php和apache结合

apache:https://blog.51cto.com/popli3/2357295

PHP:https://blog.51cto.com/popli3/2358720



  1. 在以上两篇环境完成后,编辑vi /usr/local/apache2.4/conf/httpd.conf 搜索Require all denied,把denied改成granted

ServerName www.example.com:80


#

# 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>


2. 搜索AddType,添加一行php的规则

# If the AddEncoding directives above are commented-out, then you

    # probably should define those extensions to indicate media types:

    #

    AddType application/x-compress .Z

    AddType application/x-httpd-php .php

    AddType application/x-gzip .gz .tgz

3. 搜索index.html 添加php解析

# DirectoryIndex: sets the file that Apache will serve if a directory

# is requested.

#

<IfModule dir_module>

    DirectoryIndex index.html index.php

</IfModule>

4. 重启apache

[root@minion-1 ~]# /usr/local/apache2.4/bin/apachectl graceful

5. 写个test.php页面,用http://ip/test.php访问是否有返回

[root@minion-1 ~]# vi /usr/local/apache2.4/htdocs/test.php

<?php

phpinfo();




猜你喜欢

转载自blog.51cto.com/popli3/2360415
今日推荐