前端部署

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/zly145236/article/details/83756209

准备工作:

1 要有一个域名,一级 或  二级域名

2 解析域名

 3 上传到服务器,静态资源文件放到自己要放的路径

 4  修改nginx文件内容(重点)

server {
                listen 80;
                large_client_header_buffers 4 16k;
                server_name www.xxxxxx.cn;    //自己申请的域名
                rewrite ^(.*) https://$server_name$1 permanent;
        }
    upstream manage_api {
                server localhost:8083;   //要调的后端服务器跟端口号
    }

    server {
        listen       443 ssl;
        server_name  www.xxxxxx.cn;

        ssl_certificate      /usr/local/nginx/1_fc.fangcuntech.com_bundle.crt;//下载证书的路径
        ssl_certificate_key  /usr/local/nginx/2_fc.fangcuntech.com.key;//下载证书的路径
                ssl on;
        ssl_session_timeout 5m;
        ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:ECDHE:ECDH:AES:HIGH:!NULL:!aNULL:!MD5:!ADH:!RC4;
        ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
        ssl_prefer_server_ciphers on;

        root   /usr/local/etc/group/dist;  //前端资源要放的文件
        index index.html;

        error_page 500 502 503 504 /50x.html;
        location = /50x.html {
            root html;
        }

        location / {
            try_files $uri $uri/ @router;
            index  index.html index.htm;
        }

        location /manage {
            proxy_pass http://manage_api;  //后端要调用的服务器地址
        }

        location @router {
            rewrite ^.*$ /index.html last;
        }
    }

5 要下载ssl证书  放到自定义路径下

================================================================================================

修改nginx时用到的命令

  • vi  /  vim  编辑
  • esc 退出
  • :wq  保存退出
  •  启动 Nginx   poechant@ubuntu:sudo ./sbin/nginx

  • 停止 Nginx    1 sudo ./sbin/nginx -s stop     2 sudo ./sbin/nginx -s quit     (-s都是采用向 Nginx 发送信号的方式)

  •  Nginx 重载配置   

  1.    sudo ./sbin/nginx -s reload

  2. service nginx reload上述是采用向 Nginx 发送信号的方式,或者使用:

  3.  指定配置文件    poechant@ubuntu:sudo ./sbin/nginx -c /usr/local/nginx/conf/nginx.conf

    -c表示configuration,指定配置文件。

  4. 查看 Nginx 版本

  5. 有两种可以查看 Nginx 的版本信息的参数。第一种如下:

    poechant@ubuntu:/usr/local/nginx$ ./sbin/nginx -v
    nginx: nginx version: nginx/1.0.0

    另一种显示的是详细的版本信息:

    poechant@ubuntu:/usr/local/nginx$ ./sbin/nginx -V
    nginx: nginx version: nginx/1.0.0
    nginx: built by gcc 4.3.3 (Ubuntu 4.3.3-5ubuntu4) 
    nginx: TLS SNI support enabled
    nginx: configure arguments: --with-http_ssl_module --with-openssl=/home/luming/openssl-1.0.0d/

    6. 检查配置文件是否正确

    poechant@ubuntu:/usr/local/nginx$ ./sbin/nginx -t
    nginx: [alert] could not open error log file: open() "/usr/local/nginx/logs/error.log" failed (13: Permission denied)
    nginx: the configuration file /usr/local/nginx/conf/nginx.conf syntax is ok
    2012/01/09 16:45:09 [emerg] 23898#0: open() "/usr/local/nginx/logs/nginx.pid" failed (13: Permission denied)
    nginx: configuration file /usr/local/nginx/conf/nginx.conf test failed

    如果出现如上的提示信息,表示没有访问错误日志文件和进程,可以sudo(super user do)一下:

    poerchant@ubuntu:/usr/local/nginx$ sudo ./sbin/nginx -t
    nginx: the configuration file /usr/local/nginx/conf/nginx.conf syntax is ok
    nginx: configuration file /usr/local/nginx/conf/nginx.conf test is successful

    如果显示如上,则表示配置文件正确。否则,会有相关提示。

    7. 显示帮助信息

    poechant@ubuntu:/user/local/nginx$ ./sbin/nginx -h

    或者:

    poechant@ubuntu:/user/local/nginx$ ./sbin/nginx -?

继续更新~

猜你喜欢

转载自blog.csdn.net/zly145236/article/details/83756209