在httpd配置文件中添加php解析
修改apache的配置文件,让apache可以使用php进行解析
httpd的配置文件在/usr/local/httpd/conf/httpd.conf路径
在httpd配置文件中修改如下几个配置参数,在httpd.conf配置文件中查找一下关键字符配置
[root@localhost httpd]# vim conf/httpd.conf
~
这里安装了两个php模块,需要注释掉一个php模块。因为httpd不能同时加载两个php模块
LoadModule php5_module modules/libphp5.so
#LoadModule php7_module modules/libphp7.so
将ServerName行的注释去掉,这样可以使httpd能够正常启动和访问默认页
# ServerName gives the name and port that the server uses to identify itself.
# This can often be determined automatically, but we recommend you specify
# it explicitly to prevent problems during startup.
#
# If your host doesn't have a registered DNS name, enter its IP address here.
ServerName www.example.com:80
修改默认的目录策略,denied表示拒绝访问网页目录,granted表示允许访问网页目录,防止打开虚拟主机配置会显示网页报错状态码403
# Deny access to the entirety of your server's filesystem. You must
# explicitly permit access to web content directories in other
# <Directory> blocks below.
#
<Directory />
AllowOverride none
Require all granted
</Directory>
网页根目录的配置路径及权限配置,Require all granted这里配置和上面的目录访问有关联的作用,表示网页目录是否能够有权限访问
DocumentRoot "/usr/local/httpd/htdocs"
<Directory "/usr/local/httpd/htdocs">
Options Indexes FollowSymLinks
# AllowOverride controls what directives may be placed in .htaccess files.
# It can be "All", "None", or any combination of the keywords:
# AllowOverride FileInfo AuthConfig Lim