httpd中使用php模块解析php网页

在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
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值