Home  >  Article  >  php教程  >  配置apache以支持php 在apache主配置文件httpd.conf中Include自

配置apache以支持php 在apache主配置文件httpd.conf中Include自

WBOY
WBOYOriginal
2016-06-06 19:58:551263browse

在apache的主配置文件/conf/http.conf 最下面添加 Include D:\workspace_php\apache-php.conf #文件路径可以任意 在D:\workspace_php文件下创建 apache-php.conf文件 它的具体内容为 ## PHP-Module setup#LoadFile D:/xampp/php/php5ts.dllLoadModule php5_m

在apache的主配置文件/conf/http.conf

最下面添加

Include "D:\workspace_php\apache-php.conf"

#文件路径可以任意

在D:\workspace_php文件下创建

apache-php.conf文件

它的具体内容为

#
# PHP-Module setup
#
LoadFile "D:/xampp/php/php5ts.dll"
LoadModule php5_module "D:/xampp/php/php5apache2_2.dll"

<filesmatch>
    SetHandler application/x-httpd-php
</filesmatch>
<filesmatch>
    SetHandler application/x-httpd-php-source
</filesmatch>

#
# PHP-CGI setup
#
#<filesmatch>
#    SetHandler application/x-httpd-php-cgi
#</filesmatch>
#<ifmodule actions_module>
#    Action application/x-httpd-php-cgi "/php-cgi/php-cgi.exe"
#</ifmodule>


<ifmodule php5_module>
    PHPINIDir "D:/xampp/php"
</ifmodule>

<ifmodule mime_module>
    AddType text/html .php .phps
</ifmodule>

ScriptAlias /php-cgi/ "D:/xampp/php/"
<directory>
    AllowOverride None
    Options None
    Require all denied
    <files>
          Require all granted
    </files>
</directory>

<directory>
    <filesmatch>
        SetHandler cgi-script
    </filesmatch>
    <filesmatch>
        SetHandler None
    </filesmatch>
</directory>


其中php所在的目录请根据自己的情况进行修改。

你可能已经注意到我用的是xampp下php。

本文也是借鉴了xampp的配置思路,即在apache主配置文件中多使用Include指令来添加自定义的配置文件,

尽可能减少对主配置文件的修改,使配置过程更加模块化。

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn