Home > Backend Development > PHP Tutorial > After compiling php7, how to make apache support php7

After compiling php7, how to make apache support php7

WBOY
Release: 2016-10-11 14:23:30
Original
1625 people have browsed it

我编译php7的时候没有加上 -with-apxs2 这个参数,编译完后发现服务器不能解析php,请问如何在不重新编译php7的情况下,让apache支持php7?是为apache添加php的模块吗?谢谢

回复内容:

我编译php7的时候没有加上 -with-apxs2 这个参数,编译完后发现服务器不能解析php,请问如何在不重新编译php7的情况下,让apache支持php7?是为apache添加php的模块吗?谢谢

使用FastCGI运行php

  • 开启模块

    <code>LoadModule proxy_module modules/mod_proxy.so
    LoadModule proxy_fcgi_module modules/mod_proxy_fcgi.so
    </code>
    Copy after login
  • 配置虚拟主机支持使用fcgi

    <code><VirtualHost *:80>
        DocumentRoot "/www/www.a.com"
        ServerName /www/www.a.com
        ServerAlias www.a.com
        ProxyRequests Off
        ProxyPassMatch ^/(.*\.php)$ fcgi://127.0.0.1:9000/www/www.a.com/$1  
      <Directory "/www/www.a.com">
        Options none
        AllowOverride none
        Require all granted
      </Directory>
    </VirtualHost>
    </code>
    Copy after login
  • 让httpd支持解析php页面

vim httpd.conf

1 添加如下二行

<code>AddType application/x-httpd-php  .php  
AddType application/x-httpd-php-source  .phps
</code>
Copy after login

2 定位至DirectoryIndex index.html
修改为:

<code>DirectoryIndex  index.php  index.html
</code>
Copy after login

题外话

感觉httpd就是麻烦,还是nginx好用。题主可以考虑使用nginx。

如果你想使用Apache的mod_php(libphp7.so)运行PHP,那只能指定--with-apxs2=/path/to/httpd/2.4/bin/apxs重新编译.
不想重新编译,那你只能用Apache提供的其他方式运行PHP,比如:
1.使用Apache的mod_fcgid配合php-cgi运行(类似IIS + PHP-CGI).
2.使用Apache的mod_proxy_fcgi配合php-fpm运行(类似Nginx + PHP-FPM).

Related labels:
php
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template