码迷,mamicode.com
首页 > Web开发 > 详细

ubuntu14.04上安装Nginx1.8.0+php5-fpm

时间:2015-06-11 23:12:52      阅读:261      评论:0      收藏:0      [点我收藏+]

标签:ubuntu nginx php

1.download nginx源码

2.

tar –xvf nginx.tar.gz

3.nginx需要preczlib

sudo apt-get prec3 prec3-dev
sudo apt-get zlib1g zlib1g-dev

 

4.安装配置

cd nginx
sudo ./configure

安装内容

Configuration summary
  +using system PCRE library
  +OpenSSL library is not used
  +using builtin md5 code
  +sha1 library is not found
  +using system zlib library
 
 nginx path prefix: "/usr/local/nginx"
 nginx binary file: "/usr/local/nginx/sbin/nginx"
 nginx configuration prefix: "/usr/local/nginx/conf"
 nginx configuration file: "/usr/local/nginx/conf/nginx.conf"
 nginx pid file: "/usr/local/nginx/logs/nginx.pid"
 nginx error log file: "/usr/local/nginx/logs/error.log"
 nginx http access log file: "/usr/local/nginx/logs/access.log"
 nginx http client request body temporary files:"client_body_temp"
 nginx http proxy temporary files: "proxy_temp"
 nginx http fastcgi temporary files: "fastcgi_temp"
 nginx http uwsgi temporary files: "uwsgi_temp"
 nginx http scgi temporary files: "scgi_temp"

 

5.编译安装

sudo make
sudo make install

安装成功之后,nginx放置在/usr/local/nginx目录下,主要的配置文件为conf目录下的nginx.conf

 

6.配置从/etc/init.d/nginx start

sudo wgethttps://raw.github.com/JasonGiedymin/nginx-init-ubuntu/master/nginx -O/etc/init.d/nginx
sudo chmod +x /etc/init.d/nginx
sudo vim /etc/init.d/nginx

默认情况 Consts 下面的内容如下,如果与自己的情况不同的话则调整(红色内容是常见的需要修改调整的项目):

PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
DAEMON=/usr/local/nginx/sbin/nginx
 
PS="nginx"
PIDNAME="nginx"                     #lets you do $PS-slave
PIDFILE=$PIDNAME.pid                #pid file
PIDSPATH=/usr/local/nginx/logs     #default pidlocation, you should change it
 
DESCRIPTION="Nginx Server..."
 
RUNAS=root                          #user to run as
 
SCRIPT_OK=0                         #ala error codes
SCRIPT_ERROR=1                      #ala error codes
TRUE=1                              #boolean
FALSE=0                             #boolean
 
lockfile=/var/lock/subsys/nginx
NGINX_CONF_FILE="/usr/local/nginx/conf/nginx.conf"
 
# chkconfig –add nginx
# chkconfig –level 2345 nginx on

于是,启动 nginx 的方法为

sudo service nginx start
sudo /etc/init.d/nginx start

 

设置开机启动的方法则为:

# vim/etc/rc.local

写入

  service nginx start

之前如果 rc.local 里面有 /usr/local/nginx/sbin/nginx 的记得要删掉(废话 = =

 

7.安装php-fpm

sudo apt-getinstall php5-fpm

/usr/local/nginx/conf/fastcgi_params添加

fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;

/usr/local/nginx/conf/nginx.conf添加

gzip  on;
gzip_min_length 1k;
gzip_buffers    4 16k;
gzip_http_version 1.1;
gzip_comp_level 2;
gzip_types text/plain application/x-javascript text/cssapplication/xml;
gzip_vary on;
 
# pass the PHP scripts to FastCGI serverlistening on 127.0.0.1:9000
#
location ~ \.php$ {
root           html;
fastcgi_pass   127.0.0.1:9000;
fastcgi_index  index.php;
fastcgi_param  SCRIPT_FILENAME  /scripts$fastcgi_script_name;
include        fastcgi_params;
}

8.监听端口

配置php5监听端口

/etc/php5/fpm/pool.d/www.conf

listen = /var/run/php5-fpm.sock 改为listen = 127.0.0.1:9000

重新运行php进程

 

9.测试

<?php
phpinfo();
?>


本文出自 “xyw的资料站” 博客,请务必保留此出处http://xyw55.blog.51cto.com/8191121/1660918

ubuntu14.04上安装Nginx1.8.0+php5-fpm

标签:ubuntu nginx php

原文地址:http://xyw55.blog.51cto.com/8191121/1660918

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!