Home > Article > Backend Development > How to connect between php and apache
Environment check before connection:
php -v PHP 5.6.30 (cli) (built: Oct 22 2018 21:56:47) Copyright (c) 1997-2016 The PHP Group Zend Engine v2.6.0, Copyright (c) 1998-2016 Zend Technologies
service apache -v Server version: Apache/2.4.37 (Unix) Server built: Oct 26 2018 22:18:18
service php-fpm status php-fpm (pid 24166) is running...
Start configuration: (mainly modify the httpd.conf file)
Load these two modules in httpd.conf
LoadModule proxy_module modules/mod_proxy.so<br>LoadModule proxy_fcgi_module modules/mod_proxy_fcgi.so
When receiving a php page request, leave it to the php engine for interpretation instead of downloading the page
AddType application/x-httpd-php .php<br>AddType application/x-httpd-php-source .phps
# Change the default index page of the directory to index.php
DirectoryIndex index.php index.html
# If php-fpm uses TCP socket, then add at the end of httpd.conf:
<FilesMatch \.php$> SetHandler "proxy:fcgi://127.0.0.1:9000" </FilesMatch>
Recommended tutorial: PHP video tutorial
The above is the detailed content of How to connect between php and apache. For more information, please follow other related articles on the PHP Chinese website!