安装libmcrypt-devel
yum -y install epel-release
yum update -y
yum -y install gcc gcc-c++ autoconf automake libtool re2c flex bison php-mcrypt libmcrypt libmcrypt-devel openssl-devel libxml2-devel libcurl-devel libjpeg-devel libpng-devel freetype-devel zlib-devel mcrypt bzip2-devel libicu-devel systemd-devel mhash postgresql-devel glibc-devel glib2-devel ncurses-devel curl-devel gettext-devel
groupadd web
useradd -M -s /sbin/nologin -g web php
如果用于开发,可以设置php账户可登录,添加密码,如下
PS: useradd -m -s /bin/bash -g web php
passwd php
cd /usr/local/src/
wget http://cn2.php.net/distributions/php-7.1.3.tar.gz
tar -zxvf php-7.1.3.tar.gz
cd php-7.1.3/
./buildconf --force
./configure \
--prefix=/usr/local/php-7.1.3 \
--with-config-file-path=/usr/local/php-7.1.3/etc/ \
--with-mysql-sock=/var/lib/mysql/mysql.sock \
--with-mcrypt \
--with-mhash \
--with-openssl \
--with-mysqli=shared,mysqlnd \
--with-pdo-mysql=shared,mysqlnd \
--with-gd \
--with-iconv \
--with-zlib \
--with-xmlrpc \
--with-libdir=/usr/lib64 \
--with-png-dir=/usr/lib64 \
--with-gettext=/usr/lib64 \
--with-curl \
--with-jpeg-dir \
--with-freetype-dir=/usr/lib64 \
--with-fpm-user=php \
--with-fpm-group=web \
--with-pgsql \
--with-libxml-dir \
--with-bz2 \
--with-pcre-dir \
--without-gdbm \
--without-pear \
--enable-zip \
--enable-inline-optimization \
--enable-shared \
--enable-xml \
--enable-bcmath \
--enable-shmop \
--enable-sysvsem \
--enable-sysvshm \
--enable-sysvmsg \
--enable-intl \
--enable-mbregex \
--enable-mbstring \
--enable-ftp \
--enable-gd-native-ttf \
--enable-pcntl \
--enable-sockets \
--enable-soap \
--enable-session \
--enable-opcache \
--enable-fpm \
--enable-fileinfo \
--enable-calendar \
--enable-cli \
--enable-static \
--enable-wddx \
--disable-debug \
--enable-mysqlnd \
--enable-pdo \
--disable-rpath
make && make install
cp php.ini-development /usr/local/php-7.1.3/etc/php.ini
cp /usr/local/php-7.1.3/etc/php-fpm.conf.default /usr/local/php-7.1.3/etc/php-fpm.conf
cp /usr/local/php-7.1.3/etc/php-fpm.d/www.conf.default /usr/local/php-7.1.3/etc/php-fpm.d/www.conf
vi /lib/systemd/system/php-fpmd.service
[Unit]
Description=The PHP FastCGI Process Manager
After=network.target
[Service]
Type=forking
PIDFile=/run/php-fpm.pid
ExecStart=/usr/local/php-7.1.3/sbin/php-fpm --daemonize -g /run/php-fpm.pid
ExecReload=/bin/kill -USR2 $MAINPID
ExecStop=/bin/kill -SIGINT $MAINPID
PrivateTmp=true
[Install]
WantedBy=multi-user.target
开机自启动、运行、停止、重新加载、删除开机启动
chmod +x /lib/systemd/system/php-fpmd.service
systemctl enable php-fpmd.service
systemctl start php-fpmd.service
systemctl stop php-fpmd.service
systemctl daemon-reload
systemctl disable php-fpmd.service
安装插件
yum -y install ImageMagick-devel
编译imageMagick插件
配置php.ini
vi /usr/local/php-7.1.3/etc/php.ini
修改
expose_php = Off
date.timezone=Asia/Shanghai
末尾添加
extension=imagick.so
extension=pdo_mysql.so
extension=redis.so