本文操作环境:linux5.9.8系统、php5.4.45版,DELL G3电脑
php5.4.45安装教程
编译安装php5.4.45
PHP下载地址 http://www.php.net/releases/
HTTPD下载地址 http://mirrors.hust.edu.cn/apache/
由于webtatic不对php5.4版本提供支持服务,所以需要手动编译安装
https://webtatic.com/packages/php54/
这其中有两种情况:
yum 安装 httpd,编译安装php5.4.45
a. yum install httpd httpd-devel
b. tar zxvf php-5.4.45.tar.gz
cd php-5.4.45
注意:编译安装PHP前,必须确保原来yum安装的php5.3已经被移出,否则不会生成libphp5.so文件。
./configure --with-apxs2=/usr/sbin/apxs --with-mysql
make && make install
cp php.ini-development /usr/local/lib/php.ini
sed -i 's%;date.timezone =%date.timezone = Asia/Shanghai%' /usr/local/lib/php.ini
验证 /etc/httpd/conf/httpd.conf文件是否已经加载了libphp5.so模块
grep "libphp5.so" /etc/httpd/conf/httpd.conf
添加apache 解析php文件
sed '/ .gz .tgz/a\AddType application/x-httpd-php .php' /etc/httpd/conf/httpd.conf
编译安装 httpd2.2 php5.4.45
a. tar zxvf httpd-2.2.31.tar.gz
cd httpd-2.2.31
ls
./configure --enable-so
make && make install
/usr/local/apache2/bin/apachectl start
lsof -i:80
/usr/local/apache2/bin/apachectl stop
lsof -i:80
b. cd ../
cd php-5.4.45
./configure --with-apxs2=/usr/local/apache2/bin/apxs --with-mysql
make && make install
cp php.ini-development /usr/local/lib/php.ini
c. sed -i 's%;date.timezone =%date.timezone = Asia/Shanghai%' /usr/local/lib/php.ini
验证 /usr/local/apache2/conf/httpd.conf文件是否已经加载了libphp5.so模块
grep "libphp5.so" /usr/local/apache2/conf/httpd.conf
添加apache 解析php文件
sed '/ .gz .tgz/a\AddType application/x-httpd-php .php' /usr/local/apache2/conf/httpd.conf
d. 验证
/usr/local/apache2/bin/apachectl start
echo "<?php phpinfo(); ?>" > index.php
查看是否能正常显示php的配置。