php路径没有加载图1 :图二禁用php.info的结果php
[root@chy ~]# /usr/local/php/bin/php -i (查看php的路径) [root@chy 111.com]# vim index.php <?php phpinfo (); (在indix.php里面增长phpinfo) 在网页中能够查看到php的路径,可是有加载(如截图1) 那若是没有加载时就须要在源码包中cp一个了,拷贝方式以下:[root@chy 111.com]# cd /usr/local/src/php-5.6.30/ (进入到源码包中) [root@chy php-5.6.30]# cp php.ini-development /usr/local/php/etc/php.ini (cp到/etc下) [root@chy php-5.6.30]# /usr/local/apache2.4/bin/apachectl graceful (这时还须要刷新配置文件) [root@chy php-5.6.30]# vim /usr/local/php/etc/php.ini (在php的配置文件里面作一些操做) disable_functions =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,phpinfo (禁用函数,通常也是须要把phpinfo须要禁用掉,由于若是不由用,php的一些信息就会在网页中显示出来) [root@chy php-5.6.30]# /usr/local/apache2.4/bin/apachectl graceful (加载一下配置文件) (图二是网页访问php.info时被拒绝的结果) [root@chy php-5.6.30]# vim /usr/local/php/etc/php.ini date.timezone =Asia/Chongqing (若是不定义这个会出现报错) ; http://php.net/display-errors display_errors = Of (这个显示错误信息也是须要关闭的,若是不关闭报错的信息会显示在网页的页面上) error_log = /tmp/php_errors.log (定义错误日志的路径) error_reporting = E_ALL (记录日志的权限,生产环境用的是 E_ALL & ~E_NOTICE ) [root@chy php-5.6.30]# /usr/local/apache2.4/bin/apachectl -t Syntax OK [root@chy php-5.6.30]# /usr/local/apache2.4/bin/apachectl graceful (检查配置,并加载一下配置) [root@chy php-5.6.30]# curl -A "a" -x127.0.0.1:80 http://www.111.com/index.php (用curl检测时发现没有任何的显示,这里加-A是由于以前作了user_agent的配置) [root@chy php-5.6.30]# ls -l /tmp/php_errors.log -rw-r--r-- 1 daemon daemon 438 8月 4 08:09 /tmp/php_errors.log [root@chy php-5.6.30]# ps aux |grep httpd root 2448 0.0 0.7 245632 11668 ? Ss 05:05 0:02 /usr/local/apache2.4/bin/httpd -k start daemon 5108 0.0 0.5 534596 9132 ? Sl 08:11 0:00 /usr/local/apache2.4/bin/httpd -k start daemon 5109 0.0 0.5 534596 9132 ? Sl 08:11 0:00 /usr/local/apache2.4/bin/httpd -k start daemon 5110 0.0 0.5 534596 9132 ? Sl 08:11 0:00 /usr/local/apache2.4/bin/httpd -k start root 5199 0.0 0.0 112664 976 pts/0 S+ 08:13 0:00 grep --color=auto httpd (这里须要注意的是若是发现更改了php配置文件后,也设置了错误日志的路径与权限仍是没有记录错误日志,就须要看看错误日志的目录有没有写权限,这个权限是apache的属主daemon)
错误日志的小案例html
[root@chy php-5.6.30]# vim /data/wwwroot/111.com/2.php (写一个2.php) [root@chy php-5.6.30]# curl -A "c" -x127.0.0.1:80 http://www.111.com/2.php -I HTTP/1.0 500 Internal Server Error Date: Fri, 04 Aug 2017 00:22:37 GMT Server: Apache/2.4.27 (Unix) PHP/5.6.30 X-Powered-By: PHP/5.6.30 Connection: close Content-Type: text/html; charset=UTF-8 (状态码为500,为500的缘由是2.php的语法故意写错了) [root@chy php-5.6.30]# !cat cat /tmp/php_errors.log [04-Aug-2017 08:07:05 Asia/chongqing] PHP Warning: phpinfo() has been disabled for security reasons in /data/wwwroot/111.com/index.php on line 2 [04-Aug-2017 08:07:09 Asia/chongqing] PHP Warning: phpinfo() has been disabled for security reasons in /data/wwwroot/111.com/index.php on line 2 [04-Aug-2017 08:09:56 Asia/chongqing] PHP Warning: phpinfo() has been disabled for security reasons in /data/wwwroot/111.com/index.php on line 2 [04-Aug-2017 08:22:37 Asia/chongqing] PHP Parse error: syntax error, unexpected end of file in /data/wwwroot/111.com/2.php on line 4 (查看错误日志)
网站隔离(A,B网站互不影响,当一个网站被黑了,另外一个网站没有影响)open_basedirshell
[root@chy php-5.6.30]# vim /usr/local/php/etc/php.ini open_basedir =/data/wwwroot/111.com/tmp/ (在php.ini下定义的是整个的网站并达不到须要的效果,若是须要实现每一个网站都隔离须要在apache的虚拟配置文件里进行配置) [root@chy php-5.6.30]# vi /usr/local/apache2.4/conf/extra/httpd-vhosts.conf <VirtualHost *:80> DocumentRoot "/data/wwwroot/111.com" ServerName www.111.com ServerAlias www.exaple.com 222.com #<Directory /data/wwwroot/111.com> #<filesMatch 123.php> #AllowOverride AuthConfig #AuthName "111.com user auth" #AuthType Basic #AuthUserFile /data/.htpasswd #require valid-user #</FilesMatch> #</Directory> php_admin_value open_basedir "/data/wwwroot/111.com:/tmp/" (针对不一样的虚拟主机设置open_basedir,php_admin_value open_basedir "/data/wwwroot/111.com:/tmp/"主要配置)