LNMP环境下部署PHP应用的实操指南
一 准备与安装
二 上传代码与数据库初始化
三 Nginx与PHP-FPM配置
server {
listen 80;
server_name your_domain;
root /var/www/your_project/public;
index index.php index.html index.htm;
location / {
try_files $uri $uri/ /index.php?$query_string;
}
location ~ \.php$ {
include snippets/fastcgi-php.conf;
fastcgi_pass unix:/var/run/php/php7.4-fpm.sock; # 按实际版本与路径修改
}
location ~ /\.ht {
deny all;
}
}
四 多环境与PHP版本切换
五 验证与常见问题处理