Py学习  »  NGINX

Linux中在Nginx中发布项目 2020-08-29

驱风逐浪玩压缩 • 3 年前 • 222 次点击  

1.首先进入home文件夹下

cd /home/
  • 1

2.创建nginx-projects目录

mkdir nginx-projects
  • 1

3.点击ALT+P进入SFTP,将项目上传到Linux系统中(将web.zip是更改为自己的项目名,压缩包形式,注意zip格式的压缩包,切记要上传中文的,会有乱码问题)

put F:/web.zip
  • 1

4.回到CRT,将项目移动到home/nginx-projecst目录下

cd ~
mv web.zip /home/nginx-projects/
  • 1
  • 2

5.进入项目

cd /home/nginx-projects/
  • 1

6.解压项目

unzip web.zip
  • 1

7.修改Nginx配置文件

vi /home/nginx-1.17.5/conf/nginx.conf
  • 1

8.在打开的配置文件中找到如下代码

 server {
        listen       80;
        server_name  localhost;

        #charset koi8-r;

        #access_log  logs/host.access.log  main;

        location / {
            root   html;
            index  index.html index.htm;
        }
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12

9.将root 后面的html修改为自己文件的路径

server {
        listen       80;
        server_name  localhost;

        #charset koi8-r;

        #access_log  logs/host.access.log  main;

        location / {
------------------------------------------(修改此处)
            root   /home/nginx-projects/web;
------------------------------------------(注:此处横线是为了醒目)
            index  index.html index.htm;
        }
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14

10.进入/usr/local/nginx/sbin/中

cd /usr/local/nginx/sbin/
  • 1

11.如果Nginx已经启动了,需要先关闭nginx服务

./nginx -


    
s stop
  • 1

12.启动服务并加载配置文件

/usr/local/nginx/sbin/nginx -c /home/nginx-1.17.5/conf/nginx.conf
  • 1

13.浏览器打开网址,就可以看到自己的项目了

http://ip地址
  • 1
Python社区是高质量的Python/Django开发社区
本文地址:http://www.python88.com/topic/73019
 
222 次点击