這篇文章主要介紹了關於PHP的安裝以及與apache整合的介紹,有著一定的參考價值,現在分享給大家,有需要的朋友可以參考一下
apache 2.4.29
php 5.4.45
# tar -zxvf php-5.4.45.tar.gz # cd php-5.4.45 # ./configure --prefix=/usr/local/php --with-apxs2=/usr/local/apache2/bin/apxs --with-libxml2=/usr/include/libxml2 # make # make install
/configure --prefix=/usr/local/php --with-apxs2=/usr/local/apache2/bin/apxs - -with-libxml2=/usr/include/libxml2
錯誤log:
Sorry, I cannot run apxs. Possible reasons follow: 1. Perl is not installed 2. apxs was not found. Try to pass the path using --with-apxs2=/path/to/apxs 3. Apache was not built using --enable-so (the apxs usage page is displayed) The output of /usr/local/apache2/bin/apxs follows: ./configure: /usr/local/apache2/bin/apxs: /replace/with/path/to/perl/interpreter: bad interpreter: No such file or directory configure: error: Aborting
按照提示安裝perl
# perl -v //先查看果然没安装 # yum install -y perl # perl -v //安装成功 This is perl, v5.10.1 (*) built for x86_64-linux-thread-multi Copyright 1987-2009, Larry Wall Perl may be copied only under the terms of either the Artistic License or the GNU General Public License, which may be found in the Perl 5 source kit. Complete documentation for Perl, including FAQ lists, should be found on this system using "man perl" or "perldoc perl". If you have access to the Internet, point your browser at http://www.perl.org/, the Perl Home Page.
再次./configure仍然提示這個錯誤。於是百度。 。 。 。
才知道需要先按照perl再按照apache才行,不安裝perl的情況下安裝apache,apxs就無法運作。
補救辦法:
檢視檔案
# cat /usr/local/apache2/bin/apxs
第一行是#!/replace/with/path/to/perl/interpreter -w
改為:#!/usr/bin /perl -w
再次:
./configure --prefix=/usr/local/php --with-apxs2=/usr/local/apache2/bin/apxs --with-libxml2=/usr/include/libxml2
成功!
如果php安裝正確,apache的設定檔會自動被備份(httpd.conf.bak)和修改,修改如下
開啟如下註解,載入php模組。
LoadModule php5_module modules/libphp5.so
如果您想要apache解析php文件,也需要在httpd.conf中加入(#AddOutputFilter INCLUDES .shtmlhtml):
AddType application/x-httpd-php .html AddHandler php5-script .php
<?php phpinfo(); ?>
相關推薦:
android和PHP實作簡單的登入php如何實作隨機數字和字母驗證碼的程式碼以上是PHP的安裝以及與apache整合的介紹的詳細內容。更多資訊請關注PHP中文網其他相關文章!