1 创建php用户和用户组,并在github下载php7源码
1 #######新建php用户和php组 2 [root@typecodes ~]# groupadd -r www && useradd -r -g www -s /bin/false -d /usr/local/php7 -M php 3 4 #####安装编译php7时需要的依赖包 5 [root@typecodes ~]# yum -y install libxml2 libxml2-devel openssl openssl-devel curl-devel libjpeg-devel libpng-devel freetype-devel libmcrypt-devel
2 PHP7编译参数的配置
准备工作做好后,就开始正式配置php7的安装明细了。注意,操作时一定要先把下面反斜杠“”后面添加的注释文字去掉!!!
1 cd /usr/local/src 2 wget http://cn2.php.net/distributions/php-7.1.5.tar.gz 3 tar zxvf php-7.1.5.tar.gz 4 cd php-7.1.5 5 6 ######开始配置 7 [root@typecodes php-7.1.5]# ./configure 8 --prefix=/usr/local/php7 9 --exec-prefix=/usr/local/php7 10 --bindir=/usr/local/php7/bin 11 --sbindir=/usr/local/php7/sbin 12 --includedir=/usr/local/php7/include 13 --libdir=/usr/local/php7/lib/php 14 --mandir=/usr/local/php7/php/man 15 --with-config-file-path=/usr/local/php7/etc 16 --with-mysql-sock=/var/lib/mysql/mysql.sock 17 --with-mcrypt=/usr/include 18 --with-mhash 19 --with-openssl 20 --with-mysql=shared,mysqlnd 21 --with-mysqli=shared,mysqlnd 22 --with-pdo-mysql=shared,mysqlnd 23 --with-gd 24 --with-iconv 25 --with-zlib 26 --enable-zip 27 --enable-inline-optimization 28 --disable-debug 29 --disable-rpath 30 --enable-shared 31 --enable-xml 32 --enable-bcmath 33 --enable-shmop 34 --enable-sysvsem 35 --enable-mbregex 36 --enable-mbstring 37 --enable-ftp 38 --enable-gd-native-ttf 39 --enable-pcntl 40 --enable-sockets 41 --with-xmlrpc 42 --enable-soap 43 --without-pear 44 --with-gettext 45 --enable-session 46 --with-curl 47 --with-jpeg-dir 48 --with-freetype-dir 49 --enable-opcache 50 --enable-redis 51 --enable-fpm 52 --enable-fastcgi 53 --with-fpm-user=www 54 --with-fpm-group=www 55 --without-gdbm 56 --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