标签:hup net lin amp creating option basename c/s table
一、Nginx 源码包安装与配置
1、环境准备
操作系统、内核版本: | CentOS 6.8 2.6.32-642.el6.x86_64 |
Nginx 软件版本: | nginx-1.10.2 |
2、创建Nginx用户
[root@web01 ~]# groupadd -g 108 -r nginx
[root@web01 ~]# useradd -u 108 -r -g 108 nginx
[root@web01 ~]# id nginx
uid=108(nginx) gid=108(nginx) groups=108(nginx)
3、安装Nginx所需依赖包
# yum -y install pcre-devel openssl-devel gcc-c++ zlib-devel
4、编译安装Nginx-1.10.2
# cd /root/soft
# tar -xf nginx-1.10.2.tar.gz
# cd nginx-1.10.2
# ./configure --prefix=/usr/local/nginx --user=nginx --group=nginx --with-http_stub_status_module --with-http_ssl_module --with-file-aio --with-http_dav_module
# make
# make install
5、为nginx提供SysV init启动脚本(/etc/init.d/nginx)
#!/bin/sh
# 6、Nginx启动脚本赋予执行权限
# chmod +x /etc/init.d/nginx
7、添加到服务管理列表,并设置开机自动启动服务
# chmod +x /etc/init.d/nginx
# chkconfig --add nginx
# chkconfig nginx on
# chkconfig --list ngin
nginx 0:off 1:off 2:on 3:on 4:on 5:on 6:off
8、启动Nginx服务
Nginx启动前检查语法:(修改配置,重启服务前一定要先检查配置文件语法。)
[root@web01 nginx-1.10.2]# /usr/local/nginx/sbin/nginx -t
nginx: the configuration file /usr/local/nginx/conf/nginx.conf syntax is ok
nginx: configuration file /usr/local/nginx/conf/nginx.conf test is successful启动Nginx服务:[root@web01 nginx-1.10.2]# /etc/init.d/nginx start Starting nginx: [ OK ]
9、查看Nginx服务对应端口是否启动成功
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
nginx 4547 root 6u IPv4 17508 0t0 TCP *:http (LISTEN)
nginx 4548 nginx 6u IPv4 17508 0t0 TCP *:http (LISTEN)
[root@web01 nginx-1.10.2]# netstat -lnt| grep 80
tcp 0 0 0.0.0.0:80 0.0.0.0:* LISTEN
tcp 0 0 :::32980 :::* LISTEN
10、检查Nginx启动的实际效果,通过浏览器访问
好了到这里Nginx的安装就完成了,接下来会介绍Ngnix相关的配置!
标签:hup net lin amp creating option basename c/s table
原文地址:http://www.cnblogs.com/miclesvic/p/6135725.html