ubuntu24.04:lnmp环境搭建之一:安装php+nginx环境
一,安装nginx:
用apt安装
# apt install nginx
查看状态:
# systemctl status nginx
使自动启动:
# systemctl enable nginx.service
确认是否自动启动:
# systemctl is-enabled nginx.service
enabled
二,安装php:
安装php
# apt install php
安装php-fpm
# apt install php-fpm
查看状态
# systemctl status php8.3-fpm.service
使自动启动:
# systemctl enable php8.3-fpm.service
Synchronizing state of php8.3-fpm.service with SysV service script with /usr/lib/systemd/systemd-sysv-install.
Executing: /usr/lib/systemd/systemd-sysv-install enable php8.3-fpm
确认是否自动启动:
# systemctl is-enabled php8.3-fpm.service
enabled
三,配置nginx访问php:
使可访问php:
# vi /etc/nginx/sites-enabled/default
把下面一段去掉注释:
location ~ \.php$ {
include snippets/fastcgi-php.conf;
#
# # With php-fpm (or other unix sockets):
fastcgi_pass unix:/run/php/php8.3-fpm.sock;
# # With php-cgi (or other tcp sockets):
# fastcgi_pass 127.0.0.1:9000;
}
四,测试效果:

浙公网安备 33010602011771号