11.28 restricting a directory from parsing PHP
Editing a configuration file httpd-vhosts.conf
Vim/usr/local/apache2.4/conf/extra/httpd-vhosts.conf
Add the following information
<Directory/data/wwwroot/111.com/upload>
Php_admin_flag engine off
<filesmatch (. *) \.php (. *) >
Order Allow,deny
Deny from all
</FilesMatch>
</Directory>
Reload
/usr/local/apache2.4/bin/apachectl-t
/usr/local/apache2.4/bin/apachectl Graceful
Test
mkdir upload//Create directory
LS//view file
CP 123.php upload///copy 123.php to upload directory
Curl-x127.0.0.1:80 ' Http://111.com/upload/123.php-I
11.29 Limit User_agent
<lfmodule mod_rewrite.c>
Rewriteengine on
Rewritecond%{http_user_agent}. *curl.*[nc,or]
Rewritecond%{http_user_agent}. *baidu.com.*[nc]
Rewritecond. *-[F]//f,forbidden Forbidden
<lfModule>
Reload
/usr/local/apache2.4/bin/apachectl-t
/usr/local/apache2.4/bin/apachectl Graceful
Test
Curl-x127.0.0.1:80 ' Http://111.com/upload/123.php-I
Curl-a "Aminglinux aminglinux"-X127.0.0.1:80 ' http://111.com/123.php '// -A, specify user_agent;
-I view status code;-e referer;
11.30/11.31 PHP Related Configuration
/usr/local/php/bin/php-i | Grep-i "Loaded configuration file"
Open_basedir Security Options
Php_admin_value open_basedir "/data/wwwroot/111.com:/tmp/"//Restrict a website to access the directory of this site, not to other site directories
Vim/usr/local/php7/etc/php.ini
Open_basedir =/data/wwwroot/1111.com:/tmp//if changed to 1111.com
/usr/local/apache2.4/bin/apachectl Graceful
Curl-a "A" -x127.0.0.1:80 http://111.com/2.php-I//500 error
Cat/tmp/php_errors.log//Log prompt is not in the allowed directory
Extended
Apache Open Compression http://ask.apelearn.com/question/5528
apache2.2 to 2.4 configuration file changes http://ask.apelearn.com/question/7292
Apache Options Parameter http://ask.apelearn.com/question/1051
Apache prohibits trace or track from preventing XSS http://ask.apelearn.com/question/1045
Apache configuration HTTPS support SSL http://ask.apelearn.com/question/1029
Linux Learning Note April 18 task