nginx

命令 内容 参数 备注
tar -zxvf xxx.tar.gz 解压文件 -zxvf

参考

  1. 安装依赖库gcc等
  • yum -y install make zlib zlib-devel gcc-c++ libtool openssl openssl-devel
  1. 下载 pcre
  • cd /usr/local/src/
  • wget http://downloads.sourceforge.net/project/pcre/pcre/8.35/pcre-8.35.tar.gz
  • wget https://netix.dl.sourceforge.net/project/pcre/pcre/8.40/pcre-8.40.tar.gz
  1. 编译 pcre
  • tar zxvf pcre-8.35.tar.gz
  • cd pcre-8.35
  • ./configure
  • make && make install
  • pcre-config --version
  1. 下载 nginx
  • cd /usr/local/src/
  • wget http://nginx.org/download/nginx-1.6.2.tar.gz
  • tar zxvf nginx-1.6.2.tar.gz
  • cd nginx-1.6.2
  1. 编译 nginx
  • mkdir /usr/local/webserver
  • cd /usr/local/webserver/
  • mkdir nginx
  • cd /usr/local/src/nginx-1.6.2
  • ./configure --prefix=/usr/local/webserver/nginx --with-http_stub_status_module --with-http_ssl_module --with-pcre=/usr/local/src/pcre-8.35
  • make && make install
  • /usr/local/webserver/nginx/sbin/nginx -v
  1. nginx 配置文件
  • vi /usr/local/webserver/nginx/conf/nginx.conf
  • 默认配置
server {
    listen       80;
    server_name  localhost;

    location / {
        root   html;
        index  index.html index.htm;
    }
    
    error_page   500 502 503 504  /50x.html;
    location = /50x.html {
        root   html;
    }
}
  • 配置1 nginx 转发请求到多个tomcat
    #gzip  on;
    
    upstream mytomcats {
        server localhost:8081;
        server localhost:8082;  
    }
        
    server {
        listen       80;
        server_name  localhost;

        location / {
            proxy_pass http://mytomcats;
        }
        
        error_page   500 502 503 504  /50x.html;
        location = /50x.html {
            root   html;
        }
    }
  1. 检查配置文件 nginx.conf 的正确性命令
  • /usr/local/webserver/nginx/sbin/nginx -t
  1. Nginx 命令
  • 启动
    • /usr/local/webserver/nginx/sbin/nginx
  • 停止
    • /usr/local/webserver/nginx/sbin/nginx -s stop
  • 重新加载
    • /usr/local/webserver/nginx/sbin/nginx -s reload

你可能感兴趣的:(nginx)