php libphp5.so lamp

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 

下面開始漫長的排錯過程
技術分享圖片
yum provides xml2-config
yum install -y libxml2-devel
技術分享圖片
yum list |grep -i openssl
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
繼續./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*

技術分享圖片
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

Linux學習總結(三十二)lamp之php安裝