linux nginx搭建与使用详解程序员
2023-06-13 09:19:58 时间
nginx: the configuration file /etc/nginx/nginx.conf syntax is ok nginx: configuration file /etc/nginx/nginx.conf test is successful
CentOS7.0+ nginx实现停止、启动、重启
systemctl stop nginx.service; systemctl start nginx.service; systemctl restart nginx.service; systemctl status nginx.service;
开机自启:
systemctl enable nginx.service
取消开机自启:
systemctl disable nginx.service
nginx配置的修改: 修改nginx.conf(位置在/etc/nginx/)文件,可将配置文件放在一个文件夹中,让nginx自己去读取自定义的配置文件,修改结果如下
# For more information on configuration, see: # * Official English Documentation: http://nginx.org/en/docs/ # * Official Russian Documentation: http://nginx.org/ru/docs/ user nginx; worker_processes auto; error_log /var/log/nginx/error.log; pid /run/nginx.pid; # Load dynamic modules. See /usr/share/doc/nginx/README.dynamic. include /usr/share/nginx/modules/*.conf; events { worker_connections 1024; http { 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; tcp_nodelay on; keepalive_timeout 65; types_hash_max_size 2048; include /etc/nginx/mime.types; default_type application/octet-stream; # Load modular configuration files from the /etc/nginx/conf.d directory. # See http://nginx.org/en/docs/ngx_core_module.html#include # for more information. include /etc/nginx/conf.d/*.conf; }
include /etc/nginx/conf.d/*.conf;这一句的意思是从/etc/nginx/conf.d/文件夹中搜索所有*.conf的配置文件填充进配置中,例如我发布了一个网站,端口号是5000,如果不进行nginx映射,只能在linux的内网中进行访问,
无法在外网进行访问
例如我在/etc/nginx/conf.d/中添加了myblog.conf,如下面,重启nginx后,80端口的http请求都会转向到内部的5000端口,这样自己的网站就可以访问了
server { listen 80; location / { proxy_pass http://localhost:5000; proxy_http_version 1.1; proxy_set_header Upgrade $http_upgrade; proxy_set_header Connection keep-alive; proxy_set_header Host $host; proxy_cache_bypass $http_ipgrade; }
原创文章,作者:ItWorker,如若转载,请注明出处:https://blog.ytso.com/2126.html
服务器部署程序员系统优化网站设置运维相关文章
- linux非root用户启动nginx,Linux 普通用户启动nginx
- 员Linux终端:程序员的神奇世界(linux终端程序)
- Linux系统查看用户ID的方法(linux查看uid)
- 深入浅出:Linux线程堆栈大小(linux线程堆栈大小)
- 设置Linux下图标样式的自定义(linux图标)
- Linux下重启Nginx服务器(linux重启nginx)
- Linux:一种快速光盘修复解决方案(光盘修复linux)
- Linux:让所有用户无往不胜!(linux全部用户)
- 使用Linux命令快速设置DNS(linux设置dns命令)
- 小米笔记本上安装 Linux系统,快速操作指南(小米笔记本安装linux)
- 处理Linux 嵌入式系统解决视频处理问题(linux嵌入式视频)
- Linux文件存储:深入探索目录结构(linux文件的存储结构)
- Linux下如何快速修改分区名称(linux修改分区名称)
- 系统为程序员量身定制的Linux系统(最适合程序员的linux)
- 缓存Linux实现Nginx缓存的快速删除(linux删除nginx)
- 日志解决Linux系统中Nginx删除日志的方法(linux删除nginx)
- 设置Linux系统时间:一步一步指南(设置linux时间)
- 系统Linux下安装网卡驱动的指南(安装网卡驱动linux)
- Linux应用的广泛应用领域(linux应用领域)
- Linux下编译内核:挑战程序员的技术极限(linux下编译内核)
- Linux操作系统:开放源代码的程序员之福(linux操作系统是什么)