安装PHP5
PHP官网:www.php.net
当前主流版本为5.6/7.1
安装php之前必须先安装好mysql和Apache
下载与解压
cd /usr/local/src/
wget http://cn2.php.net/distributions/php-5.6.30.tar.gz
tar zxvf php-5.6.30.tar.gz
安装文件
cd /usr/local/src/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
编译与安装
make && make install
设置加载文件
cp /usr/local/src/php-5.6.30/php.ini-production /usr/local/php/etc/php.ini
查看配置文件加载目录
/usr/local/php/bin/php -i |less
安装内容的信息注释
--prefix= php的安装路径
--with-apxs2= apache的apxs工具目录
--with-config-file-path= 指定配置文件路径
--with-mysql= 指定MySQL的路径
--with-pdo-mysql=
--with-mysqli=
后面所有--with-都是指定模块
安装告错以及处理
告错1:
错误信息:
configure: error: xml2-config not found. Please check your libxml2 installation.
处理方案:
缺少xml2这个包,搜索并安装它;一般安装的都是库文件,也就是后面带devel的包;
yum list |grep xml2
yum install -y libxml2-devel
告错2:
错误信息:
configure: error: Cannot find OpenSSL's
处理方案:
缺少openssl包,搜索并安装它;一般安装的都是库文件也就是openssl-devel;
yum list |grep openssl
yum install -y openssl-devel
告错3:
错误信息:
configure: error: Please reinstall the BZip2 distribution
处理方案:
缺少bzip2的包,搜索并安装它的库文件;
yum list |grep -i bzip2
yum install -y bzip2-devel
告错4:
错误信息:
configure: error: jpeglib.h not found.
处理方案:
这个缺少的是libjpeg-devel包,但是系统里面没有libjpeg-devel,搜索jpeglib是搜索不出的;
最后匹配出的包为libjpeg-turbo-devel
yum list |grep -i jpeg
yum install -y libjpeg-devel
告错5:
错误信息:
configure: error: png.h not found.
解决方案:
缺少libpng-devel包,搜索错误提示的png查询;
yum list |grep -i png
yum install -y libpng-devel
告错6:
错误信息:
configure: error: freetype-config not found.
解决方案:
缺少freetype-devel,最好先搜索再安装;
yum list |grep -i freetype
yum install -y freetype-devel
告错7:
错误信息:
configure: error: mcrypt.h not found. Please reinstall libmcrypt.
解决方案:
缺少mcrypt,请先安装epel-release再安装mcrypt;
重要事情说三遍:一定要先安装epel-release后再安装libtomcrypt-devel;
重要事情说三遍:一定要先安装epel-release后再安装libtomcrypt-devel;
重要事情说三遍:一定要先安装epel-release后再安装libtomcrypt-devel;
yum install -y epel-release
yum list |grep -i mcry
yum install -y libtomcrypt-devel
如果不成功那么使用yum移除这两个包重新安装
yum erase epel-release.noarch
yum erase libtomcrypt