阿里云服务器安装后-安装配置PHP-FPM

01/12/2016

1.更新缓存,安装PHP-FPM

tianyangtax@iZ25tc8mln7Z:~$ sudo apt-get update
tianyangtax@iZ25tc8mln7Z:~$ sudo apt-get upgrade
tianyangtax@iZ25tc8mln7Z:~$ sudo apt-get install php5 php5-cli php5-curl php5-fpm php5-intl php5-mcrypt php5-mysqlnd php5-gd

2.更新PHP-FPM配置文件

tianyangtax@iZ25tc8mln7Z:~$ sudo vim /etc/php5/fpm/php.ini
tianyangtax@iZ25tc8mln7Z:~$ sudo cat /etc/php5/fpm/php.ini
...
post_max_size = 1024M 
memory_limit = 2048M
upload_max_filesize = 1024M
...
tianyangtax@iZ25tc8mln7Z:~$ sudo vim /etc/php5/fpm/pool.d/www.conf
tianyangtax@iZ25tc8mln7Z:~$ sudo cat /etc/php5/fpm/pool.d/www.conf
...
listen = /var/run/php5-fpm.sock
...
listen.owner = www-data
listen.group = www-data
listen.mode = 0660
...
tianyangtax@iZ25tc8mln7Z:~$ sudo service php5-fpm restart
php5-fpm stop/waiting
php5-fpm start/running, process 11930

3.更新NGINX站点配置文件以支持PHP

tianyangtax@iZ25tc8mln7Z:~$ sudo vim /etc/nginx/sites-available/default
tianyangtax@iZ25tc8mln7Z:~$ sudo cat /etc/nginx/sites-available/default
...
server {
...
    	index index.html index.htm index.php;
...
# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
	#
	location ~ \.php$ {
		fastcgi_split_path_info ^(.+\.php)(/.+)$;
		# NOTE: You should have "cgi.fix_pathinfo = 0;" in php.ini
	
		# With php5-cgi alone:
		# fastcgi_pass 127.0.0.1:9000;
		# With php5-fpm:
		fastcgi_pass unix:/var/run/php5-fpm.sock;
		fastcgi_index index.php;
		include fastcgi_params;
	}

	# deny access to .htaccess files, if Apache's document root
	# concurs with nginx's one
	#
	location ~ /\.ht {
		deny all;
	}
...
tianyangtax@iZ25tc8mln7Z:~$ sudo service nginx restart
 * Restarting nginx nginx                     [ OK ]

4.测试服务器及PHP是否正常

 
tianyangtax@iZ25tc8mln7Z:~$ sudo vim /usr/share/nginx/html/phpinfo.php
tianyangtax@iZ25tc8mln7Z:~$ sudo cat /usr/share/nginx/html/phpinfo.php
< ?php
    phpinfo();

2016-01-12 20:58:31屏幕截图