編譯php7後,如何讓apache支援php7

來源:互聯網
上載者:User
我編譯php7的時候沒有加上 -with-apxs2 這個參數,編譯完後探索服務器不能解析php,請問如何在不重新編譯php7的情況下,讓apache支援php7?是為apache添加php的模組嗎?謝謝

回複內容:

我編譯php7的時候沒有加上 -with-apxs2 這個參數,編譯完後探索服務器不能解析php,請問如何在不重新編譯php7的情況下,讓apache支援php7?是為apache添加php的模組嗎?謝謝

使用FastCGI運行php

  • 開啟模組

    LoadModule proxy_module modules/mod_proxy.soLoadModule proxy_fcgi_module modules/mod_proxy_fcgi.so
  • 配置虛擬機器主機支援使用fcgi

        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        Options none    AllowOverride none    Require all granted  
  • 讓httpd支援解析php頁面

vim httpd.conf

1 添加如下二行

AddType application/x-httpd-php  .php  AddType application/x-httpd-php-source  .phps

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

DirectoryIndex  index.php  index.html

題外話

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

  • 聯繫我們

    該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

    如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.