支付PHP部署

支付PHP部署

由于支付业务的开发早期又老旧,但业务非常稳定和健壮虽然使用的PHP是5版本

运维必须根据实际业务的环境来提供支持,而不能随心所欲;比如这个支付环境的PHP就需要编译安装5版本

由于节点比较多,生成批处理(脚本)更快速安全一致,如下

#!/bin/bash
# Author: royoy
# Date: 0518/2018
# Desc: PHP5 installation for payment env

yum install gcc gcc-c++ autoconf libjpeg libjpeg-devel libpng libpng-devel freetype freetype-devel libpng libpng-devel libxml2 libxml2-devel zlib zlib-devel glibc glibc-devel glib2 glib2-devel bzip2 bzip2-develncurses ncurses-deve curl curl-devel openssl openssl-devel gdbm-devel db4-devel libXpm-devel libX11-devel gd-devel pcre pcre-devel libmcrypt-devel wget -y || {
echo 'network is unavailable'
exit
}

wget http://mirrors.sohu.com/php/php-5.6.2.tar.gz

tar xf php-5.6.2.tar.gz
cd php-5.6.2

[ -d /usr/local/php56 ] && {
echo '/usr/local/php56 already exists'
exit
}

./configure --prefix=/usr/local/php56 \
--with-config-file-path=/usr/local/php56/etc \
--enable-fpm --enable-pcntl --enable-mysqlnd --enable-opcache --enable-sockets --enable-sysvmsg --enable-sysvsem \
--enable-sysvshm --enable-shmop --enable-zip --enable-ftp --enable-soap --enable-xml --enable-mbstring \
--disable-rpath --disable-debug --disable-fileinfo --with-pcre-regex --with-iconv --with-zlib --with-mcrypt --with-gd --with-openssl \
--with-mhash --with-xmlrpc --with-curl --with-imap-ssl --with-mysql=mysqlnd --with-mysqli=mysqlnd --with-pdo-mysql=mysqlnd \
--with-iconv-dir=/usr/local --with-freetype-dir --with-jpeg-dir --with-png-dir --with-zlib  --enable-xml --disable-rpath --enable-discard-path \
--enable-safe-mode --enable-bcmath --enable-shmop --enable-sysvsem --enable-inline-optimization  --enable-mbregex --enable-fastcgi \
--enable-force-cgi-redirect --enable-mbstring --with-mcrypt --with-gd --enable-gd-native-ttf --with-openssl --with-mhash --enable-pcntl \
--enable-sockets --with-ldap --with-ldap-sasl --with-xmlrpc 

sed -i '/EXTRA_LIBS = -lcrypt/s/$/& -liconv/' Makefile &&  make && make install

cp php.ini-production /usr/local/php56/etc/php.ini
cp /usr/local/php56/etc/php-fpm.conf.default /usr/local/php56/etc/php-fpm.conf
cp sapi/fpm/init.d.php-fpm /etc/init.d/php-fpm
chmod +x /etc/init.d/php-fpm

sed -i.bak 's/9000/9001/' /usr/local/php56/etc/php-fpm.conf
sed -i '/user =/s/nobody/www/'  /usr/local/php56/etc/php-fpm.conf
sed -i '/group =/s/nobody/www/'  /usr/local/php56/etc/php-fpm.conf
sed -i '/pm =/s/dynamic/static/'  /usr/local/php56/etc/php-fpm.conf
sed -i '/pm.max_children =/s/5/128/' /usr/local/php56/etc/php-fpm.conf
sed -i '/short_open_tag =/s/Off/On/' /usr/local/php56/etc/php.ini