先安装apache
再向/usr/software/上传一个php-5.4.14.tar.gz
yum install libxml2 libxml2-devel curl curl-devel libjpeg libjpeg-devel libpng libpng-devel libmcrypt libmcrypt-devel libtool-ltdl-devel
tar zxvf php-5.4.14.tar.gz
cd php-5.4.14
./configure --prefix=/usr/local/php --with-apxs2=/usr/local/apache/bin/apxs (apache安装的目录)
如果出现:
Sorry, I cannot run apxs.
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
修改/usr/local/apache/bin/apxs文件
vi /usr/local/apache/bin/apxs 将第一行
#!/replace/with/path/to/perl/interpreter -w
改为
#!/usr/bin/perl -w
make
make install
cp php.ini-development /usr/local/php/lib/php.ini
ln -s /usr/local/php/bin/php /usr/bin/php
vi /usr/local/php/lib/php.ini
把include_path前面的分号删除,改成include_path = /usr/local/php/lib/php
vi /usr/local/apache/conf/httpd.conf
在最下面加入一行AddHandler application/x-httpd-php .php
重启apache
vi /usr/local/apache/htdocs/test.php
<?php
phpinfo();
?>
用浏览器访问http://localhost/test.php