PHP5及PHP7的安裝
1、官網:www.php.net 當前主流版本5.6/7.1
2?cd /usr/local/src
3?wget http://cn2.php.net/distributions/php-5.6.32.tar.bz2
4?解壓:tar -jxvf php-5.6.32.tar.bz2
5、cd php-5.6.32/
6? 編譯
./configure --prefix=/usr/local/php --with-apxs2=/usr/local/apache/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-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
解決方案:
centos: yum install freetype-devel
debian: apt-get install libfreetype6-dev
遇到錯誤2:configure: error: mcrypt.h not found. Please reinstall libmcrypt.
解決方案:
cenos: yum install libmcrypt libmcrypt-devel
怎麽遇到的錯誤這麽少?
7?echo $? 檢查編譯是否成功
8?make & make install
make clean 一下然後再make,即可。原因未知,可能是某些腳本執行順序的問題?
9?查看/usr/local/php/及/usr/local/php/bin 目錄 : ls /usr/local/php/
它的核心位置:/bin 目錄 ,查看大小 du -sh /usr/local/php/bin/bin/
10、php和apache結合的擴展模塊目錄,就算你刪除php目錄,也沒有關系,因為它們所要的就是libphp5.so這個模塊,apache和php就是用這個文件 /usr/local/apache/modules/libphp5.so
12?cp php.ini-production /usr/local/php/etc/php.ini
這是配制文件所在的路徑
/usr/local/php/bin/php -i |less 查php的一些信息,包括編譯參數,及configuration file的路徑。這個目錄是空的,所以cp,cp完之後再用這條命令查看就有了
二、安裝php7
1?cd /usr/local/src
2、wget http://cn2.php.net/distributions/php-7.1.6.tar.bz2
3?解壓
4?cd php-7.1.6
4?編譯:
./configure --prefix=/usr/local/php7 --with-apxs2=/usr/local/apache/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
6?make & makeinstall
7、查看apache加載了幾個php ,/usr/local/apache/bin/apachectl -M
8、想用哪一個 就要去改配制文件:vim /usr/local/apache/conf/httpd.conf
查找到php5.so 或php7.so 不想用哪一個就註釋掉哪一個
PHP5及PHP7的安裝