安装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 php
useradd -M -s /sbin/nologin -g php php
如果用于开发,可以设置php账户可登录,添加密码,如下
PS: useradd -m -s /bin/bash -g php 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=php \ --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-rpathmake && 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 ManagerAfter=network.target[Service]Type=forkingPIDFile=/run/php-fpm.pidExecStart=/usr/local/php-7.1.3/sbin/php-fpm --daemonize -g /run/php-fpm.pidExecReload=/bin/kill -USR2 $MAINPIDExecStop=/bin/kill -SIGINT $MAINPIDPrivateTmp=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