1 创建php用户和用户组,并在github下载php7源码
#######新建php用户和php组
[root@typecodes ~]# groupadd -r www && useradd -r -g www -s /bin/false -d /usr/local/php7 -M php #####安装编译php7时需要的依赖包
[root@typecodes ~]# yum -y install libxml2 libxml2-devel openssl openssl-devel curl-devel libjpeg-devel libpng-devel freetype-devel libmcrypt-devel
2 PHP7编译参数的配置
准备工作做好后,就开始正式配置php7的安装明细了。注意,操作时一定要先把下面反斜杠“\”后面添加的注释文字去掉!!!
cd /usr/local/src
wget http://cn2.php.net/distributions/php-7.1.5.tar.gz
tar zxvf php-7.1..tar.gz
cd php-7.1. ######开始配置
[root@typecodes php-7.1.]# ./configure \
--prefix=/usr/local/php7 \
--exec-prefix=/usr/local/php7 \
--bindir=/usr/local/php7/bin \
--sbindir=/usr/local/php7/sbin \
--includedir=/usr/local/php7/include \
--libdir=/usr/local/php7/lib/php \
--mandir=/usr/local/php7/php/man \
--with-config-file-path=/usr/local/php7/etc \
--with-mysql-sock=/var/lib/mysql/mysql.sock \
--with-mcrypt=/usr/include \
--with-mhash \
--with-openssl \
--with-mysql=shared,mysqlnd \
--with-mysqli=shared,mysqlnd \
--with-pdo-mysql=shared,mysqlnd \
--with-gd \
--with-iconv \
--with-zlib \
--enable-zip \
--enable-inline-optimization \
--disable-debug \
--disable-rpath \
--enable-shared \
--enable-xml \
--enable-bcmath \
--enable-shmop \
--enable-sysvsem \
--enable-mbregex \
--enable-mbstring \
--enable-ftp \
--enable-gd-native-ttf \
--enable-pcntl \
--enable-sockets \
--with-xmlrpc \
--enable-soap \
--without-pear \
--with-gettext \
--enable-session \
--with-curl \
--with-jpeg-dir \
--with-freetype-dir \
--enable-opcache \
--enable-redis \
--enable-fpm \
--enable-fastcgi \
--with-fpm-user=www \
--with-fpm-group=www \
--without-gdbm \
--disable-fileinfo
执行上面的配置命令的结果:
configure: WARNING: unrecognized options: --with-mysql, --enable-fastcgi
我在配置的时候,下面句报错了,去掉就可以正常编译了。
--with-mcrypt=/usr/include
make && make install
拷贝配置
cp /usr/local/php/etc/php-fpm.d/www.conf.default /usr/local/php/etc/php-fpm.d/www.conf
cp /usr/local/php/etc/php-fpm.conf.default /usr/local/php/etc/php-fpm.conf
然后就是运行 /usr/local/php7/sbin/php-fpm 如果有错误信息,在一步一步排查解决;
最后让Nginx解析php文件,以下变动
在nginx/html下创建php文件,浏览器输入ip/filename.php查看是否正确解析!Over