Nginx服务器部署

12次阅读

采用 nginx 源码安装方式

1. 将 nginx-1.8.0.tar.gz 上传到 /usr/local/ 目录下

2. 进入根目录执行编译检查依赖环境是否满足./configure

由于 nginx 依赖于 gc++、pcre、zlib 等库 , 如果环境不存在此三个库 , 则会报 error, 需要安装

再次执行./configure

若上面步骤正确执行 , 安装完毕 !

可将 nginx 配置为系统变量

配置后 nginx 启动命令为 nginx -c /usr/local/nginx/conf/nginx.conf
测试 : 浏览器地址栏输入:http://ip:80

10.86.64.198 内部使用 ,nginx.conf 及 80.conf

user nobody; worker_processes auto; error_log /var/log/nginx/error.log; pid logs/nginx.pid; events { worker_connections 1024; } http { include mime.types; default_type application/octet-stream; log_format main '$remote_addr - $remote_user [$time_local] "$request" ' '$status $body_bytes_sent "$http_referer" ' '"$http_user_agent" "$http_x_forwarded_for"'; access_log /var/log/nginx/access.log main; sendfile on; tcp_nopush on; keepalive_timeout 65; include /usr/local/nginx/conf/conf.d/*.conf; client_max_body_size 500M; } 
server { listen 80; location = / { rewrite ^ /XXX/index.html } location / { proxy_pass http://XXX:8080; } } 

10.86.64.197 外部使用 ,nginx.conf 及 80.conf、443.conf

user nobody; worker_processes auto; error_log /var/log/nginx/error.log; pid logs/nginx.pid; events { worker_connections 1024; } http { include mime.types; default_type application/octet-stream; log_format main '$remote_addr - $remote_user [$time_local] "$request" ' '$status $body_bytes_sent "$http_referer" ' '"$http_user_agent" "$http_x_forwarded_for"'; access_log /var/log/nginx/access.log main; sendfile on; tcp_nopush on; keepalive_timeout 65; include /usr/local/nginx/conf/conf.d/*.conf; client_max_body_size 500M; } 
server { listen 80; server_name XXX.com; rewrite ^(.*)$ https://${server_name}$1 permanent;  } 
server { listen 443; server_name XXX.com; ssl on; ssl_certificate /etc/ssl/certs/Server_Wildcard_XXX_com_20180921.cer; ssl_certificate_key /etc/ssl/certs/Server_Wildcard_XXX_com_20180921.key; error_page 500 502 503 504 /50x.html; location / { proxy_pass http://XXX:8080; proxy_http_version 1.1; proxy_set_header Upgrade $http_upgrade; proxy_set_header Connection "upgrade"; } } 

nginx -t 查看 nginx 进程当前使用的配置文件
start nginx # 启动 nginx
nginx -s reload # 重新载入配置文件
nginx -s reopen # 重启 nginx
nginx -s stop # 停止 nginx

原文链接:https://blog.csdn.net/gxl8052/article/details/113567798

正文完
 
追风者
版权声明:本站原创文章,由 追风者 2024-01-02发表,共计2016字。
转载说明:声明:本站内容均来自互联网,归原创作者所有,如有侵权必删除。 本站文章皆由CC-4.0协议发布。