php安装完成后,并不能直接使用,需要进行一些配置


拷贝php配置文件

[root@ly-linux php-5.6.28]# cp php.ini-production /usr/local/php/etc/php.ini


配置apache

[root@ly-linux php-5.6.28]# vim /usr/local/apache2/conf/httpd.conf

<Directory />

Options FollowSymlLinks

AllowOverride None

Order deny,allow

Deny from all // 此行修改 =====> Allow from all

</Directory>

AddType application/x-gzip .gz .tgz

#在下方添加一行

AddType application/x-httpd-php .php

<IfModule dir_module> DirectoryIndex index.html //此行后添加index.htm index.php</IfModule>

找到下方语句

#ServerName www.example.com:80

改成

ServerName localhost:80

保存退出。


检测配置

[root@ly-linux php-5.6.28]# /usr/local/apache2/bin/apachectl -t

Syntax //说明没有问题

[root@ly-linux php-5.6.28]# /usr/local/apache2/bin/apachectl start

[root@ly-linux php-5.6.28]# ps aux |grep httpd

#检测apache是否正常启动


测试php解析

[root@ly-linux php-5.6.28]# vim /usr/local/apache2/htdocs/1.php

<?php echo "php work";?>保存退出,

[root@ly-linux php-5.6.28]# curl localhost/1.phpphp work

只有显示这个才算成功 。如果不流畅,检测iptables规则

[root@ly-linux php-5.6.28]# iptables -nvL

如果有一些规则,执行

[root@ly-linux php-5.6.28]# iptables -F

[root@ly-linux php-5.6.28]# service iptables save