#!/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
|
#!/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
|
若是在安裝memcached及redis時memcached安裝不成功,可參考如下方法安裝memcachedphp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
|
#要安裝 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
|
參考一下方法安裝redishtml
1
2
3
4
|
/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
|
1
2
3
4
5
6
7
8
9
|
; 設置用戶和用戶組,默認都是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
|
保存配置文件後,檢驗配置是否正確的方法爲:java
/usr/local/php-7.0.7/sbin/php-fpm -t
若是出現諸如 test is successful
字樣,說明配置沒有問題。mysql
/usr/local/php-7.0.7/sbin/php-fpm
相關依賴參考:nginx
http://www.cnblogs.com/52fhy/p/5797981.htmlgit
各類擴展在php7上的分支參考:github
https://github.com/gophp7/gophp7-ext/wiki/extensions-catalogredis