连接前环境检查:
php -vPHP 5.6.30 (cli) (built: Oct 22 2018 21:56:47)Copyright (c) 1997-2016 The PHP GroupZend Engine v2.6.0, Copyright (c) 1998-2016 Zend Technologies
service apache -vServer version: Apache/2.4.37 (Unix)Server built: Oct 26 2018 22:18:18
service php-fpm statusphp-fpm (pid 241<strong style="color:transparent">来源gao@daima#com搞(%代@#码网</strong>66) is running...
开始配置:(主要修改 httpd.conf 文件)
加载httpd.conf中的这两个模块
LoadModule proxy_module modules/mod_proxy.so
LoadModule proxy_fcgi_module modules/mod_proxy_fcgi.so
接受到php页面请求时,交给php引擎解释,而不是下载页面
AddType application/x-httpd-php .php
AddType application/x-httpd-php-source .phps
# 将目录的默认索引页面改为index.php
DirectoryIndex index.php index.html
# 如果php-fpm使用的是TCP socket,那么在httpd.conf末尾加上:
<FilesMatch \.php$>SetHandler "proxy:fcgi://127.0.0.1:9000"</FilesMatch>
推荐教程:PHP视频教程
以上就是php和apache之间如何连接的详细内容,更多请关注搞代码gaodaima其它相关文章!