nginx 在centos 离线安装

  1. 上传pcre-devel-7.8-7.el6.x86_64.rpm至服务器;
  2. 执行rpm –iv pcre-devel-7.8-7.el6.x86_64.rpm;非root账号 sudo rpm –iv pcre-devel-7.8-7.el6.x86_64.rpm
  3. 上传nginx-1.13.6至服务器
  4. 执行 ./configure  --prefix=/usr/local/nginx   --sbin-path=/usr/local/nginx/sbin/nginx --conf-path=/usr/local/nginx/conf/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  --user=nginx --group=nginx --with-http_stub_status_module  --http-client-body-temp-path=/var/tmp/nginx/client/ --http-proxy-temp-path=/var/tmp/nginx/proxy/ --http-fastcgi-temp-path=/var/tmp/nginx/fcgi/ --http-uwsgi-temp-path=/var/tmp/nginx/uwsgi --http-scgi-temp-path=/var/tmp/nginx/scgi --without-http_gzip_module --with-pcre
  5. 成功后,执行make,若失败重新执行上一步
  6. 成功后,执行make install
  7.    /usr/local/nginx/sbin/nginx -c /usr/local/nginx/conf/nginx.conf
  8. 可能出现 nginx: [emerg] getpwnam("nginx") failed 错误,因为服务器上没有添加nginx用户组,执行 [root@localhost nginx-1.11.2]# useradd -s /sbin/nologin -M nginx
  9. [root@localhost nginx-1.11.2]# id nginx
  10. [root@localhost nginx-1.11.2]# /usr/local/nginx/sbin/nginx
  11. [root@localhost nginx-1.11.2]# netstat -tlunp | grep nginx
  12. 若出现nginx: [emerg] mkdir() "/var/tmp/nginx/client/" failed (2: No such file or directory),可手动新建此目录
  13. nginx配置:
  1. cd /usr/local/nginx/conf
  2. 打开nginx.conf文件,在Server{}加入配置

#静态资源目录

location ~ .*\.(js|css|ico|png|jpg|eot|svg|ttf|woff|html|gif) {

            root   /home/docker/scf;

            index  index.html index.htm;

        }

#用户注册登录模块

location /jwt/ {

            index  index.html index.htm;

proxy_pass http://10.220.160.103:8760/jwt/;#正式环境切换为服务器ip

        }

 

#业务路径

location /api/ {

            index  index.html index.htm;

proxy_pass http://10.220.160.103:8760/api/;#正式环境切换为服务器ip

        }

#上传文件前端访问路径配置,正式环境root配置为mount公共目录

location ^~ /file/ {

root  /home/upload/;

 

}

开放linux防火墙端口

添加防火墙规则:sudo iptables -I INPUT -p tcp --dport 80 -j ACCEPT

保存防护区规则:sudo /etc/rc.d/init.d/iptables save

重启防火墙生效规则:sudo service iptables restart

查看规则表: iptables -L –n

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值