起步
之前在服务器搭建了lamp环境,想换用性能更强的nginx作为服务器软件,又想将php5升级为php7.
安装nginx无需赘述:sudo apt-get install nginx,启动ng前修改apache的端口。
安装php7
源码在http://php.net/downloads.php 下载,并解压。
# cd php7***
# ./configure –prefix=/usr/local/php7 –with-config-file-path=/usr/local/php7/etc –with-mcrypt=/usr/include –with-mysql=mysqlnd –with-mysqli=mysqlnd –with-pdo-mysql=mysqlnd –with-gd –with-iconv –with-zlib –enable-xml –enable-bcmath –enable-shmop –enable-sysvsem –enable-inline-optimization –enable-mbregex –enable-fpm –enable-mbstring –enable-ftp –enable-gd-native-ttf –with-openssl –enable-pcntl –enable-sockets –with-xmlrpc –enable-zip –enable-soap –without-pear –with-gettext –enable-session –with-curl –with-jpeg-dir –with-freetype-dir –enable-opcache
# make
# make install
为不与5冲突,文件夹都用php7,安装过程中报错的安装响应的依赖。
对接nginx
nginx本身不能处理php脚本,需要发给php解释器处理。nginx一般是把请求发fastcgi管理进程处理,fascgi管理进程选择cgi子进程处理结果并返回被nginx。
# cp sapi/fpm/init.d.php-fpm /etc/init.d/php7-fpm
# chmod +x /etc/init.d/php7-fpm
# cp /usr/local/php7/etc/php-fpm.conf.default /usr/local/php7/etc/php-fpm.conf
# cp /usr/local/php7/etc/php-fpm.d/www.conf.default /usr/local/php7/etc/php-fpm.d/www.conf
启动php-fpm
中途如遇到日志文件路径不存在就手动创建并给予写的权限。

