Ubuntu安装nginx + php5-fpm
1、安装
$apt-get install mysql-server $apt-get install nginx $apt-get install php5-fpm $apt-get install php5-cli php5-gd php5-mcrypt php5-mysql
2、修改nginx配置
$vim /etc/nginx/nginx.conf
修改下面两行代码:
worker_processes 4; keepalive_timeout 2;
3、修改site配置
vim /etc/nginx/sites-available/default
修改inde.php 和 php 的fpm配置信息
server { root /var/www; #页面文件存放路径 index index.php index.html index.htm; # 加入index.php server_name localhost; # 修改为网站域名 location / { try_files $uri $uri/ /index.php?$args; # wordpress 重定向 if (-f $request_filename/index.html){ rewrite (.*) $1/index.html break; } if (-f $request_filename/index.php){ rewrite (.*) $1/index.php; } if (!-f $request_filename){ rewrite (.*) /index.php; } } # php5-fpm 配置信息 location ~ \.php$ { fastcgi_pass unix:/var/run/php5-fpm.sock; fastcgi_index index.php; include fastcgi_params; } }
4、修改php5-fpm,改为socket监听。
vim /etc/php5/fpm/pool.d/www.conf
改为socket监听
;listen = 127.0.0.1:9000 listen = /var/run/php5-fpm.sock
5、重启
$service php5-fpm restart $service nginx restart