使用MobaXterm配置nginx

1.查看nginx地址
bash 复制代码
nginx -t 

nginx -t = 测试配置文件语法 + 检查路径是否正确

  • 不会重启 Nginx
  • 不会影响正在运行的服务
  • 只检查你改的配置对不对

结果:

bash 复制代码
nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
nginx: configuration file /etc/nginx/nginx.conf test is successful
2.使用 vi 打开编辑

比如路径是 /etc/nginx/nginx.conf,输入:

复制代码
vi /etc/nginx/nginx.conf

按一下键盘上的 i 左下角会出现 -- INSERT --,就可以改了。

修改完成后

  1. 先按一下 Esc 键(必须按)
  2. 输入 :wq
  3. 回车
  4. 重启nginx
bash 复制代码
nginx -s reload
  • 不保存强制退出:Esc:q! → 回车
  • 保存并退出:Esc:wq → 回车
3.修改配置

复制一个server,修改前端端口 9081,上传文件地址 /home/knowledgeGraph/kg/dist

bash 复制代码
 server {
        listen       9081;
        listen       [::]:9081;
        server_name  _;
        location / {
                root /home/knowledgeGraph/kg/dist;
                index  index.html index.htm;
                try_files $uri $uri/ /index.html;
        }
        location /api/ {
                proxy_pass http://localhost:8080/;
                proxy_connect_timeout 6000;
                proxy_read_timeout 6000;
        }




        #root         /usr/share/nginx/html;

        # Load configuration files for the default server block.
        #include /etc/nginx/default.d/*.conf;

        error_page 404 /404.html;
        location = /404.html {
        }

        error_page 500 502 503 504 /50x.html;
        location = /50x.html {
        }
    }
4.上传压缩包

上传压缩包到 /home/knowledgeGraph/kg,然后切换到该目录解压压缩包

bash 复制代码
unzip dist.zip

重启nginx

bash 复制代码
nginx -s reload
相关推荐
木叶子---2 小时前
Spring 枚举转换器冲突问题分析与解决
java·python·spring
standovon2 小时前
SpringSecurity的配置
java
阿里巴巴首席技术官2 小时前
通过纯Nginx实现一个简单的文件上传功能
运维·nginx
霸道流氓气质2 小时前
SpringBoot+LangChain4j+Ollama+RAG(检索增强生成)实现私有文档向量化检索回答
java·spring boot·后端
就叫飞六吧2 小时前
Docker Hub 上主流的nginx发行
java·nginx·docker
MiNG MENS2 小时前
基于SpringBoot和Leaflet的行政区划地图掩膜效果实战
java·spring boot·后端
pengyi8710152 小时前
动态IP池快速更换实操方案,5分钟完成IP替换
服务器·网络·tcp/ip
2601_949814692 小时前
Spring Boot中的404错误:原因、影响及处理策略
java·spring boot·后端
不做无法实现的梦~2 小时前
Linux 上使用 CLion 开发嵌入式,并用 Codex CLI
linux·运维·服务器