当前位置:网站首页>Most PHP programmers don't understand how to deploy safe code
Most PHP programmers don't understand how to deploy safe code
2022-07-29 05:51:00 【Liaoshengping】

If your website is still based on 777 As permission , Then your server will be open to anyone , Anyone can execute scripts in the directory .
I have seen some outsourcing projects of others , Unexpectedly, the permissions of the whole project are set to 777 , In fact, it is very terrible , Hackers can upload files to any directory , And execute the file .
This is terrible , Some programmers can use some tools to scan for vulnerabilities , Like a lot of php The programmer said in his resume , Cracked php, Implant the back door, etc , It's all because of the early php Low threshold for programmers , Weak awareness of safety , Many websites can get Shell.
How to set it up correctly php Running directory ? Let me summarize some methods , Share with you .
Set the owner of the directory
php The program is generally for nginx perhaps apche Called , So the system will have a www( Depending on the situation , Some are www-data) Of users and user groups
sudo chown -R www-data:www-data /path/to/your/laravel/root/directory
But if we use php artisan command , Or when you want to use FTP Transfer files to the server , Setting permissions like this will result in an error , Because the permission of this directory belongs to www-data:www-data Users and user groups . You should add to web In the user group of .(ubantu It's called ubantu,vagrant It's called vagrant)
sudo usermod -a -G www-data ubuntu
Set the permissions
First of all, restore your original program
to php Read and write permissions required by the framework .
Laravel:
sudo chgrp -R www-data storage bootstrap/cache
sudo chmod -R ug+rwx storage bootstrap/cache
If it is Tp frame :
sudo chgrp -R www-data runtime
sudo chmod -R ug+rwx runtime
So your php The framework is relatively safe .
Upload permission
Some of our small programs need to upload pictures or files to the server ( But it is recommended to upload to OSS Or a third-party storage scheme such as seven cows .)
Prevent the uploaded program from being attacked by malicious programs , We can do it in Nginx perhaps Apache Refuse to run php Script
Nginx:
location ~ ^/(uploads|assets)/.*\.(php|php5|jsp)$ {
deny all;
}
Apache:
RewriteEngine on RewriteCond % !^$
RewriteRule uploads/(.*).(php)$ – [F]
This is so , Your program is covered with a thick shield
边栏推荐
- win10+opencv3.2+vs2015配置
- 我的理想工作,码农的绝对自由支配才是最重要的——未来创业的追求
- July 28 ens/usd Value Forecast: ENS attracts huge profits
- 焕然一新,swagger UI 主题更改
- “山东大学移动互联网开发技术教学网站建设”项目实训日志六
- What is nmap and how to use it
- Laravel service container (Application of context binding)
- Fvuln automated web vulnerability detection tool
- “山东大学移动互联网开发技术教学网站建设”项目实训日志五
- DAO赛道异军突起,M-DAO的优势在哪里?
猜你喜欢

北京宝德&TaoCloud共建信创之路

“山东大学移动互联网开发技术教学网站建设”项目实训日志三

What is sqlmap and how to use it

Windows下cmd窗口连接mysql并操作表

The LAAS protocol of defi 2.0 is the key to revitalizing the development of defi track

Novice introduction: download from PHP environment to thinkphp6 framework by hand

Laravel Swagger添加访问密码

“山东大学移动互联网开发技术教学网站建设”项目实训日志一

iSCSI vs iSER vs NVMe-TCP vs NVMe-RDMA

C# 判断用户是手机访问还是电脑访问
随机推荐
Common prompt pop-up box of uniapp
大部分PHP程序员,都搞不懂如何安全代码部署
CMD window under Windows connects to MySQL and operates the table
全闪分布式,如何深度性能POC?
熊市下PLATO如何通过Elephant Swap,获得溢价收益?
Starfish OS:以现实为纽带,打造元宇宙新范式
iSCSI vs iSER vs NVMe-TCP vs NVMe-RDMA
Record the SQL injection vulnerability of XX company
QT setting background image method
Training log III of "Shandong University mobile Internet development technology teaching website construction" project
Training log 7 of the project "construction of Shandong University mobile Internet development technology teaching website"
What is nmap and how to use it
完全去中心化的编程模式,不需要服务器,也不需要ip,就像一张漫无目的的网络、四处延伸
与张小姐的春夏秋冬(2)
突破硬件瓶颈(一):Intel体系架构的发展与瓶颈挖掘
Go|Gin 快速使用Swagger
赓续新征程,共驭智存储
剑指核心-TaoCloud全闪SDS助力构建高性能云服务
加密资产熊市之下,PlatoFarm的策略玩法依旧能获得稳定收益
Move protocol global health declaration, carry out the health campaign to the end