1、更新yum、安装php相关依赖
yum update yum -y install libxml2 libxml2-devel openssl openssl-devel bzip2 bzip2-devel libcurl libcurl-devel libjpeg libjpeg-devel libpng libpng-devel freetype freetype-devel gmp gmp-devel libmcrypt libmcrypt-devel readline readline-devel libxslt libxslt-devel zlib zlib-devel glibc glibc-devel glib2 glib2-devel ncurses curl gdbm-devel db4-devel libXpm-devel libX11-devel gd-devel gmp-devel expat-devel xmlrpc-c xmlrpc-c-devel libicu-devel libmcrypt-devel libmemcached-devel gcc-c++
2、创建www用户及用户组
groupadd www useradd -g www www
3、安装cmake、libzip(编译软件以及压缩软件)
*安装cmake
tar -zxvf cmake* ./bootstrap make && make install
*安装libzip
tar -zxvf libzip* mkdir build cd build cmake .. make && make install
4、编译php,./configure。报错: error: off_t undefined; check your library configuration,设置以下
vi /etc/ld.so.conf /usr/local/lib64 /usr/local/lib /usr/lib /usr/lib64 ldconfig -v
5、再次编译php
./configure \ --prefix=/usr/local/php\ --enable-fpm\ --with-fpm-user=www\ --with-fpm-group=www\ --with-config-file-path=/usr/local/php/conf\ --disable-rpath\ --enable-soap\ --with-libxml-dir\ --with-xmlrpc\ --with-openssl\ --with-mhash\ --with-pcre-regex\ --with-zlib\ --enable-bcmath\ --with-bz2\ --enable-calendar\ --with-curl\ --enable-exif\ --with-pcre-dir\ --enable-ftp\ --with-gd\ --with-openssl-dir\ --with-jpeg-dir\ --with-png-dir\ --with-zlib-dir\ --with-freetype-dir\ --enable-gd-jis-conv\ --with-gettext\ --with-gmp\ --with-mhash\ --enable-mbstring\ --with-onig\ --with-mysqli=mysqlnd\ --with-pdo-mysql=mysqlnd\ --with-zlib-dir\ --with-readline\ --enable-shmop\ --enable-sockets\ --enable-sysvmsg\ --enable-sysvsem \ --enable-sysvshm \ --enable-wddx\ --with-libxml-dir\ --with-xsl\ --enable-zip\ --with-pear make && make install
6、添加用户永久变量
vi /etc/profile PATH=$PATH:/usr/local/php/bin export PATH *即时生效 source /etc/profile
7、将编译好的php配置文件cp目录
cp php.ini-production /usr/local/php/conf/php.ini cp /usr/local/php/etc/php-fpm.conf.default /usr/local/php/etc/php-fpm.conf cp /usr/local/php/etc/php-fpm.d/www.conf.default /usr/local/php/etc/php-fpm.d/www.conf
8、设置开机自启
cp sapi/fpm/php-fpm.service /usr/lib/systemd/system/php-fpm.service systemctl start php-fpm.service systemctl enable php-fpm.service