步驟如下: 1、安裝依賴 2、下載PHP源碼包 3、配置參數 4、編譯 註意:我這裡報錯提示“undefined reference to `libiconv_open'”,make 時增加 ZEND_EXTRA_LIBS=’-liconv’ 參數即可,如下 5、安裝 6、完成安裝後需處理 6.1、 ...
步驟如下:
1、安裝依賴
yum install libxml2 libxml2-devel openssl openssl-devel bzip2 bzip2-devel libcurl libcurl-devel libjpeg libjpeg-devel libpng libpng-devel freetype freetype-devel gmp gmp-devel libmcrypt libmcrypt-devel readline readline-devel libxslt libxslt-devel
2、下載PHP源碼包
wget http://cn2.php.net/distributions/php-7.0.27.tar.gz
3、配置參數
./configure --prefix=/alidata/server/php-7.0.27 \ --with-apxs2=/alidata/server/httpd-2.4.10/bin/apxs \ --with-curl \ --with-freetype-dir \ --with-gd \ --with-gettext \ --with-iconv-dir \ --with-kerberos \ --with-libdir=lib64 \ --with-libxml-dir \ --with-mysqli \ --with-openssl \ --with-pcre-regex \ --with-pdo-mysql \ --with-pdo-sqlite \ --with-pear \ --with-png-dir \ --with-xmlrpc \ --with-xsl \ --with-zlib \ --enable-fpm \ --enable-bcmath \ --enable-libxml \ --enable-inline-optimization \ --enable-gd-native-ttf \ --enable-mbregex \ --enable-mbstring \ --enable-opcache \ --enable-pcntl \ --enable-shmop \ --enable-soap \ --enable-sockets \ --enable-sysvsem \ --enable-xml \ --enable-zip
4、編譯
make
註意:我這裡報錯提示“undefined reference to `libiconv_open'”,make 時增加 ZEND_EXTRA_LIBS=’-liconv’ 參數即可,如下
make ZEND_EXTRA_LIBS='-liconv'
5、安裝
make install
6、完成安裝後需處理
6.1、將 alidata/server/php 軟鏈接設置為 alidata/server/php-7.0.27
cd /alidata/www/server rm -rf php ln -s /alidata/server/php-7.0.27 php
6.2、 httpd.conf文件里開啟PHP7模塊
不開啟啟動Apache時會報“/etc/rc.d/init.d/httpd: line 79: 29939 Segmentation fault $HTTPD -k $ARGV”的錯誤
#LoadModule php5_module modules/libphp5.so
LoadModule php7_module modules/libphp7.so
6.4、 重新Apache
systemctl stop httpd
systemctl start httpd