linux伺服器PHP升級到7

operl552發表於2018-09-10

PHP安裝

本文以php7.0.30為例,下載地址:http://cn2.php.net/get/php-7.0.30.tar.gz/from/this/mirror


tar -zxvf php-7.0.30.tar.gz


cd php-7.0.30


安裝依賴包,有安裝就不需要
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

編譯安裝PHP

./configure  --prefix=/alidata/server/php-7.0.30 --with-openssl --with-config-file-path=/alidata/server/php-7.0.30/etc --with-mysqli --with-pdo-mysql --with-gd --with-iconv=/usr/local/libiconv --with-zlib --enable-zip --enable-inline-optimization --enable-xml --enable-bcmath --enable-shmop --enable-sysvsem --enable-mbregex --enable-mbstring --enable-ftp --enable-gd-native-ttf --enable-pcntl --enable-sockets --with-xmlrpc --enable-soap --without-pear --with-gettext --enable-session --with-curl --with-jpeg-dir --with-freetype-dir --enable-opcache --enable-fpm --with-fpm-user=nginx --with-fpm-group=nginx --without-gdbm --with-pcre-regex --with-png-dir --enable-fileinfo

make && make install
軟連結
ln -s /alidata/service/php-7.0.30 /alidata/service/php

配置php-fpm 

cp php.ini-production /alidata/service/php/etc/php.ini
cp /alidata/service/php/etc/php-fpm.conf.default /alidata/service/php/etc/php-fpm.conf
cp /alidata/service/php/etc/php-fpm.d/www.conf.default /alidata/service/php/etc/php-fpm.d/www.conf
cp sapi/fpm/init.d.php-fpm /etc/init.d/php-fpm
chmod +x /etc/init.d/php-fpm

啟動php-fpm

/etc/init.d/php-fpm start

PHP擴充套件安裝

以 memcache  為例

wget https://github.com/websupport-sk/pecl-memcache/archive/php7.zip

unzip pecl-memcache-php7.zip
cd pecl-memcache-php7
/alidata/service/php/bin/phpize
./configure --with-php-config=/usr/local/php/bin/php-config
make && make install

修改 /alidata/service/php/etc/php.ini 

extension_dir = "/alidata/server/php-7.0.30/lib/php/extensions/no-debug-non-zts-20151012/"
.....
extension=memcache.so


相關文章