vim /usr/local/apache2.4/conf/extra/httpd-vhosts.conf
<Directory /data/wwwroot/123.com/upload> php_admin_flag engine off </Directory>
/usr/local/apache2.4/bin/apachectl -t /usr/local/apache2.4/bin/apachectl graceful
禁止解析upload目錄下的php文件php
;shell
mkdir /data/wwwroot/123.com/upload/ cp /data/wwwroot/123.com/admin.php /data/wwwroot/123.com/upload/example.php curl -x127.0.0.1:80 www.123.com/upload/example.php
或者apache
<Directory /data/wwwroot/123.com/upload> <FilesMatch(.*)\.php(.*)> Order allow,deny Deny from all </FilesMatch> </Directory>
/usr/local/apache2.4/bin/apachectl -t /usr/local/apache2.4/bin/apachectl graceful
禁止訪問upload目錄下的php文件;vim
user_agent能夠理解爲瀏覽器標識
user_agent爲何能夠作訪問控制呢?
背景:好比網站受到cc***。***的人經過軟件或者肉機,想***某個網站的時候,把全部的肉機發動起來,讓它們同時訪問一個站點。可是cc***每每有一個特徵,就是user_agent一致的,訪問地址一致。訪問速度快,每秒N次瀏覽器
vim /usr/local/apache2.4/conf/extra/httpd-vhosts.conf
核心配置文件內容curl
<IfModule mod_rewrite.c> RewriteEngine on RewriteCond %{HTTP_USER_AGENT} .*curl.* [NC,OR] RewriteCond %{HTTP_USER_AGENT} .*baidu.com.* [NC] RewriteRule .* - [F] </IfModule>
curl -A "123123" 指定user_agentsocket
/usr/local/apache2.4/bin/apachectl -t /usr/local/apache2.4/bin/apachectl graceful
curl -x127.0.0.1:80 www.123.com curl -A '1231' -x127.0.0.1:80 www.123.com curl -A 'baidu.com' -x127.0.0.1:80 www.123.com
查看php配置文件位置ide
vim /data/wwwroot/123.com/123.php <?php phpinfo(); ?>
經過瀏覽器查看配置文件信息函數
若是配置文件不存在就要去模板目錄下複製一份;測試
修改php配置文件
vim /usr/local/php/etc/php.ini
如下爲一般須要禁用的函數
eval,assert,popen,passthru,escapeshellarg,escapeshellcmd,passthru,exec,system,chroot,scandir,chgrp,chown,escapeshellcmd,escapeshellarg,shell_exec,proc_get_status,ini_alter,ini_restore,dl,pfsockopen,openlog,syslog,readlink,symlink,leak,popepassthru,stream_socket_server,popen,proc_open,proc_close
vim /usr/local/apache2.4/conf/extra/httpd-vhosts.conf
php_admin_value open_basedir "/data/wwwroot/123.com:/tmp/"
設置表示容許訪問當前目錄(即PHP腳本文件所在之目錄)和/tmp/目錄,能夠防止php***跨站