下载安装包 1 2 3 wget http://cn2.php.net/distributions/php-7.2.5.tar.gz tar -zxvf php-7.2.5.tar.gz
安装依赖 1 yum -y install wget vim pcre pcre-devel openssl openssl-devel libicu-devel gcc gcc-c++ autoconf libjpeg libjpeg-devel libpng libpng-devel freetype freetype-devel libxml2 libxml2-devel zlib zlib-devel glibc glibc-devel glib2 glib2-devel ncurses ncurses-devel curl curl-devel krb5-devel libidn libidn-devel openldap openldap-devel nss_ldap jemalloc-devel cmake boost-devel bison automake libevent libevent-devel gd gd-devel libtool* libmcrypt libmcrypt-devel mcrypt mhash libxslt libxslt-devel readline readline-devel gmp gmp-devel libcurl libcurl-devel openjpeg-devel
编译安装 如需复制,请复制第二种,第一种会超出字符限制
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 ./configure --prefix=/usr/local/php \ --with-config-file-path=/usr/local/php/etc \ --enable-fpm \ --with-fpm-user=www \ --with-fpm-group=www \ --enable-mysqlnd \ --with-mysqli=mysqlnd \ --with-pdo-mysql=mysqlnd \ --enable-mysqlnd-compression-support \ --with-iconv-dir \ --with-freetype-dir \ --with-jpeg-dir \ --with-png-dir \ --with-zlib \ --with-libxml-dir \ --enable-xml \ --disable-rpath \ --enable-bcmath \ --enable-shmop \ --enable-sysvsem \ --enable-inline-optimization \ --with-curl \ --enable-mbregex \ --enable-mbstring \ --with-libmbfl \ --enable-ftp \ --with-gd \ --enable-gd-jis-conv \ --with-openssl \ --with-mhash \ --enable-pcntl \ --enable-sockets \ --with-xmlrpc \ --enable-zip \ --enable-soap \ --with-gettext \ --disable-fileinfo \ --enable-opcache \ --with-pear \ --enable-maintainer-zts \ --with-ldap=shared \ --without-gdbm --enable-exif \ --enable-fileinfo \ --enable-calendar \ --enable-readline \ --enable-sodium \ --enable-sysvmsg \ --enable-sysvshm \ --enable-wddx
1 2 3 4 5 6 ./configure --prefix=/usr/local/php --with-config-file-path=/usr/local/php/etc --enable-fpm --with-fpm-user=www --with-fpm-group=www --enable-mysqlnd --with-mysqli=mysqlnd \ --with-pdo-mysql=mysqlnd --enable-mysqlnd-compression-support --with-iconv-dir --with-freetype-dir --with-jpeg-dir --with-png-dir --with-zlib --with-libxml-dir --enable-xml \ --disable-rpath --enable-bcmath --enable-shmop --enable-sysvsem --enable-inline-optimization --with-curl --enable-mbregex --enable-mbstring --with-libmbfl --enable-ftp \ --with-gd --enable-gd-jis-conv --with-openssl --with-mhash --enable-pcntl --enable-sockets --with-xmlrpc --enable-zip --enable-soap --with-gettext --disable-fileinfo \ --enable-opcache --with-pear --enable-maintainer-zts --with-ldap=shared --without-gdbm --enable-exif --enable-fileinfo --enable-calendar --enable-readline --enable-sodium \ --enable-sysvmsg --enable-sysvshm --enable-wddx
安装
修改配置文件 1 2 3 4 5 6 7 cp php.ini-development /usr/local/php/etc/php.inicd /usr/local/php/etccp -a php-fpm.conf.default php-fpm.confcd /usr/local/php/etc/php-fpm.d/cp -a www.conf.default www.conf
添加全局变量 1 2 ln -sf /usr/local/php/bin/php /usr/bin/phpln -sf /usr/local/php/bin/phpize /usr/local/bin/phpize
添加www用户 1 2 3 4 groupadd www useradd www useradd -g www www
使用systemctl管理php-fpm 1 vim /usr/lib/systemd/system/php-fpm.service
1 2 3 4 5 6 7 8 9 10 11 12 13 [Unit] Description=The PHP FastCGI Process Manager After=syslog.target network.target [Service] Type=forking PIDFile=/run/php-fpm.pid ExecStart=/usr/local/php/sbin/php-fpm ExecReload=/bin/kill -USR2 $MAINPID PrivateTmp=true [Install] WantedBy=multi-user.target
1 2 systemctl daemon-reload
systemctl 命令 1 2 3 4 systemctl status php-fpm systemctl stop php-fpm systemctl start php-fpm systemctl retart php-fpm
第三方扩展(igbinary,psr,phalcon,redis,swoole)安装 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 wget https://pecl.php.net/get/igbinary-3.2.1.tgz wget https://pecl.php.net/get/phalcon-4.1.0.tgz wget https://pecl.php.net/get/psr-1.0.1.tgz wget https://pecl.php.net/get/redis-5.3.2.tgz wget https://pecl.php.net/get/swoole-4.5.10.tgz tar -zxvf igbinary-3.2.1.tgz cd igbinaryphpize ./configure --with-php-config=/usr/local/php/bin/php-config make && make install extension=igbinary php -m
扩展问题 1.sodium扩展问题
checking for re2c… no configure: WARNING: You will need re2c 0.13.4 or later if you want to regenerate PHP parsers. checking for gawk… gawk checking for sodium support… yes, shared checking for pkg-config… /usr/bin/pkg-config checking for libsodium… configure: error: Please install libsodium - See https://github.com/jedisct1/libsodium
解决办法
1 2 3 4 5 6 1. yum -y groupinstall "Development Tools" 2. wget https://github.com/jedisct1/libsodium/releases/download/1.0.11/libsodium-1.0.11.tar.gz 3. tar xf libsodium-1.0.11.tar.gz && cd libsodium-1.0.11 4. ./configure && make -j2 && make install 5. echo /usr/local/lib > /etc/ld.so.conf.d/usr_local_lib.conf 6. ldconfig
解决办法
1 cp -frp /usr/lib64/libldap* /usr/lib/