Heim  >  Artikel  >  Backend-Entwicklung  >  编译php7后,如何让apache支持php7

编译php7后,如何让apache支持php7

WBOY
WBOYOriginal
2016-10-11 14:23:301555Durchsuche

我编译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>
  • 配置虚拟主机支持使用fcgi

    <code><virtualhost>
        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>
        Options none
        AllowOverride none
        Require all granted
      </directory>
    </virtualhost>
    </code>
  • 让httpd支持解析php页面

vim httpd.conf

1 添加如下二行

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

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

<code>DirectoryIndex  index.php  index.html
</code>

题外话

感觉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).

Stellungnahme:
Der Inhalt dieses Artikels wird freiwillig von Internetnutzern beigesteuert und das Urheberrecht liegt beim ursprünglichen Autor. Diese Website übernimmt keine entsprechende rechtliche Verantwortung. Wenn Sie Inhalte finden, bei denen der Verdacht eines Plagiats oder einer Rechtsverletzung besteht, wenden Sie sich bitte an admin@php.cn