JAVA和Nginx 教程大全

网站首页 > 精选教程 正文

nginx 在centos 离线安装

wys521 2024-09-14 13:32:26 精选教程 37 ℃ 0 评论


  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

本文暂时没有评论,来添加一个吧(●'◡'●)

欢迎 发表评论:

最近发表
标签列表