PAPI-PHP7安装

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了PAPI-PHP7安装相关的知识,希望对你有一定的参考价值。

PHP7安装脚本
#!/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缓存扩展安装脚本
#!/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安装不成功,可参考以下方法安装memcached

安装Memcached
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

参考一下方法安装redis

安装Redis
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

 

 

配置www.conf(在php-fpm.d目录下)
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

 

保存配置文件后,检验配置是否正确的方法为:

/usr/local/php-7.0.7/sbin/php-fpm -t

如果出现诸如 test is successful 字样,说明配置没有问题。

启动php-fpm

/usr/local/php-7.0.7/sbin/php-fpm 

相关依赖参考:

http://www.cnblogs.com/52fhy/p/5797981.html

 

各种扩展在php7上的分支参考:

https://github.com/gophp7/gophp7-ext/wiki/extensions-catalog

 



以上是关于PAPI-PHP7安装的主要内容,如果未能解决你的问题,请参考以下文章

VSCode自定义代码片段7——CSS动画

VSCode自定义代码片段7——CSS动画

ES7-Es8 js代码片段

centos 7安装gitlab及使用

版本管理 GitLab 的安装及管理 (CentOS 7)

以下代码片段的时间复杂度是多少?