当前位置:网站首页>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
边栏推荐
- Seay source code audit system
- 与张小姐的春夏秋冬(2)
- Bare metal cloud FASS high performance elastic block storage solution
- Breaking through the hardware bottleneck (I): the development of Intel Architecture and bottleneck mining
- Xsan is highly available - xdfs and San are integrated with new vitality
- “山东大学移动互联网开发技术教学网站建设”项目实训日志五
- Gluster cluster management analysis
- SQL修复重复数据
- Mobile terminal -flex item attribute
- Novice introduction: download from PHP environment to thinkphp6 framework by hand
猜你喜欢

新手入门:手把手从PHP环境到ThinkPHP6框架下载

Crypto巨头们ALL IN元宇宙,PlatoFarm或能突围

Fantom (FTM) 价格将在未来几天飙升 20%

Okaleido Tiger 7.27日登录Binance NFT,首轮已获不俗成绩

裸金属云FASS高性能弹性块存储解决方案

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

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

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

Fantom (FTM) 在 FOMC会议之前飙升 45%

The Platonic metauniverse advocated by musk has long been verified by platofarm
随机推荐
运动健康深入人心,MOVE PROTOCOL引领品质生活
Fantom (FTM) 价格将在未来几天飙升 20%
第五空间智能安全⼤赛真题----------PNG图⽚转换器
Xsan is highly available - xdfs and San are integrated with new vitality
Mobile terminal -flex item attribute
Read and understand move2earn project - move
与张小姐的春夏秋冬(2)
xtrabackup 的使用
剑指核心-TaoCloud全闪SDS助力构建高性能云服务
熊市下PLATO如何通过Elephant Swap,获得溢价收益?
Go|gin quickly use swagger
量化开发必掌握的30个知识点【什么是Level-2数据】
Go|Gin 快速使用Swagger
识变!应变!求变!
性能对比|FASS iSCSI vs NVMe/TCP
Windows下cmd窗口连接mysql并操作表
QT layout management -- Part stretch principle and sizepolicy
加密资产熊市之下,PlatoFarm的策略玩法依旧能获得稳定收益
Strategic cooperation with many institutions shows the strength of the leading company of platofarm yuancosmos
What is wapiti and how to use it