转自:https://www.jianshu.com/p/b4164a656b8bphp
1. 下载php-7.0.14.tar.gz,并将其解压:html
$ tar -zvxf php-7.0.14.tar.gz
2. 安装相关依赖包:mysql
$ apt-get install -y libxml2 libxml2-dev openssl libcurl4-gnutls-dev libjpeg-dev libpng12-dev libfreetype6-dev
3. 执行:ln -s /usr/lib/x86_64-linux-gnu/libssl.so /usr/lib
linux
注:不然会报错:configure: error: Cannot find OpenSSL's librariesnginx
4. 编译:web
$ cd php-7.0.14 $ ./configure --with-openssl --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-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-fpm \ --enable-fastcgi --without-gdbm --disable-fileinfo
5. 安装:sql
$ make && make install
成功:api
php安装成功浏览器
$ cd php-7.0.14
$ cp php.ini-production /usr/local/etc/php.ini
在php.ini中添加一行:cgi.fix_pathinfo=0session
$ cp /usr/local/etc/php-fpm.conf.default /usr/local/etc/php-fpm.conf
$ cp /usr/local/etc/php-fpm.d/www.conf.default /usr/local/etc/php-fpm.d/www.conf
$ vi /usr/local/etc/php-fpm.d/www.conf
将group = nobody修改成 group = ,即将nobody删除。不然在后面执行service php-fpm start时会报错,即Starting php-fpm [10-Feb-2017 06:32:10] ERROR: [pool www] cannot get gid for group 'nobody'
(可直接执行:sed -i "s/group = nobody/group = /g" /usr/local/etc/php-fpm.d/www.conf)
$ vi /usr/local/etc/php-fpm.conf
将php-fpm.conf最后一行的include=NONE/etc/php-fpm.d/.conf修改成include=etc/php-fpm.d/.conf
(注:此时可使用命令进行测试:
$ /usr/local/sbin/php-fpm -t
输出:NOTICE: configuration file /usr/local/etc/php-fpm.conf test is successful 即配置正确)
$ cp /root/php-7.0.14/sapi/fpm/init.d.php-fpm /etc/init.d/php-fpm
$ chmod 755 /etc/init.d/php-fpm
$ service php-fpm start
输出:Starting php-fpm done
注:先要安装nginx,具体步聚见http://www.jianshu.com/p/6b70db035b95
<?php phpinfo() ?>
http://localhost/test.php
,看到如下页面即成功。test.php页面