Ubuntu上 ThinkPHP 项目安全加固清单
一 基础部署与运行环境
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_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_pass unix:/run/php/php8.1-fpm.sock; # 版本按实际调整
}
}
二 框架与应用层安全
三 服务器与网络防护
location ~ ^/(uploads|assets)/.*\.(php|php5|jsp)$ {
deny all;
}
四 文件与目录安全
五 持续化安全与合规