| 主機參考:VPS測評參考推薦/專注分享VPS服務器優惠信息!若您是商家可以在本站進行投稿,查看詳情!此外我們還提供軟文收錄、PayPal代付、廣告贊助等服務,查看詳情! |
| 我們發布的部分優惠活動文章可能存在時效性,購買時建議在本站搜索商家名稱可查看相關文章充分了解該商家!若非中文頁面可使用Edge瀏覽器同步翻譯!PayPal代付/收錄合作 |
php.ini配置中有3處設置可能導致網站安全出問題。那么是哪三處呢?跟著小編一起往下看吧。一定會對你們有所幫助的。
首先大家都知道所有的PHP源碼網站都必須配置環境,不論是使用集成環境還是自己手動搭建,可能很少有人關注過php.ini里面配置的這些東西到底有什么作用,很多站長在設置php.ini文件時,都是網上找一個教程,然后人家說哪里增加哪里刪除按步驟進行,但是這里面的設置還真有兩處會引起網站安全問題。
有人會說就一個php.ini文件怎么可能會有安全問題呢,難不成hiker會攻擊的我php.ini文件不成?
這倒不是啦,而是運行方式會給hiker提供一個窗口,請看下面的配置步驟說明。
以windows系統上安裝PHP為例,所有版本的php.ini文件的設置幾乎都是一樣的,先去官方網站下載需要的PHP版本,然后解壓縮并重命名。
假設安裝php7.4,安裝在服務器" target="_blank" href="http://undefined" rel="external nofollow" rel="external nofollow" rel="external nofollow" gt;服務器的D盤根目錄:下載Non-Thread Safe (NTS) 版本的PHP程序,然后解壓縮,并重命名為“php”文件夾,將其拷貝到D盤根目錄下面。
打開D:php下的php.ini-development文件,復制一份并將其重命名為php.ini,打開D:phpphp.ini文件,下面是完整的配置過程。
1、將short_open_tag = Off改為
short_open_tag = On
這樣修改的作用是一些網站的模板文件中使用了如<? ?gt;這樣的php代碼,可保證代碼可以正常執行,在ecshop、dedecms和WordPress等模板中也都常見于這類代碼。
2、將expose_php = On,將其改為
expose_php = Off
作用是出于網站安全,禁止顯示php的版本號,防止別人針對特定php版本漏洞攻擊網站。有的網站你用站長工具一查,使用的是什么web服務器、PHP版本是多少都一目了然,對于特定的PHP版本漏洞,hiker當然是知道的,隱藏版本號雖不能說解決了問題,但是會給hiker增加難度。
3、查找如下代碼
; On windows:
; extension_dir = "ext"
將這里的extension_dir前面的分號去掉,并且把ext修改為PHP的安裝路徑,如下所示。注意斜杠不要寫反了,因為我把PHP安裝在D盤的。
extension_dir = "D:phpext"
4、查找max_execution_time = 30,將數字30修改為300或1200。作用是每個腳本執行的最大時間,默認是30秒,解決可能因為網速和服務器的地址(如國外主機)可能會總是連接超時的問題。
5、搜索;cgi.force_redirect = 1,把前面的分號去掉,并把數字1改為0。cgi.force_redirect = 0的意思就是關閉重定向執行php文件,出于安全考慮防止別人上傳木馬執行如:你的網站url/as=你的網站url/sdf/muma.php,這樣的重定向PHP文件是可執行的,將這個配置改為0之后這類型的重定向PHP文件就不會執行了。
這也是為什么有的網站總是被掛馬的原因,這樣修改之后即便是網站前臺存在安全漏洞,被hiker上傳了木馬文件,通過這樣的方式木馬文件不會運行,所以沒有用。
6、查找代碼;cgi.fix_pathinfo=1將分號去掉并將數字1改為0。作用是禁止解析非法php文件,如/a.jpg/1.php這樣的圖片下的一個php文件屬于非法的,設置為0就是禁止執行。這種將木馬偽裝成圖片上傳的文件存在已久,禁止這類文件運行,即使被上傳了木馬,由于設置了不允許運行,所以沒有用。
7、查找代碼fastcgi.impersonate = 1將前面的分號去掉。作用是iis或nginx使用的是fastcgi方式解析php文件,不開啟就不能運行php程序,Apache則不用開啟。
8、搜索 cgi.rfc2616_headers = 0 去掉分號并把0改為1。意思是告訴php使用什么樣的報頭,什么是報頭呢?就像這個:HTTP/1.1。
9、搜索upload_tmp_dir =,將前面的分號刪除并添加路徑如下:
upload_tmp_dir = D:phptemp
意思是上傳文件的臨時目錄,用來存放網站上傳文件的臨時虛擬目錄,但是不會真的上傳任何文件在里面。
10、分別搜索以下代碼,一行一個,分別去掉其前面的分號(分號表示注釋,不生效的意思,去掉就生效了):
extension=bz2
extension=curl
extension=gd2
extension=gmp
extension=mbstring
extension=php_mysql" target="_blank" href="http://undefined" rel="external nofollow" rel="external nofollow" rel="external nofollow" gt;mysql.dll
extension=mysqli
extension=pdo_mysql
11、查找date.timezone =刪除分號并修改為如下這樣:
date.timezone = Asia/Shanghai
注意大小寫,意思是格式化時間,默認使用北京時間(東8區),這樣可以使服務器時間和程序的時間一致,否則可能你發文章顯示的時時間會和實際時間不一樣,如果不設置時間可能會相差8小時,也可以設置為date.timezone = PRC ,設置時區為中國時區,PRC是中國時區的簡稱。
以上就是完整的php.ini文件配置,真的有3處設置和網站的安全有關系,由于這個文件一般只會設置一次,之后都不會去更改,所以有的問題也不容易被發現。
以上就是php.ini配置中有3處設置可能導致網站安全出問題的詳細內容,你們了解了嗎?如果想了解更多請關注主機參考其它相關文章!
There are three settings in the php.ini configuration that may cause website security problems. So what are the three places? Follow Xiaobian to look down. It will certainly help you.
First of all, we all know that all PHP source websites must be configured with environment. No matter the integrated environment is used or the website is built manually, few people have paid attention to the function of these things configured in php.ini. When many webmasters are setting php.ini file, they are looking for a tutorial on the Internet, and then they are told where to add or delete it according to the steps, but here There are really two aspects of face setting that can cause website security problems.
Some people will say that how can a php.ini file have security problems? Is it possible that hiker will attack my php.ini file?
This is not true, but the operation mode will provide a window for hiker. Please see the following configuration steps.
Take PHP installed on Windows system as an exle. The settings of all versions of php.ini file are almost the same. First go to the official website to download the required PHP version, and then extract and rename it.
Suppose php7.4 is installed in the d-root directory of the server "target =" _blank "href =" http: / / undefined " gt; download the non thread safe (NTS) version of PHP program, extract it, rename it to the" PHP "folder, and copy it to the d-root directory.
Open the php.ini-development file under D: PHP, copy it and rename it to php.ini, and open the D: PHP php.ini file. The following is the complete configuration process.
1. Change short "open" tag = off to
short_open_tag = On
The effect of this modification is that some websites use template files such as lt? Gt; this kind of PHP code can ensure the normal execution of the code, which is also common in ECSHOP, dedecms, WordPress and other templates.
2. Change expose? PHP = on to
expose_php = Off
The function is to prevent PHP version number from being displayed for the sake of website security, so as to prevent other people from attacking websites against specific PHP version vulnerabilities. Some websites you use the webmaster tool to check, which web server and PHP version you use are clear at a glance. For specific PHP version vulnerabilities, hiker certainly knows. Although the hidden version number can not be said to solve the problem, it will increase the difficulty for hiker.
3. Look for the following code
; On windows:
; extension_dir = "ext"
Remove the semicolon in front of extension dir here, and change ext to the installation path of PHP, as shown below. Note that the slash should not be written backwards, because I installed PHP on disk D.
extension_dir = "D:phpext"
4. Find max? Execution? Time = 30, and change the number 30 to 300 or 1200. The function is the maximum execution time of each script, which is 30 seconds by default. It can solve the problem that the connection may always time out due to the network speed and the address of the server (such as the foreign host).
5. Search; cgi.force_redirect = 1, remove the previous semicolon and change the number 1 to 0. Cgi.force_redirect = 0 means to close the redirection execution PHP file. For security reasons, prevent other people from uploading the Trojan horse to execute, such as: your website URL / as = your website URL / SDF / muma.php, so the redirection PHP file is executable. After changing this configuration to 0, this type of redirection PHP file will not execute.
This is also the reason why some websites are always hung up. After modification, even if there is a security hole in the front desk of the website, the Trojan file is uploaded by hiker. In this way, the Trojan file will not run, so it is useless.
6. Find the code; CGI. Fix_pathinfo = 1 remove the semicolon and change the number 1 to 0. The function is to prevent parsing illegal PHP files. For exle, a PHP file under a picture like / a.jpg/1.php is illegal. Setting 0 is to prevent execution. This kind of Trojan disguised as a picture upload file has existed for a long time. It is forbidden to run this kind of file. Even if the Trojan is uploaded, it is useless because it is set not to run.
7. Find the code fastcgi. Impersonate = 1 to remove the previous semicolon. The function is that IIS or nginx uses the fastcgi method to parse PHP files. If you do not open it, you cannot run PHP programs. Apache does not need to open it.
8. Search cgi.rfc2616 ﹐ headers = 0 remove the semicolon and change 0 to 1. It means to tell PHP what kind of header to use and what is it? Like this: http / 1.1.
9. Search for upload? TMP? Dir =, delete the previous semicolon and add the path as follows:
upload_tmp_dir = D:phptemp
It means the temporary directory of uploaded files, which is used to store the temporary virtual directory of uploaded files on the website, but it will not really upload any files in it.
10. Search for the following codes, one line at a time, and remove the semicolon (semicolon means comment. If it is not effective, it will take effect):
extension=bz2
extension=curl
extension=gd2
extension=gmp
extension=mbstring
extension=php_mysql" target="_blank" href="http://undefined" rel="external nofollow" rel="external nofollow" rel="external nofollow" gt;mysql.dll
extension=mysqli
extension=pdo_mysql
11. Find date.timezone = delete the semicolon and change it to the following:
date.timezone = Asia/Shanghai
Pay attention to case, which means format time. Beijing time (East 8 area) is used by default, so that the server time is consistent with the program time. Otherwise, the time displayed in your post may be different from the actual time. If you don't set the time, it may be 8 hours different, or you can set it to date.timezone = PRC , set the time zone as China time zone, and PRC is the abbreviation of China time zone.
The above is the complete php.ini file configuration. There are really three settings that have something to do with the security of the website. Because this file is usually only set once and will not be changed later, some problems are not easy to find.
The above is the details of three settings in php.ini configuration that may cause website security problems. Do you understand? If you want to learn more, please pay attention to the host and refer to other related articles!
--------------------------------------------------------------
主機參考,收集國內外VPS,VPS測評,主機測評,云服務器,虛擬主機,獨立服務器,國內外服務器,高性價比建站主機相關優惠信息@www.k2270.com
詳細介紹和測評國外VPS主機,云服務器,國外服務器,國外主機的相關優惠信息,商家背景,網絡帶寬等等,也是目前國內最好的主機云服務器VPS參考測評資訊優惠信息分享平臺
這幾篇文章你可能也喜歡:
- inMotion.hosting:虛擬主機/VPS/經銷商主持人黑色星期五促銷活動,虛擬主機套餐每月$ 2.29
- Hostinger綜合審查(Hostdare如何可用)
- 藍色Xiyun香港AMD服務器4內核4G 19.9/月8核8G 39/月16核心16G 79/月,相同的價格更新價格
- HOSTDARE US虛擬托管在第一個月起為0.03美元(US Virtual IP)
- 網站服務器和虛擬主機有什么區別? (虛擬主機和虛擬服務器)
本文由主機參考刊發,轉載請注明:php.ini配置中有3處設置可能導致網站安全出問題 http://www.k2270.com/12740.html
主機參考

















評論前必須登錄!
注冊