看PHP7.0發佈了,嚐嚐鮮決定自己動手安裝部署下,(未安裝mysql及php優化加速等,後續完成)現將步驟羅列下:
1、系統添加www用戶
#useradd wwwy
2、安裝前準備
#yum install epel-* -y
#yum install -y wget unzip gcc gcc-c++ make zlib zlib-devel pcre pcre-devel libjpeg libjpeg-devel libpng libpng-devel freetype freetype-devel libxml2 libxml2-devel glibc glibc-devel glib2 glib2-devel bzip2 bzip2-devel ncurses ncurses-devel curl curl-devel e2fsprogs e2fsprogs-devel krb5 krb5-devel openssl openssl-devel openldap openldap-devel nss_ldap openldap-clients openldap-servers
#wget http://ftp.gnu.org/pub/gnu/libiconv/libiconv-1.14.tar.gz
#tar zxf libiconv-1.14.tar.gz
#cd libiconv-1.14
#./configure --prefix=/usr
#make
#make install
#cd ..
2、下載PHP7.0
#wget http://php.net/distributions/php-7.0.0.tar.bz2
#tar -jxvf php-7.0.0.tar.bz2
#cd php-7.0.0
#./configure --prefix=/usr/local/php70 --sysconfdir=/usr/local/php70/etc --with-config-file-scan-dir=/usr/local/php70/etc --enable-fpm --with-fpm-user=www --with-fpm-group=www --enable-mbstring --enable-sockets --enable-pcntl --enable-pdo --enable-mysqlnd --with-mysql=mysqlnd --with-mysqli=mysqlnd --with-pdo-mysql=mysqlnd --enable-sysvshm --enable-shmop --with-jpeg-dir=/usr --with-freetype-dir=/usr --with-png-dir=/usr --with-zlib-dir=/usr --with-gd --with-openssl --enable-opcache --enable-zip --enable-bcmath --enable-pcntl --enable-ftp --with-curl
#./configure --prefix=/usr/local/php70 --sysconfdir=/usr/local/php70/etc --with-config-file-scan-dir=/usr/local/php70/etc --enable-fpm --with-fpm-user=www --with-fpm-group=www --enable-mbstring --enable-sockets --enable-pcntl --enable-pdo--enable-sysvshm --enable-shmop --with-jpeg-dir=/usr --with-freetype-dir=/usr --with-png-dir=/usr --with-zlib-dir=/usr --with-iconv=/usr/lib --with-gd --with-openssl --enable-opcache=no --enable-zip --enable-bcmath --enable-pcntl --enable-ftp --with-curl
#make
#make install
#cp php.ini-production /usr/local/php70/etc/php.ini
#cp sapi/fpm/init.d.php-fpm /etc/init.d/php-fpm
#cp sapi/fpm/php-fpm.conf /usr/local/php70/etc/php-fpm.conf
#cp sapi/fpm/www.conf /usr/local/php70/etc/php-fpm.d/www.conf
#cd ..
#sed -i 's#short_open_tag = Off#short_open_tag = On#g' /usr/local/php70/etc/php.ini
#chmod +x /etc/init.d/php-fpm
3、安裝nginx-1.9.7
#wget http://nginx.org/download/nginx-1.9.7.tar.gz
#tar -zxvf nginx-1.9.7.tar.gz
#cd nginx-1.9.7
#./configure --user=www --group=www --prefix=/usr/local/nginx --with-http_stub_status_module --with-http_ssl_module
#make;make install
#cd ..
#vi /usr/local/nginx/conf/nginx.conf
#將document_root的定義放在location /{}的外面
root html;
index index.html index.htm index.php;
#下面的按照紅色標註修改
...
location ~ \.php$ {
root html;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
4、nginx的啓動
#/usr/local/nginx/sbin/nginx
關閉nginx,需要關閉nginx的主進程
查詢nginx主進程號
ps -ef | grep nginx
從容停止 kill -QUIT 主進程號
快速停止 kill -TERM 主進程號
強制停止 kill -9 nginx
5、啓動php-fpm#/etc/init.d/php-fpm start
相應的關閉及重啓爲stop,restart
在document的根目錄/usr/local/nginx/html下創建一個index.php文件輸出phpinfo信息
#echo '<?php phpinfo(); ?>' >/usr/local/nginx/html/index.php
6、訪問看到phpinfo