当前位置:网站首页>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
边栏推荐
- How can Plato obtain premium income through elephant swap in a bear market?
- 新手入门:手把手从PHP环境到ThinkPHP6框架下载
- Differences between href and SRC
- NIFI 改UTC时间为CST时间
- The bear market is slow, and bit.store provides stable stacking products to help you get through the bull and bear market
- Record the SQL injection vulnerability of XX company
- “山东大学移动互联网开发技术教学网站建设”项目实训日志三
- The openatom openharmony sub forum was successfully held, and ecological and industrial development entered a new journey
- 7 月 28 日 ENS/USD 价值预测:ENS 吸引巨额利润
- 加密资产熊市之下,PlatoFarm的策略玩法依旧能获得稳定收益
猜你喜欢

熊市下PLATO如何通过Elephant Swap,获得溢价收益?

Extreme deflation and perpetual motion machine model will promote the outbreak of platofarm

第五空间智能安全⼤赛真题----------PNG图⽚转换器

Reporting Service 2016 自定义身份验证

运动健康深入人心,MOVE PROTOCOL引领品质生活

centos7 静默安装oracle

Huawei 2020 school recruitment written test programming questions read this article is enough (Part 2)

IDEA使用JDBC连接MySQL数据库个人详细教程

Crypto giants all in metauniverse, and platofarm may break through

D3.JS 纵向关系图(加箭头,连接线文字描述)
随机推荐
Under the bear market of encrypted assets, platofarm's strategy can still obtain stable income
Fvuln automated web vulnerability detection tool
ReportingService WebService Form身份验证
Reporting Service 2016 自定义身份验证
『全闪实测』数据库加速解决方案
“山东大学移动互联网开发技术教学网站建设”项目实训日志二
Novice introduction: download from PHP environment to thinkphp6 framework by hand
Read and understand move2earn project - move
量化开发必掌握的30个知识点【什么是Level-2数据】
dcat 批量操作弹窗及参数传递
D3.JS 纵向关系图(加箭头,连接线文字描述)
“山东大学移动互联网开发技术教学网站建设”项目实训日志七
How to survive in the bear market of encryption market?
Training log III of "Shandong University mobile Internet development technology teaching website construction" project
加密资产熊市之下,PlatoFarm的策略玩法依旧能获得稳定收益
Crypto巨头们ALL IN元宇宙,PlatoFarm或能突围
Laravel service container (Application of context binding)
Huawei 2020 school recruitment written test programming questions read this article is enough (Part 2)
山寨币SHIB 在 ETH 鲸鱼的投资组合中拥有 5.486 亿美元的股份——交易者应提防……
Fantom (FTM) prices will soar by 20% in the next few days