PHP7 Installation Scripts
#!/bin/bash
wget http:
//cn2.php.net/distributions/php-7.0.7.tar.bz2
tar jxvf php-
7.0
.
7
.tar.bz2
cd php-
7.0
.
7
mkdir -p /usr/local/php-
7.0
.
7
/etc/
./configure --prefix=/usr/local/php-
7.0
.
7 --with-config-file-scan-dir=/usr/local/php-
7.0
.
7
/etc/ --enable-inline-optimization --enable-opcache --enable-session --enable-fpm --with-mysql=mysqlnd --with-mysqli=mysqlnd --with-pdo-mysql=mysqlnd --with-pdo-sqlite --with-sqlite3 --with-gettext --enable-mbregex --enable-mbstring --enable-xml --with-iconv --with-mcrypt --with-mhash --with-openssl --enable-bcmath --enable-soap --with-xmlrpc --with-libxml-dir --enable-pcntl --enable-shmop --enable-sysvmsg --enable-sysvsem --enable-sysvshm --enable-sockets --with-curl --with-curlwrappers --with-zlib --enable-zip --with-bz2 --with-gd --enable-gd-
native
-ttf --with-jpeg-dir --with-png-dir --with-freetype-dir --with-iconv-dir --with-readline --with-fpm-user=www --with-fpm-group=www
make && make install #注意:在make的时候报undefined reference to `libiconv_open’的问题的解决方案
vim Makefile
## 找到 EXTRA_LIBS = 这行,在最后加上 -liconv
make && make install
cp php.ini* /usr/local/php-
7.0
.
7
/etc/
cd /usr/local/php-
7.0
.
7
/etc/
cp php.ini-development php.ini
cp php-fpm.conf.
default
php-fpm.conf
cp php-fpm.d/www.conf.
default php-fpm.d/www.conf
# 其他配置
sed -i s/
‘variables_order = "GPCS"‘
/
‘variables_order = "EGPCS"‘
/g /usr/local/php-
7.0
.
7
/etc/php.ini
echo
‘date.timezone = PRC‘ >> /usr/local/php-
7.0
.
7
/etc/php.ini
echo
‘extension_dir = "/usr/local/php-7.0.7/lib/php/extensions/no-debug-non-zts-20151012/"‘ >> /usr/local/php-
7.0
.
7
/etc/php.ini
echo
"/usr/local/php-7.0.7/sbin/php-fpm" >> /etc/rc.local
echo -e
‘\nexport PATH=/usr/local/php/bin:/usr/local/php/sbin:$PATH\n‘ >> /etc/profile && source /etc/profile
|
PHP7 Cache Extension Installation script
#!/bin/bash
function install_status(){
if [ $? -eq
0 ];then
echo -e
"\033[32m$1 successful!\033[0m"
else
echo -e
"\033[31m$1 failed,please check it!\033[0m"
fi
}
function add_so_to_ini(){
EXTENSION=$
1
cp -f /usr/local/php-${PHP_VERSION}/etc/php.ini /usr/local/php-${PHP_VERSION}/etc/php.ini.bak && sed
"/extension=${EXTENSION}.so/d" /usr/local/php-${PHP_VERSION}/etc/php.ini.bak > /usr/local/php-${PHP_VERSION}/etc/php.ini
echo
"extension=${EXTENSION}.so" >> /usr/local/php-${PHP_VERSION}/etc/php.ini
}
PHP_VERSION=
7.0
.
7
#
5.6
.
28
#
7.0
.
7
echo ${PHP_VERSION}
#memcached
unzip -o php-memcached-php7.zip
cd php-memcached-php7
/usr/local/php-
7.0
.
7
/bin/phpize
./configure --enable-memcached --with-php-config=/usr/local/php-${PHP_VERSION}/bin/php-config --with-libmemcached-dir=/usr/local/libmemcached --disable-memcached-sasl
install_status
‘configure_memcached.so‘
make && make install
install_status
‘install_memcached.so‘
add_so_to_ini memcached
#memcache
unzip -o pecl-memcache-NON_BLOCKING_IO_php7.zip
cd pecl-memcache-NON_BLOCKING_IO_php7
/usr/local/php-
7.0
.
7
/bin/phpize
./configure --with-php-config=/usr/local/php-${PHP_VERSION}/bin/php-config --enable-memcache --with-zlib-dir
install_status
‘configure_memcache.so‘
make && make install
install_status
‘install_memcache.so‘
add_so_to_ini memcache
#redis
/usr/local/php-${PHP_VERSION}/bin/pecl install redis
install_status
‘install_redis.so‘
add_so_to_ini redis
|
If memcached installation is unsuccessful when installing memcached and Redis, refer to the following methods to install the memcached
Installing memcached
1234567891011121314151617 |
#要安装 memcached,需要先安装依赖库 libmemcached
wget https:
//launchpad
.net
/libmemcached/1
.0
/1
.0.18/+download
/libmemcached-1
.0.18.
tar
.gz
tar -zxf libmemcached-1.0.18.
tar
.gz
cd libmemcached-1.0.18/
.
/configure
make &&
make install
#安装好依赖库之后,我们来安装 memcached :
mkdir -p
/usr/local/php-7
.0.7
/ext
git clone -b php7 https:
//github
.com
/php-memcached-dev/php-memcached
.git
/usr/local/php-7
.0.7
/ext/memcached
cd /usr/local/php-7
.0.7
/ext/memcached
/usr/local/php-7
.0.7
/bin/phpize
.
/configure --
enable
-memcached --with-php-config=
/usr/local/php-7
.0.7
/bin/php-config
--disable-memcached-sasl
make test
make &&
make install
vim
/usr/local/php-7
.0.7
/etc/php
.ini
[Memcached]
extension=memcached.so
|
Refer to the method to install Redis
Installing Redis
1234 |
/usr/local/php-7 .0.7 /bin/pecl install redis-3.1.0 vi /usr/local/php-7 .0.7 /etc/php .ini [Redis] extension=redis.so |
configuration www.conf (under PHP-FPM.D directory)
123456789 |
; 设置用户和用户组,默认都是nobody user = www group = www ; 设置PHP监听 ; 下面是默认值,不建议使用。可以默认值 ; listen = 127.0.0.1:9000 ; 根据nginx.conf中的配置fastcgi_pass unix: /tmp/php7-cgi .sock; listen = /tmp/php7-cgi .sock |
After you save the configuration file, verify that the configuration is correct by:
/usr/local/php-7.0.7/sbin/php-fpm -t
If such test is successful
words appear, there is no problem with the configuration.
Start PHP-FPM
/usr/local/php-7.0.7/sbin/php-fpm
Dependent Dependency Reference:
Http://www.cnblogs.com/52fhy/p/5797981.html
A variety of branching references on PHP7:
Https://github.com/gophp7/gophp7-ext/wiki/extensions-catalog
PAPI-PHP7 Installation