centos 非root nginx安裝

下載nginx

https://nginx.org/en/download.html

安裝依賴

yum  install  gcc  gcc-c++  make  automake  autoconf  libtool  pcre  pcre-devel  zlib  zlib-devel openssl openssl-devel

解壓二進制包

tar -zxvf nginx-x.x.x.tar.gz

配置相關環境變量

cd nginx-x.x.x
 
 ./configure --prefix=/usr/local/nginx --with-compat --with-file-aio --with-threads --with-http_addition_module --with-http_auth_request_module --with-http_dav_module --with-http_flv_module --with-http_gunzip_module --with-http_gzip_static_module --with-http_mp4_module --with-http_random_index_module --with-http_realip_module --with-http_secure_link_module --with-http_slice_module --with-http_ssl_module --with-http_stub_status_module --with-http_sub_module --with-http_v2_module --with-mail --with-mail_ssl_module --with-stream --with-stream_realip_module --with-stream_ssl_module --with-stream_ssl_preread_module

編譯

make && make install

查看編譯結果,爲0表示成功

echo $?

啓動nginx

cd /usr/local/nginx/
 ./sbin/nginx -c ./conf/nginx.conf
 
ps -ef|grep nginx

配置http

server {
    listen       80;
    listen       443 ssl;
    if ($scheme = http) {
        return   https://$host$request_uri;
    }  
     
    ssl                  on;
    ssl_certificate /path/to/crt;
    ssl_certificate_key /path/to/key;
    #ssl_session_cache    shared:SSL:1m;
    ssl_session_timeout  5m;
    ssl_ciphers  自行添加;
    ssl_prefer_server_ciphers  on;
    error_page   404 /404/404.html;
    error_page   500 502 503 504 /50x.html;
    location = /50x.html {
        root    html;
    }
 
    location / {       
        proxy_buffering off;
        add_header Cache-Control "no-cache, no-store";
        proxy_redirect off;
        proxy_set_header Host $host;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_pass   http://127.0.0.1:8080;
        proxy_set_header X-Forwarded-Proto $scheme;
        fastcgi_intercept_errors on;
    }
 
    access_log /data/nginx_logs/access.log;
}
發佈了41 篇原創文章 · 獲贊 4 · 訪問量 8萬+
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章