han8809 发表于 2018-12-12 09:10:03

Linux学习总结(三十二)lamp之php安装

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

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
  下面开始漫长的排错过程
http://i2.运维网.com/images/blog/201804/12/2faaf79eef0cdfe87c1390a8b7583721.jpg
yum provides xml2-config
yum install -y libxml2-devel
http://i2.运维网.com/images/blog/201804/12/33b9dc8075831d7d0e1f965fb881bde2.jpg
yum list |grep -i openssl
yum install -y openssl openssl-devel
http://i2.运维网.com/images/blog/201804/12/7b529b568564b960080992126f26da66.jpg
yum install -y bzip2-devel
http://i2.运维网.com/images/blog/201804/12/8bb475b2301d6cf29e611221300b9eab.jpg
yum install -y libjpeg-devel
http://i2.运维网.com/images/blog/201804/12/ebc8dab0a1ecb93aff806869717b9463.jpg
yum install -y libpng-devel
http://i2.运维网.com/images/blog/201804/12/50e7bf8195799700dd68ac13e8924af3.jpg
yum install -y freetype-devel
http://i2.运维网.com/images/blog/201804/12/dc5748d78f145b1a7618bd9a982bb9fd.jpg
yum install -y epel-release
yum install -y libmcrypt-devel
继续./configure ...
make && make install
cp php.ini-production/usr/local/php/etc/php.ini   //拷贝配置文件
安装完成后我们找下看是否生成了我们要的php模块libphp5.so
ls /usr/local/apache2.4/modules/libphp5.so 可以找到
du -sh !$ 查看下它的大小 ,发现36M左右
至此说明我们php安装成功了
php7 安装
方法跟php5相同,就是./configure 时改下安装路径,和配置文件路径

cd /usr/local/src/
wget http://cn2.php.net/distributions/php-7.1.6.tar.bz2
tar zxf php-7.1.6.tar.bz2
cd php-7.1.6
./configure --prefix=/usr/local/php7 --with-apxs2=/usr/local/apache2.4/bin/apxs --with-config-file-path=/usr/local/php7/etc--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
  ls /usr/local/apache2.4/modules/libphp*
http://i2.运维网.com/images/blog/201804/12/e86c4ee274d95f0e1e5047dbb5cec411.jpg
cp php.ini-production/usr/local/php7/etc/php.ini
最后我们把要下载的包总结下:

yum install -y libxml2-devel
yum install -y openssl 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 epel-release
yum install -y libmcrypt-devel


页: [1]
查看完整版本: Linux学习总结(三十二)lamp之php安装