Linux 安装Nginx

1 新建两个文件夹 一个存放安装文件,一个存放解压后的文件

mkdir -p /export/software   //存放安装文件
mkdir -p /export/servers     //存放解压后的文件

2 把文件放到服务器上的software文件夹内 然后解压到servers文件夹内

cd /export/software     //进入software文件夹 
tar -zxvf nginx-1.8.0.tar.gz  -C /export/servers/            //解压

3 安装依赖环境

yum install gcc-c++
yum install -y pcre pcre-devel
yum install -y zlib zlib-devel
yum install -y openssl openssl-devel

4 创建临时目录

mkdir -p  /var/temp/nginx  //创建目录

5 在nginx的解压的目录中执行(生成Makefile文件)

cd /export/servers/nginx-1.8.0/
./configure \
--prefix=/usr/local/nginx \
--pid-path=/var/run/nginx/nginx.pid \
--lock-path=/var/lock/nginx.lock \
--error-log-path=/var/log/nginx/error.log \
--http-log-path=/var/log/nginx/access.log \
--with-http_gzip_static_module \
--http-client-body-temp-path=/var/temp/nginx/client \
--http-proxy-temp-path=/var/temp/nginx/proxy \
--http-fastcgi-temp-path=/var/temp/nginx/fastcgi \
--http-uwsgi-temp-path=/var/temp/nginx/uwsgi \
--http-scgi-temp-path=/var/temp/nginx/scgi
Makefile是一种配置文件, Makefile 一个工程中的源文件不计数,其按类型、功能、模块分别放在若干个目录中,makefile定义了一系列的规则来指定,哪些文件需要先编译,哪些文件需要后编译,哪些文件需要重新编译,甚至于进行更复杂的功能操作,因为 makefile就像一个Shell脚本一样,其中也可以执行操作系统的命令。

configure参数
./configure \
--prefix=/usr \                                          指向安装目录
--sbin-path=/usr/sbin/nginx \                            指向(执行)程序文件(nginx)
--conf-path=/etc/nginx/nginx.conf \                      指向配置文件
--error-log-path=/var/log/nginx/error.log \              指向log
--http-log-path=/var/log/nginx/access.log \              指向http-log
--pid-path=/var/run/nginx/nginx.pid \                    指向pid
--lock-path=/var/lock/nginx.lock \                       (安装文件锁定,防止安装文件被别人利用,或自己误操作。)
--user=nginx \
--group=nginx \
--with-http_ssl_module \                                 启用ngx_http_ssl_module支持(使支持https请求,需已安装openssl)
--with-http_flv_module \                                 启用ngx_http_flv_module支持(提供寻求内存使用基于时间的偏移量文件)
--with-http_stub_status_module \                         启用ngx_http_stub_status_module支持(获取nginx自上次启动以来的工作状态)
--with-http_gzip_static_module \                         启用ngx_http_gzip_static_module支持(在线实时压缩输出数据流)
--http-client-body-temp-path=/var/tmp/nginx/client/ \    设定http客户端请求临时文件路径
--http-proxy-temp-path=/var/tmp/nginx/proxy/ \           设定http代理临时文件路径
--http-fastcgi-temp-path=/var/tmp/nginx/fcgi/ \          设定http fastcgi临时文件路径
--http-uwsgi-temp-path=/var/tmp/nginx/uwsgi \            设定http uwsgi临时文件路径
--http-scgi-temp-path=/var/tmp/nginx/scgi \              设定http scgi临时文件路径
--with-pcre                                              启用pcre库
参数详解

 

6 编译 安装

make
make  install

7 启动nginx

cd /usr/local/nginx/sbin/
./nginx 
# 重启
./nginx -s reload

8 校验

netstat -nltp  //查看进程

 浏览器输入ip访问(默认端口是80)。

posted @ 2016-04-22 20:39  青衫仗剑  阅读(245)  评论(0编辑  收藏  举报