{"id":16,"date":"2026-03-24T13:34:13","date_gmt":"2026-03-24T05:34:13","guid":{"rendered":"https:\/\/www.bengzi.cn\/?p=16"},"modified":"2026-03-24T13:36:31","modified_gmt":"2026-03-24T05:36:31","slug":"lnmp%e6%9c%8d%e5%8a%a1%e5%99%a8%e5%bf%ab%e9%80%9f%e6%90%ad%e5%bb%ba%e6%95%99%e7%a8%8b","status":"publish","type":"post","link":"https:\/\/www.bengzi.cn\/?p=16","title":{"rendered":"LNMP\u670d\u52a1\u5668\u5feb\u901f\u642d\u5efa\u6559\u7a0b"},"content":{"rendered":"\n<p id=\"u05a2c938\"><strong>CentOS Stream 9<\/strong> \u4e0a\u642d\u5efa <strong>LNMP \u73af\u5883\u5e76\u4f7f\u7528 PHP 8.3<\/strong><\/p>\n\n\n\n<p id=\"u34ec97ab\">cat \/etc\/os-release<\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\" id=\"szfyw\"\/>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"84d857d8\">\u4e00\u3001\u7cfb\u7edf\u51c6\u5907<\/h2>\n\n\n\n<pre id=\"dvsVQ\" class=\"wp-block-code\"><code>sudo dnf update -y\nsudo dnf install epel-release -y\nsudo dnf groupinstall \"Development Tools\" -y<\/code><\/pre>\n\n\n\n<p id=\"u767c581e\">\u9632\u706b\u5899\uff1a<\/p>\n\n\n\n<pre id=\"Xsxxp\" class=\"wp-block-code\"><code>sudo systemctl enable firewalld\nsudo systemctl start firewalld\nsudo firewall-cmd --permanent --add-service=http\nsudo firewall-cmd --permanent --add-service=https\nsudo firewall-cmd --reload<\/code><\/pre>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\" id=\"IYfrq\"\/>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"0319a10e\">\u4e8c\u3001\u5b89\u88c5 Nginx<\/h2>\n\n\n\n<pre id=\"NNg1q\" class=\"wp-block-code\"><code>sudo dnf install nginx -y\nsudo systemctl enable nginx\nsudo systemctl start nginx\ncurl http:\/\/localhost<\/code><\/pre>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\" id=\"mFYte\"\/>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"c09de1b7\">\u4e09\u3001\u5b89\u88c5 MariaDB\uff08\u6216 MySQL\uff09<\/h2>\n\n\n\n<pre id=\"oCqxw\" class=\"wp-block-code\"><code>sudo dnf install mariadb-server mariadb -y\nsudo systemctl enable mariadb\nsudo systemctl start mariadb\nsudo mysql_secure_installation<\/code><\/pre>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\" id=\"yJa94\"\/>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"7644ff80\">\u56db\u3001\u5b89\u88c5 PHP 8.3<\/h2>\n\n\n\n<ol class=\"wp-block-list\">\n<li><strong>\u6dfb\u52a0 Remi \u4ed3\u5e93<\/strong><\/li>\n<\/ol>\n\n\n\n<pre id=\"K8dyl\" class=\"wp-block-code\"><code>sudo dnf install https:\/\/rpms.remirepo.net\/enterprise\/remi-release-9.rpm -y\nsudo dnf module reset php -y\nsudo dnf module enable php:remi-8.3 -y<\/code><\/pre>\n\n\n\n<ol class=\"wp-block-list\">\n<li><strong>\u5b89\u88c5 PHP \u53ca\u5e38\u7528\u6269\u5c55<\/strong><\/li>\n<\/ol>\n\n\n\n<pre id=\"XgrgZ\" class=\"wp-block-code\"><code>sudo dnf install php php-fpm php-cli php-mysqlnd php-json php-gd php-mbstring php-curl php-xml php-intl php-zip -y<\/code><\/pre>\n\n\n\n<ol class=\"wp-block-list\">\n<li><strong>\u914d\u7f6e PHP-FPM<\/strong><\/li>\n<\/ol>\n\n\n\n<pre id=\"BhRNR\" class=\"wp-block-code\"><code>sudo vi \/etc\/php-fpm.d\/www.conf<\/code><\/pre>\n\n\n\n<p id=\"ud4b364d7\">\u4fee\u6539\uff1a<\/p>\n\n\n\n<pre id=\"TuNUy\" class=\"wp-block-code\"><code>user = nginx\ngroup = nginx\nlisten.owner = nginx\nlisten.group = nginx\nlisten = \/run\/php-fpm\/www.sock<\/code><\/pre>\n\n\n\n<ol class=\"wp-block-list\">\n<li><strong>\u542f\u52a8 PHP-FPM<\/strong><\/li>\n<\/ol>\n\n\n\n<pre id=\"Xmdej\" class=\"wp-block-code\"><code>sudo systemctl enable php-fpm\nsudo systemctl start php-fpm<\/code><\/pre>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\" id=\"LyY8N\"\/>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"d89bb29c\">\u4e94\u3001\u914d\u7f6e Nginx \u652f\u6301 PHP<\/h2>\n\n\n\n<p id=\"uce776731\">\u7f16\u8f91 Nginx \u914d\u7f6e <code>\/etc\/nginx\/conf.d\/default.conf<\/code>\uff1a<\/p>\n\n\n\n<pre id=\"oFDeV\" class=\"wp-block-code\"><code>server {\n    listen       80;\n    server_name  localhost;\n\n    root   \/usr\/share\/nginx\/html;\n    index  index.php index.html index.htm;\n\n    location \/ {\n        try_files $uri $uri\/ =404;\n    }\n\n    location ~ \\.php$ {\n        include fastcgi_params;\n        fastcgi_pass unix:\/run\/php-fpm\/www.sock;\n        fastcgi_index index.php;\n        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;\n    }\n\n    error_log \/var\/log\/nginx\/error.log;\n    access_log \/var\/log\/nginx\/access.log;\n}<\/code><\/pre>\n\n\n\n<p id=\"ucfd3673d\">\u6d4b\u8bd5\u914d\u7f6e\u5e76\u91cd\u8f7d\uff1a<\/p>\n\n\n\n<pre id=\"ZOrSQ\" class=\"wp-block-code\"><code>sudo nginx -t\nsudo systemctl reload nginx<\/code><\/pre>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\" id=\"nw3BH\"\/>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"b10c2070\">\u516d\u3001\u6d4b\u8bd5 PHP<\/h2>\n\n\n\n<pre id=\"ZWtBt\" class=\"wp-block-code\"><code>echo \"&lt;?php phpinfo(); ?&gt;\" | sudo tee \/usr\/share\/nginx\/html\/info.php<\/code><\/pre>\n\n\n\n<p id=\"u63138a3a\">\u6d4f\u89c8\u5668\u8bbf\u95ee\uff1a<code>http:\/\/\u670d\u52a1\u5668IP\/info.php<\/code>\uff0c\u786e\u8ba4 PHP 8.3 \u5df2\u8fd0\u884c\u3002<\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\" id=\"tVUO9\"\/>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"c1d1d33c\">\u4e03\u3001\u53ef\u9009\uff1a\u5b89\u88c5 Redis<\/h2>\n\n\n\n<pre id=\"lshKm\" class=\"wp-block-code\"><code>sudo dnf install redis -y\nsudo systemctl enable redis\nsudo systemctl start redis\nredis-cli ping  #<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"G3twL\">\u516b\u3001\u53ef\u9009\uff1anode.js<\/h2>\n\n\n\n<pre id=\"lqSYd\" class=\"wp-block-code\"><code># \u5b89\u88c5 Node.js (\u4f7f\u7528 nvm \u6216\u7cfb\u7edf\u5305\u7ba1\u7406\u5668)\ncurl -o- https:\/\/raw.githubusercontent.com\/nvm-sh\/nvm\/v0.39.0\/install.sh | bash\nsource ~\/.bashrc\nnvm install 20\nnvm use 20\n\n# \u5b89\u88c5\u524d\u7aef\u4f9d\u8d56\u5e76\u6784\u5efa\nnpm install\nnpm run build<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"ugz6p\">\u4e5d\u3001\u53ef\u9009\uff1a\u5b89\u88c5 Composer \u4f9d\u8d56<\/h2>\n\n\n\n<pre id=\"mh8PI\" class=\"wp-block-code\"><code># \u5982\u679c\u6ca1\u6709\u5b89\u88c5 Composer\uff0c\u5148\u5b89\u88c5\ncurl -sS https:\/\/getcomposer.org\/installer | php\nsudo mv composer.phar \/usr\/local\/bin\/composer\n\n# \u5b89\u88c5\u9879\u76ee\u4f9d\u8d56\uff08\u751f\u4ea7\u73af\u5883\u4f7f\u7528 --no-dev\uff09\ncomposer install --no-dev --optimize-autoloader<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>CentOS Stream 9 \u4e0a\u642d\u5efa LNMP \u73af\u5883\u5e76\u4f7f\u7528 PHP 8.3 cat \/etc\/os-rele [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":18,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[6],"tags":[],"class_list":["post-16","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-6"],"blocksy_meta":[],"_links":{"self":[{"href":"https:\/\/www.bengzi.cn\/index.php?rest_route=\/wp\/v2\/posts\/16","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.bengzi.cn\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.bengzi.cn\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.bengzi.cn\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.bengzi.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=16"}],"version-history":[{"count":1,"href":"https:\/\/www.bengzi.cn\/index.php?rest_route=\/wp\/v2\/posts\/16\/revisions"}],"predecessor-version":[{"id":17,"href":"https:\/\/www.bengzi.cn\/index.php?rest_route=\/wp\/v2\/posts\/16\/revisions\/17"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.bengzi.cn\/index.php?rest_route=\/wp\/v2\/media\/18"}],"wp:attachment":[{"href":"https:\/\/www.bengzi.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=16"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.bengzi.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=16"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.bengzi.cn\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=16"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}