一、安装Apache
yum -y install httpd
/etc/init.d/httpd start
文档目录在/var/www/html
二、安装PHP
yum -y install php
修改Apache配置文件,/etc/httpd/conf/httpd.conf
对应位置追加以下内容:
LoadModule php5_module /usr/lib64/httpd/modules/libphp5.so
追加
AddType application/x-httpd-php .php .phtml
AddType application/x-httpd-php-source .phps
DirectoryIndex 追加index.php
重启Apache,/etc/init.d/httpd restart ,会提示
“module php5_module is already loaded, skipping”,无所谓不影响
但如果php页面无法解析,浏览器里显示源码,那就在httpd.conf里追加:
AddType application/x-httpd-php .php
AddType application/x-httpd-php-source .phps
</IfModule>
重启Apache应该就好了