时间:2021-07-01 10:21:17 帮助过:39人阅读
一、下载
下载地址:http://cn2.php.com/distributions/php-5.6.8.tar.gz
二、安装
tar xzvf php-5.6.8.tar.gz
cd php-5.6.8
PHP编译参数:
#!/bin/sh
./configure \
--prefix=/usr/local/php \
--with-apxs2=/usr/local/apache2/bin/apxs \
--with-mysql=/usr/local/mysql \
--with-pdo-mysql=/usr/local/mysql \
--with-zlib \
--with-gd \
--with-freetype-dir \
--with-png-dir \
--with-jpeg-dir \
--with-mcrypt \
--enable-mbstring \
--enable-fpm \
--disable-debug
make && make install
三、配置
cp php.ini-development /usr/local/php/lib/php.ini
cd /usr/local/php/etc/
cp php-fpm.conf.default php-fpm.conf
sed -i "s/nobody/apache/g" php-fpm.conf
ln -s /usr/local/php/sbin/php-fpm /usr/sbin/
注:配合nginx使用的,如果是apache可不用配置;
四、校验
在apache web程序目录下增加一个info.php文件,内容如下:
phpinfo();
?>
打开浏览器,在地址栏输入:http://ip/info.php ,如果能正常显示出PHP相应信息即可;
编译PHP出错解决办法:
configure: error: xml2-config not found. Please check your libxml2 installation.
yum -y install libxml2 libxml2-devel
------------------------------------
configure: error: jpeglib.h not found.
yum -y install libjpeg libjpeg-devel
------------------------------------
configure: error: png.h not found.
yum -y install libpng libpng-devel
------------------------------------
configure: error: freetype-config not found.
yum -y install freetype freetype-devel
------------------------------------
configure: error: mcrypt.h not found. Please reinstall libmcrypt.
yum -y install libmcrypt-devel