Ubuntu下部署ThinkPHP项目的标准流程
一 环境准备与安装
二 部署项目代码
三 Web 服务器配置
server {
listen 80;
server_name your_domain.com;
root /var/www/your_project/public;
index index.php index.html;
location / {
try_files $uri $uri/ /index.php?$query_string;
}
location ~ \.php$ {
include snippets/fastcgi-php.conf;
fastcgi_pass unix:/run/php/php7.4-fpm.sock; # 按实际 PHP 版本调整
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
# 安全:禁止访问敏感文件
location ~ /\.env { deny all; }
location ~ /\.ht { deny all; }
}
四 应用配置与安全加固
五 上线验证与常见问题