本文主要和大家分享的是nginx 多版本 php,文中主要教大家安装的步骤希望能帮助到大家。
yum -y install readline-devel libxslt libxslt-devel./configure --prefix=/usr/local/php72 \--exec-prefix=/usr/local/php72 \--with-config-file-path=/usr/local/php72/etc \--enable-fpm \--with-fpm-user=www \--with-fpm-group=www \--enable-inline-optimization \--disable-debug \--disable-rpath \--enable-shared \--enable-soap \--with-libxml-dir \--with-xmlrpc \--with-openssl \--with-mhash \--with-pcre-regex \--with-sqlite3 \--with-zlib \--enable-bcmath \--with-iconv \--with-bz2 \--enable-calendar \--with-curl \--with-cdb \--enable-dom \--enable-exif \--enable-fileinfo \--enable-filter \--with-pcre-dir \--enable-ftp \--with-gd \--with-openssl-dir \--with-jpeg-dir \--with-png-dir \--with-zlib-dir \--with-freetype-dir \--enable-gd-jis-conv \--with-gettext \--with-gmp \--with-mhash \--enable-json \--enable-mbstring \--enable-mbregex \--enable-mbregex-backtrack \--with-libmbfl \--with-onig \--enable-pdo \--with-mysqli=mysqlnd \--with-pdo-mysql=mysqlnd \--with-zlib-dir \--with-pdo-sqlite \--with-readline \--enable-session \--enable-shmop \--enable-simplexml \--enable-sockets \--enable-sysvmsg \--enable-sysvsem \--enable-sysvshm \--enable-wddx \--with-libxml-dir \--with-xsl \--enable-zip \--enable-mysqlnd-compression-support \--with-pear \--enable-opcache
make ZEND_EXTRA_LIBS='-liconv' && make install
cp php.ini-production /usr/local/php72/etc/php.inicp /usr/local/php72/etc/php-fpm.conf.default /usr/local/php72/etc/php-fpm.confcp /usr/local/php72/etc/php-fpm.d/www.conf.default /usr/local/php72/etc/php-fpm.d/www.confcp sapi/fpm/init.d.php-fpm /etc/init.d/php-fpm72cp sapi/fpm/init.d.php-fpm /usr/local/php72/bin/php-fpm72chmod +x /etc/init.d/php-fpm72
mkdir /usr/local/php72/bin/72cp /usr/local/php72/bin/php /usr/local/php72/bin/72/php72cp /usr/local/php72/bin/pecl /usr/local/php72/bin/72/pecl72cp /usr/local/php72/bin/php-cgi /usr/local/php72/bin/72/php-cgi72cp /usr/local/php72/bin/php-config /usr/local/php72/bin/72/php-config72cp /usr/local/php72/bin/phpize /usr/local/php72/bin/72/phpize72
vim /etc/profilePATH=$PATH:/usr/local/php72/bin/72export PATH
source /etc/profile
pecl72 config-set php_ini /usr/local/php72/etc/php.ini # 发现配置不生效
pecl72 install swoole
yum install -y libmemcached-devel libmemcachedpecl72 install memcached输入 libmemcached-dir/usr
pecl72 install event # 全部默认值
pecl72 install mongodb
pecl72 install rdkafka
pecl72 install redis# 会问是否开启压缩, 建议不开启 回车默认值
pecl72 install channel://pecl.php.net/mcrypt-1.0.1 # 回车默认值
# 依赖 libdatrie 库 需要提前安装# 参考# https://github.com/zzjin/php-ext-trie-filter/tree/php7# 注意 phpize ---> phpize72; --with-php-config=/usr/local/php72/bin/php-configphpize72./configure --with-php-config=/usr/local/php72/bin/php-configmake && make install# 修改对应的 php.ini 添加 extension="trie_filter.so"
php72 -m
大概 36 行listen = /tmp/php-cgi72.sock
/etc/init.d/php-fpm72 start
chkconfig --add php-fpm72chkconfig php-fpm72 onchkconfig # 检查一下
location ~ [^/]\.php(/|$){fastcgi_index index.php;fastcgi_pass unix:/tmp/php-cgi72.sock;fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;include fastcgi_params;}
chmod 755 /tmp/php-cgi72.sockchown www:www /tmp/php-cgi72.sock
Atas ialah kandungan terperinci nginx多版本php详解. Untuk maklumat lanjut, sila ikut artikel berkaitan lain di laman web China PHP!