ThinkPHP 安全部署
首先设置目录的所有者
sudo chown -R www-data:www-data /path/to/your/laravel/root/directory
如果我们使用php artisan 命令/FTP上传文件时报错 这个目录的权限是属于www-data:www-data 用户和用户组的。你应该要添加到web 的用户组中。
sudo usermod -a -G www-data ubuntu
设置权限
首先给自己的程序还原一下最初
给php框架所需要的读写权限。
Laravel:
sudo chgrp -R www-data storage bootstrap/cachesudo chmod -R ug+rwx storage bootstrap/cache
如果是Tp框架:
sudo chgrp -R www-data runtimesudo chmod -R ug+rwx runtime
防止上传的程序被恶意攻击程序
nginx 拒绝运行php脚本
location ~ ^/(uploads|assets)/.*\.(php|php5|jsp)$ {
deny all;
}
Apache 拒绝运行php脚本
RewriteEngine on RewriteCond % !^$RewriteRule uploads/(.*).(php)$ –

浙公网安备 33010602011771号