当前位置:   article > 正文

本地安装nginx及部署项目_nginx本地部署

nginx本地部署

1、下载:

nginx官网地址:https://nginx.org/en/download.html

选择遗留的稳定版本:

在这里插入图片描述

解压到任意位置

在这里插入图片描述

2、启动:

cmd 进入nginx文件夹 输入命令行:start nginx

在这里插入图片描述

打开浏览器,输入: http://localhost:80 出现以下页面即为启动成功

在这里插入图片描述

3、部署项目:

将项目放到nginx的html文件夹下

在这里插入图片描述

4、修改nginx的conf文件夹下的nginx.conf配置文件

配置说明:
1、listen:端口号
2、server_name:虚拟ip地址
3、root:声明默认网站根目录位置 --项目的根目录
4、index:定义首页索引文件的名称 --index.html
5、try_files:$uri $uri/ /app/index.html; 这里的设置是通过内部重定向的方式,去匹配目录下的索引文件index.html
6、location:控制服务访问路径
7、proxy_pass:请求代理转发

   server {
        listen       8011;
        server_name  localhost;	 

        #charset koi8-r;

        #access_log  logs/host.access.log  main;

        location / {
			try_files $uri $uri/ /index.html;
            #root   html;
            #index  index.html index.htm;
        }

        #error_page  404              /404.html;

        # redirect server error pages to the static page /50x.html
        #
        error_page   500 502 503 504  /50x.html;
        location = /50x.html {
            root   html;
        }

        # proxy the PHP scripts to Apache listening on 127.0.0.1:80
        #
        #location ~ \.php$ {
        #    proxy_pass   http://127.0.0.1;
        #}

        # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
        #
        #location ~ \.php$ {
        #    root           html;
        #    fastcgi_pass   127.0.0.1:9000;
        #    fastcgi_index  index.php;
        #    fastcgi_param  SCRIPT_FILENAME  /scripts$fastcgi_script_name;
        #    include        fastcgi_params;
        #}

        # deny access to .htaccess files, if Apache's document root
        # concurs with nginx's one
        #
        #location ~ /\.ht {
        #    deny  all;
        #}
    }
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  • 32
  • 33
  • 34
  • 35
  • 36
  • 37
  • 38
  • 39
  • 40
  • 41
  • 42
  • 43
  • 44
  • 45
  • 46

5、重启nginx:

cmd 进入nginx文件夹 输入命令行:nginx -s reload

![在这里插入图片描述](https://img-blog.csdnimg.cn/24be0c6535b942969b8510893f87dc93.png

6、效果:

在这里插入图片描述

7、nginx在windows下的常用命令:

启动:

直接点击nginx目录下的nginx.exe 或者

start nginx
  • 1
关闭:
nginx -s stop
  • 1
修改配置后重新加载生效并重启nginx:
nginx -s reload
  • 1
重新打开日志文件:
nginx -s reopen
  • 1
测试nginx配置文件nginx.conf是否正确:
nginx -t -c /xxx/xx/nginx.conf
  • 1

8、nginx实现同个ip、端口访问不同的项目(以路劲区分项目):

nginx实现同个ip、端口访问不同的项目(以路劲区分项目)

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/我家自动化/article/detail/232365
推荐阅读
相关标签
  

闽ICP备14008679号