Configure Apache to support PHP in the Apache main configuration file httpd.conf Include custom profile in

Time:2020-6-2

In Apache’s main configuration file / conf/ http.conf

Add at the bottom

Include “D:workspace_phpapache-php.conf”

The file path can be any

In D: workspace_ Create under PHP file

apache- php.conf file

Its specific content is

[html] view plain copy

PHP-Module setup

LoadFile “D:/xampp/php/php5ts.dll”
LoadModule php5_module “D:/xampp/php/php5apache2_2.dll”

<FilesMatch “.php$”>

SetHandler application/x-httpd-php  

</FilesMatch>
<FilesMatch “.phps$”>

SetHandler application/x-httpd-php-source  

</FilesMatch>

PHP-CGI setup

<FilesMatch “.php$”>

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 “D:/xampp/php”>

AllowOverride None  
Options None  
Require all denied  
<Files "php-cgi.exe">  
      Require all granted  
</Files>  

</Directory>

<Directory “D:/xampp/cgi-bin”>

<FilesMatch "\.php$">  
    SetHandler cgi-script  
</FilesMatch>  
<FilesMatch "\.phps$">  
    SetHandler None  
</FilesMatch>  

</Directory>

Please modify the directory where PHP is located according to your own situation.
You may have noticed that I use PHP under xampp.

This paper also uses the configuration idea of xampp for reference, that is, in the main Apache configuration file, the include instruction is often used to add a custom configuration file,

Reduce the modification of the main configuration file as much as possible to make the configuration process more modular.