环境:安装依赖包
[root]# yum install zlib zlib-devel pcre pcre-devel openssl openssl-devel -y
创建用户和组:
[root]# groupadd nginx
[root]# useradd -r -g nginx -s /sbin/nologin -M nginx
安装包:
1.下载安装包
[root]#wget http://nginx.org/download/nginx-1.6.3.tar.gz
2.解压
[root]# tar zxvf nginx-1.6.3.tar.gz
[root]# cd nginx-1.6.3
安装
**1.编译**
[nginx]#./configure \
--prefix=/etc/nginx \
--sbin-path=/usr/sbin/nginx \
--conf-path=/etc/nginx/nginx.conf \
--error-log-path=/var/log/nginx/error.log \
--http-log-path=/var/log/nginx/access.log \
--pid-path=/var/run/nginx.pid \
--lock-path=/var/run/nginx.lock \
--user=nginx \
--group=nginx \
--with-http_ssl_module \
--with-http_realip_module \
--with-http_addition_module \
--with-http_sub_module \
--with-http_dav_module \
--with-http_flv_module \
--with-http_mp4_module \
--with-http_gunzip_module \
--with-http_gzip_static_module \
--with-http_random_index_module \
--with-http_secure_link_module \
--with-http_stub_status_module \
--with-http_auth_request_module \
--with-file-aio \
--with-http_spdy_module \
--with-ipv6 \
--with-pcre
**2.安装**
[nginx]#make && make install
服务
[nginx]#/usr/sbin/nginx –t 测试nginx.conf配置文件语法是否正确
[nginx]#/usr/sbin/nginx 启动nginx服务
[nginx]#/usr/sbin/nginx –s stop/quit 停止服务
[nginx]#/usr/sbin/nginx –s reload 重新加载配置文件
配置文件
http{
sendfile on;
keepalive_timeout 65;
server { #虚拟主机配置
listen 80;
server_name localhost;
location / {
root html;
index index.html index.htm;
}
}
启动服务
[nginx]#/usr/sbin/nginx
[nginx]#ps aux|grep nginx