【运维】nginx安装

1.下载

下载完成后上传到服务器上。http://nginx.org/en/download.html

【运维】nginx安装_第1张图片
nginx

2.安装

  • 解压
    [root@iZ2ze6x9yc8dbln1yj6rurZ nginx-1.12.2]# tar -xzvf nginx-1.12.2.tar.gz

  • 安装依赖包
    [root@iZ2ze6x9yc8dbln1yj6rurZ nginx-1.12.2]# yum -y install zlib zlib-devel openssl openssl-devel pcre pcre-devel gcc-c++ gc-devel

  • 配置安装目录
    [root@iZ2ze6x9yc8dbln1yj6rurZ nginx-1.12.2]# ./configure --prefix=/usr/local/soft/nginx --with-http_stub_status_module --with-http_ssl_module

  • 配置结果


    【运维】nginx安装_第2张图片
    nginx详细配置
  • 安装
    [root@iZ2ze6x9yc8dbln1yj6rurZ nginx-1.12.2]# make
    [root@iZ2ze6x9yc8dbln1yj6rurZ nginx-1.12.2]# make install

  • 启动
    [root@iZ2ze6x9yc8dbln1yj6rurZ sbin]# cd /usr/local/soft/nginx/sbin
    [root@iZ2ze6x9yc8dbln1yj6rurZ sbin]# ./nginx

  • 查看nginx进程
    [root@iZ2ze6x9yc8dbln1yj6rurZ sbin]# ps -ef |grep nginx

root      4237     1  0 May16 ?        00:00:01 nginx: master process /usr/local/soft/nginx/sbin
root     31006  4237  0 13:39 ?        00:00:13 nginx: worker process      
root     31007  4237  0 13:39 ?        00:00:11 nginx: worker process      
root     31008  4237  0 13:39 ?        00:00:13 nginx: worker process      
root     31009  4237  0 13:39 ?        00:00:08 nginx: worker process      
root     31010  4237  0 13:39 ?        00:00:00 nginx: cache manager process
root     31658 30713  0 15:40 pts/6    00:00:00 grep nginx
  • 查看配置文件
    [root@iZ2ze6x9yc8dbln1yj6rurZ conf]# cd /usr/local/soft/nginx/conf
    [root@iZ2ze6x9yc8dbln1yj6rurZ conf]# cat nginx.conf
server {
        listen       80;
        server_name  localhost;
        #charset koi8-r;
        #access_log  logs/host.access.log  main;
        location / {
            root   html;
            index  index.html index.htm;
        }
        #error_page  404              /404.html;
        # redirect server error pages to the static page /50x.html
        #
        error_page   500 502 503 504  /50x.html;
        location = /50x.html {
            root   html;
        }
}
  • 重新加载配置

[root@iZ2ze6x9yc8dbln1yj6rurZ nginx]# sbin/nginx -s reload

  • 访问地址http://localhost:80
【运维】nginx安装_第3张图片
http://localhost:80

你可能感兴趣的:(【运维】nginx安装)