Linux -安装PHP5

PHP官网www.php.net 当前主流版本为5.6/7.1yum install -y libxml2-develyum install -y openssl-develyum install -y bzip2-develyum install -y libjpeg-develyum install -y libpng-...

PHP官网www.php.net 当前主流版本为5.6/7.1

yum install -y libxml2-devel
yum install -y openssl-devel
yum install -y bzip2-devel
yum install -y libjpeg-devel
yum install -y libpng-devel
yum install -y freetype-devel
yum install -y libmcrypt (安装之前,需要安装epel-release 扩展源)

重新编译:
删除已经安装好的/usr/local/php目录,到源码包目录下make clean.

安装过程:
cd /usr/local/src/

wget http://cn2.php.net/distributions/php-5.6.30.tar.gz

tar zxf php-5.6.30.tar.gz

cd php-5.6.30

./configure --prefix=/usr/local/php --with-apxs2=/usr/local/apache2.4/bin/apxs --with-config-file-path=/usr/local/php/etc --with-mysql=/usr/local/mysql --with-pdo-mysql=/usr/local/mysql --with-mysqli=/usr/local/mysql/bin/mysql_config --with-libxml-dir --with-gd --with-jpeg-dir --with-png-dir --with-freetype-dir --with-iconv-dir --with-zlib-dir --with-bz2 --with-openssl --with-mcrypt --enable-soap --enable-gd-native-ttf --enable-mbstring --enable-sockets --enable-exif

注释:
./config 是配置各种参数,生成Makefile
make 是编译
make install是安装
--with-apxs2=/usr/local/apache/bin/apxs #

--with-mysql=/usr/local/mysql #指定mysql路径
--with-pdo-mysql=/usr/local/mysql
--with-mysqli=/usr/local/mysql/bin/mysql_config
三种不同的mysql库,
可 echo $? 查看是否安装正确,安装时,遇到错误,会直接停止

这种提示,已经config 完成了

make && make install

cp php.ini-production /usr/local/php/etc/php.ini #将参考文件复制过去 生产环境中用的production,测试使用development,不同在于,一个适合在开发环境,一个在生产

/usr/local/php/bin/php -i | less 可以查看php配置信息

本文标题为:Linux -安装PHP5

基础教程推荐