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;
}
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

sleeper01

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值