1. 下载php源码安装包
wget -c https://www.php.net/distributions/php-7.0.33.tar.gz && tar xzf php-7.0.33.tar.gz;
2. 安装常用的依赖:
yum -y install gcc gcc-c++ automake autoconf make \
libtool systemd-devel glibc glibc-devel \
mcrypt libmcrypt libmcrypt-devel mhash mhash-devel libxslt libxslt-devel \
libjpeg libjpeg-devel openjpeg-devel libpng libpng-devel \
libcurl libcurl-devel gmp gmp-devel libicu libicu-devel \
freetype freetype-devel libxml2 libxml2-devel zlib zlib-devel \
glib2 glib2-devel bzip2 bzip2-devel curl curl-devel \
readline readline-devel ncurses ncurses-devel \
e2fsprogs e2fsprogs-devel openssl openssl-devel
3. 添加php-fpm的用户,或者用nobody用户
chattr -i /etc/group /etc/gshadow /etc/passwd /etc/shadow
#创建群组并创建一个用户,不允许登陆和不创主目录
groupadd php-fpm && useradd -s /sbin/nologin -g php-fpm -M php-fpm
3. 进入php源码目录,编译安装cd php-7.0.33
./configure \
--prefix=/usr/local/services/php7.0 \
--with-config-file-path=/usr/local/services/php7.0/etc \
--with-config-file-scan-dir=/usr/local/services/php7.0/etc/php.d \
--with-fpm-user=nobody \
--with-fpm-group=nobody \
--with-mysql-sock \
--with-mysqli=mysqlnd \
--with-pdo-mysql=mysqlnd \
--with-pdo-sqlite \
--with-fpm-systemd \
--with-pcre-regex \
--with-sqlite3 \
--with-cdb \
--with-kerberos \
--with-gmp \
--with-mhash \
--with-libmbfl \
--with-onig \
--with-readline \
--with-pear \
--with-xmlrpc \
--with-xsl \
--with-gettext \
--with-openssl \
--with-zlib \
--with-bz2 \
--with-gd \
--with-curl \
--with-mcrypt \
--with-pear \
--with-libxml-dir \
--with-freetype-dir \
--with-jpeg-dir \
--with-png-dir \
--with-pcre-dir \
--with-iconv-dir \
--enable-fpm \
--enable-pdo \
--enable-bcmath \
--enable-mysqlnd \
--enable-xmlreader \
--enable-xmlwriter \
--enable-calendar \
--enable-shmop \
--enable-static \
--enable-shared \
--enable-soap \
--enable-xml \
--enable-json \
--enable-mbstring \
--enable-mbregex \
--enable-mbregex-backtrack \
--enable-dom \
--enable-exif \
--enable-fileinfo \
--enable-filter \
--enable-inline-optimization \
--enable-pcntl \
--enable-sockets \
--enable-ftp \
--enable-intl \
--enable-zip \
--enable-session \
--enable-simplexml \
--enable-sysvmsg \
--enable-sysvsem \
--enable-sysvshm \
--enable-wddx \
--enable-mysqlnd-compression-support \
--enable-gd-native-ttf \
--enable-gd-jis-conv \
--enable-tokenizer \
--enable-opcache \
--disable-phpdbg-debug \
--disable-debug
make -j 16 && make install
或者
make ZEND_EXTRA_LIBS='-liconv' -j 16 && make install
4. 安装扩展库
yum -y install libevent libevent-devel \
libmemcached libmemcached-devel \
cyrus-sasl cyrus-sasl-devel \
zlib zlib-devel \
fastlz.x86_64 fastlz-devel.x86_64
/usr/local/services/php5.6/bin/pecl install igbinary
/usr/local/services/php5.6/bin/pecl install msgpack
/usr/local/services/php5.6/bin/pecl install memcached
5. 处理配置文件
cp php.ini-production /usr/local/services/php7.0/etc/php.ini
cd sapi/fpm;
cp php-fpm.service /usr/lib/systemd/system/php7-fpm.service
6. 修改配置文件
修改php.ini文件配置
修改php-fpm.conf文件
修改php-fpm.d/www.conf文件
cat > /usr/local/services/php5.6/etc/php.d/ext-opcache.ini << EOF
[opcache]
;zend_extension=opcache.so
;opcache.enable=1
opcache.enable_cli=1
opcache.memory_consumption=$Memory_limit
opcache.interned_strings_buffer=8
opcache.max_accelerated_files=100000
opcache.max_wasted_percentage=5
opcache.use_cwd=1
opcache.validate_timestamps=1
opcache.revalidate_freq=60
opcache.save_comments=0
opcache.fast_shutdown=1
opcache.consistency_checks=0
;opcache.optimization_level=0
EOF
cat > /usr/local/services/php5.6/etc/php.d/ext-igbinary.ini << EOF
[igbinary]
extension=igbinary.so
EOF
cat > /usr/local/services/php5.6/etc/php.d/ext-msgpack.ini << EOF
[msgpack]
extension=msgpack.so
EOF
cat > /usr/local/services/php5.6/etc/php.d/ext-memcached.ini << EOF
[memcached]
extension=memcached.so
memcached.use_sasl=1
EOF
7. 创建session文件保存目录
mkdir -p /tmp/phpsession;
chown -R nobody:nobody /tmp/phpsesssion;
8. phantomjs导出图片字体处理
yum install fontconfig mkfontscale
参考:https://blog.csdn.net/changzhou0519/article/details/72311443
https://blog.csdn.net/weixin_30888707/article/details/99922842
cp fonts.tar.gz /usr/share;
tar -zxvf fonts.tar.gz;
mkfontscale;
9. phantomjs导出图片字体处理
yum install fontconfig mkfontscale
参考:https://blog.csdn.net/changzhou0519/article/details/72311443
https://blog.csdn.net/weixin_30888707/article/details/99922842
cp fonts.tar.gz /usr/share;
tar -zxvf fonts.tar.gz;
mkfontscale;