nginx的单点部署

安装配置nginx

  1. 安装编译器
    [root@host01 ~]# rpm -qa | grep gcc
    [root@host01 ~]# yum install -y gcc openssl-devel pcre-devel zlib-devel lsof
    [root@host01 ~]# yum install wget -y
  2. 安装配置nginx
    [root@host01 ~]# groupadd -r nginx
    [root@host01 ~]# useradd -r -g nginx -s /sbin/nologin -M nginx
    [root@host01 ~]# mkdir -pv /var/tmp/nginx
    点我下载Nginx包到本地
    [root@host01 ~]# wget http://nginx.org/download/nginx-1.10.1.tar.gz
    [root@host01 ~]# tar -zxvf nginx-1.10.1.tar.gz
    [root@host01 ~]# cd nginx-1.10.1
    1
    [root@host01 nginx-1.10.1]# ./configure  --user=nginx  --group=nginx  --prefix=/usr/local/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/nginx.pid  --lock-path=/var/lock/nginx.lock  --with-http_stub_status_module  --with-http_ssl_module  --with-http_gzip_static_module  --with-pcre
    [root@host01 nginx-1.10.1]# make && make install
    [root@host01 nginx-1.10.1]# ./configure --help

启动验证Nginx

  1. 检查配置文件:
    [root@host01 nginx-1.10.1]# /usr/local/nginx/sbin/nginx -t

    出现以下内容表示成功
    nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
    nginx: configuration file /etc/nginx/nginx.conf test is successful

  2. 启动Nginx服务:
    [root@host01 nginx-1.10.1]# /usr/local/nginx/sbin/nginx

  3. 验证Nginx服务:
    [root@host01 nginx-1.10.1]# lsof -i:80

    COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
    nginx 3808 root 6u IPv4 22095 0t0 TCP *:http (LISTEN)
    nginx 3809 nginx 6u IPv4 22095 0t0 TCP *:http (LISTEN)

[root@host01 ~]# wget 127.0.0.1
[root@host01 ~]# curl 127.0.0.1
4. 使用Windows验证(windows打不开则关闭防护墙):
输入服务器IP地址,出现Welcom to nginx!则表示成功