{"id":118,"date":"2023-06-26T11:27:18","date_gmt":"2023-06-26T03:27:18","guid":{"rendered":"https:\/\/www.book2022.top\/?p=118"},"modified":"2026-06-29T12:14:06","modified_gmt":"2026-06-29T04:14:06","slug":"%e6%89%8b%e5%8a%a8%e9%83%a8%e7%bd%b2lnmp%e7%8e%af%e5%a2%83debian-2","status":"publish","type":"post","link":"https:\/\/www.book2020.top\/?p=118","title":{"rendered":"\u624b\u52a8\u90e8\u7f72LNMP\u73af\u5883debian"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\">\u67e5\u770bdebian\/ubuntu\u7248\u672c\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>cat \/etc\/issue<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">\u66f4\u65b0\u7cfb\u7edf\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>apt-get update &amp;&amp; apt-get upgrade -y<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">\u5b89\u88c5\u4f9d\u8d56\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>apt -y install build-essential libpcre2-dev zlib1g-dev git dbus manpages-dev aptitude g++ wget curl unzip libssl-dev libxslt-dev libgd-dev libgeoip-dev vim<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">\u6821\u51c6\u65f6\u95f4\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>ln -sf \/usr\/share\/zoneinfo\/Asia\/Shanghai \/etc\/localtime &amp;&amp; date -R<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">\u4e0b\u8f7d\/\u5b89\u88c5\/\u89e3\u538blibmaxminddb<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>wget https:\/\/github.com\/maxmind\/libmaxminddb\/releases\/download\/1.13.3\/libmaxminddb-1.13.3.tar.gz &amp;&amp; tar -zxvf libmaxminddb-1.13.3.tar.gz &amp;&amp; cd libmaxminddb-1.13.3 &amp;&amp; .\/configure<\/code><\/pre>\n\n\n\n<pre class=\"wp-block-code\"><code>make &amp;&amp; make install &amp;&amp; ldconfig &amp;&amp; cd<\/code><\/pre>\n\n\n\n<pre class=\"wp-block-code\"><code>git clone https:\/\/github.com\/leev\/ngx_http_geoip2_module.git<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">\u4e0b\u8f7d\/\u5b89\u88c5\/\u89e3\u538b openssl<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>wget -nc --no-check-certificate https:\/\/github.com\/openssl\/openssl\/releases\/download\/openssl-4.0.1\/openssl-4.0.1.tar.gz &amp;&amp; tar -zxvf openssl-4.0.1.tar.gz<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">\u4e0b\u8f7d\/\u89e3\u538b nginx<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>wget -nc --no-check-certificate https:\/\/nginx.org\/download\/nginx-1.30.2.tar.gz &amp;&amp; tar -zxvf nginx-1.30.2.tar.gz<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">\u5220\u9664 nginx.tar.gz\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>rm -rf nginx-1.30.2.tar.gz &amp;&amp; rm -rf openssl-4.0.1.tar.gz &amp;&amp; rm -rf libmaxminddb-1.13.3.tar.gz &amp;&amp; cd nginx-1.30.2<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">\u6dfb\u52a0\u7f16\u8bd1\u63d2\u4ef6\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>.\/configure --prefix=\/etc\/nginx \\\n    --with-threads \\\n    --with-file-aio \\\n    --with-http_ssl_module \\\n    --with-http_v2_module \\\n    --with-http_v3_module \\\n    --with-http_realip_module \\\n    --with-http_sub_module \\\n    --with-http_gzip_static_module \\\n    --with-http_auth_request_module \\\n    --with-http_secure_link_module \\\n    --with-http_stub_status_module \\\n    --with-cc-opt='-march=native -O3' \\\n    --with-stream \\\n    --with-stream_ssl_module \\\n    --with-stream_realip_module \\\n    --add-dynamic-module=..\/ngx_http_geoip2_module \\\n    --with-stream_ssl_preread_module \\\n    --with-compat \\\n    --with-openssl-opt=enable-tls1_3 \\\n    --with-openssl=..\/openssl-4.0.1<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">\u7f16\u8bd1\/\u5b89\u88c5 nginx<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>make &amp;&amp; make install<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">\u914d\u7f6enginx\u670d\u52a1\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>cat &gt;\/etc\/systemd\/system\/nginx.service &lt;&lt;EOF\n&#91;Unit]\nDescription=A high performance web server and a reverse proxy server\nDocumentation=man:nginx(8)\nAfter=network.target nss-lookup.target\n\n&#91;Service]\nType=forking\nPIDFile=\/etc\/nginx\/logs\/nginx.pid\nExecStartPre=\/etc\/nginx\/sbin\/nginx -t -q -g 'daemon on; master_process on;'\nExecStart=\/etc\/nginx\/sbin\/nginx -g 'daemon on; master_process on;'\nExecReload=\/etc\/nginx\/sbin\/nginx -g 'daemon on; master_process on;' -s reload\nExecStop=-\/sbin\/start-stop-daemon --quiet --stop --retry QUIT\/5 --pidfile \/etc\/nginx\/logs\/nginx.pid\nTimeoutStopSec=5\nKillMode=mixed\n\n&#91;Install]\nWantedBy=multi-user.target\nEOF<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">\u6dfb\u52a0\u914d\u7f6e\u6587\u4ef6\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>mkdir -p \/etc\/nginx\/ssl \/etc\/systemd\/system\/nginx.service.d &amp;&amp; printf \"&#91;Service]\\nExecStartPost=\/bin\/sleep 0.1\\n\" &gt; \/etc\/systemd\/system\/nginx.service.d\/override.conf<\/code><\/pre>\n\n\n\n<pre class=\"wp-block-code\"><code>cd &amp;&amp; rm -rf nginx-1.30.2 openssl-4.0.1 libmaxminddb-1.13.3 ngx_http_geoip2_module<\/code><\/pre>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>\u4e0b\u8f7d<a href=\"https:\/\/github.com\/P3TERX\/GeoLite.mmdb\/raw\/download\/GeoLite2-Country.mmdb\">GeoLite2-Country\u6570\u636e<\/a><\/strong><\/li>\n<\/ul>\n\n\n\n<pre class=\"wp-block-code\"><code>wget -P \/etc\/nginx\/GeoLite2 https:\/\/raw.githubusercontent.com\/P3TERX\/GeoLite.mmdb\/download\/GeoLite2-Country.mmdb<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">\u5b89\u88c5MariaDB php\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>apt install php-fpm php-mysql mariadb-server -y<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">\u5b89\u88c5php\u63d2\u4ef6\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>apt install php-curl php-gd php-imagick php-intl php-mbstring php-zip php-dom -y<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">mysql\u6216MariaDB\u5b89\u5168\u52a0\u56fa\uff1a<br>\u4f1a\u8bbe\u7f6e\u5bc6\u7801\uff0c\u754c\u97621\u76f4\u63a5\u56de\u8f66\uff0c\u5269\u7684\u90fd\u9009Y\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>mariadb-secure-installation<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">root\u767b\u5f55\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>mariadb -u root -p<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">\u67e5\u770b\u5f53\u524d\u7684\u6570\u636e\u5e93\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>show databases;<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">\u521b\u5efa\u6570\u636e\u5e93\u975eroot\u7528\u6237\u540d\u5bc6\u7801\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>create database wordpress; create user name@localhost identified by 'password';<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">\u6388\u4e88\u6743\u9650\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>grant all privileges on wordpress.* to name@localhost; flush privileges;<\/code><\/pre>\n\n\n\n<ul class=\"wp-block-list\">\n<li>\u4f7f\u5bc6\u7801\u751f\u6548<\/li>\n<\/ul>\n\n\n\n<pre class=\"wp-block-code\"><code>ALTER USER root@localhost IDENTIFIED VIA mysql_native_password USING PASSWORD(\"password\");<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">\u9000\u51fa\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>exit<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>\u4e0b\u8f7dhttps:\/\/typecho.org\/ \u89e3\u538b\u653e\u5728\/etc\/nginx\/html\u6587\u4ef6\u5939\u4e0b\uff0c<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u5b89\u88c5wordpress<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>cd \/etc\/nginx\/html &amp;&amp; wget https:\/\/cn.wordpress.org\/latest-zh_CN.zip &amp;&amp; unzip latest-zh_CN.zip &amp;&amp; mv wordpress\/* \/etc\/nginx\/html &amp;&amp; rm -rf latest-zh_CN.zip wordpress &amp;&amp; cd<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">\u7528\u7684\u975eroot\u8d26\u6237\u8981\u7ed9html\u6587\u4ef6\u5939\u8d4b\u7ed9\u6743\u9650\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>chown -R www-data:www-data \/etc\/nginx\/html<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">\u5b89\u88c5nginx\u914d\u7f6e\u6587\u4ef6<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>vim \/etc\/nginx\/conf\/nginx.conf<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">\u5728\u7b2c\u4e00\u884c\u6dfb\u52a0<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>load_module \/etc\/nginx\/modules\/ngx_http_geoip2_module.so;\nload_module \/etc\/nginx\/modules\/ngx_stream_geoip2_module.so;\nuser  root;<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">http {\u5757\u4e0b\u6dfb\u52a0<br><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>include conf.d\/default.conf;\n\t# GeoIP2 \u56fd\u5bb6\u8bc6\u522b\n\tmap $http_x_forwarded_for $clientRealIp {\n\t\t\"\" $remote_addr;\n\t\t~^(?P&lt;firstAddr&gt;&#91;0-9\\.]+),?.*$ $firstAddr;\n\t}\n\tgeoip2 \/etc\/nginx\/GeoLite2\/GeoLite2-Country.mmdb {\n\t\tauto_reload 5m;\n\t\t$geoip2_data_country_code default=XX source=$clientRealIp country iso_code;\n\t}\n\tmap $geoip2_data_country_code $allowed_country {\n\t\tCN      yes;\n\t\tJP      yes;\n\t\tHK      yes;\n\t\tUS      yes;\n\t\tCA      yes;\n\t\tFR      yes;\n\t\tdefault no;\n\t}<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">server {\u5757\u4e0b\u7684<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">location \/ {\u6dfb\u52a0<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>\tif ($allowed_country = no) {\n\t    return 404;\n\t}<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">\u6dfb\u52a0dhparam<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>curl https:\/\/ssl-config.mozilla.org\/ffdhe2048.txt &gt; \/etc\/nginx\/ssl\/dhparam<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">\u5f00\u542fBBR\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>echo \"net.core.default_qdisc=fq\" &gt;&gt; \/etc\/sysctl.conf &amp;&amp; echo \"net.ipv4.tcp_congestion_control=bbr\" &gt;&gt; \/etc\/sysctl.conf &amp;&amp; sysctl -p &amp;&amp; lsmod | grep bbr<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">\u52a0\u8f7d\u5355\u5143\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>systemctl daemon-reload<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">\u5f00\u542fnginx\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>systemctl start nginx<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">\u5f00\u542f\u72b6\u6001\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>systemctl status nginx<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">\u5f00\u673a\u81ea\u52a8\u542f\u52a8\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>systemctl enable nginx<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">\u91cd\u65b0\u542f\u52a8\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>systemctl restart nginx<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">\u505c\u6b62nginx\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>service nginx stop<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">\u5f00\u542fphp8.2-fpm\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>systemctl start php8.4-fpm<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">\u5f00\u542f\u72b6\u6001\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>systemctl status php8.4-fpm<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">\u5f00\u673a\u81ea\u52a8\u542f\u52a8\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>systemctl enable php8.4-fpm<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">\u91cd\u65b0\u542f\u52a8\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>systemctl restart php8.4-fpm<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">\u5f00\u542fmysql\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>systemctl start mariadb.service<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">\u5f00\u542f\u72b6\u6001\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>systemctl status mariadb.service<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">\u5f00\u673a\u81ea\u52a8\u542f\u52a8\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>systemctl enable mariadb.service<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">\u91cd\u65b0\u542f\u52a8\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>systemctl restart mariadb.service<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>\u67e5\u770bdebian\/ubuntu\u7248\u672c\uff1a \u66f4\u65b0\u7cfb\u7edf\uff1a \u5b89\u88c5\u4f9d\u8d56\uff1a \u6821\u51c6\u65f6\u95f4\uff1a \u4e0b\u8f7d\/\u5b89\u88c5\/\u89e3\u538blibmaxmind&#8230;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":true,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-118","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/www.book2020.top\/index.php?rest_route=\/wp\/v2\/posts\/118","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.book2020.top\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.book2020.top\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.book2020.top\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.book2020.top\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=118"}],"version-history":[{"count":5,"href":"https:\/\/www.book2020.top\/index.php?rest_route=\/wp\/v2\/posts\/118\/revisions"}],"predecessor-version":[{"id":259,"href":"https:\/\/www.book2020.top\/index.php?rest_route=\/wp\/v2\/posts\/118\/revisions\/259"}],"wp:attachment":[{"href":"https:\/\/www.book2020.top\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=118"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.book2020.top\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=118"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.book2020.top\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=118"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}