Ubuntu部署ThinkPHP项目实操指南
一 环境准备
二 部署代码与依赖
三 Web 服务器配置
server {
listen 80;
server_name your_domain.com www.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; # 例如:/run/php/php8.1-fpm.sock
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
# 安全:禁止访问 .ht* 文件
location ~ /\.ht {
deny all;
}
}
四 安全与优化
五 常见问题快速排查