liunx系统下安装部署nginx 及配置前端项目的部署发布

准备目录

[root@instance-3lm099to ~]# mkdir /usr/local/nginx
[root@instance-3lm099to ~]# cd /usr/local/nginx/

添加添加准备内容

[root@instance-3lm099to nginx-1.14.0]# yum -y install gcc gcc-c++ autoconf automake make
[root@instance-3lm099to nginx-1.14.0]# yum -y install openssl openssl-devel

下载

从http://nginx.org/download/上下载相应的版本(或者wget http://nginx.org/download/nginx-1.5.9.tar.gz直接在Linux上用命令下载)

解压

解压 tar -zxvf nginx-1.5.9.tar.gz 

解压好后移至目录

[root@instance-3lm099to nginx]# cd nginx-1.5.9/

设置Nginx安装路径,如果没有指定,默认为/usr/local/nginx

[root@instance-3lm099to nginx-1.14.0]# ./configure --prefix=/usr/local/nginx

编译

make (make的过程是把各种语言写的源码文件,变成可执行文件和各种库文件)

[root@instance-3lm099to nginx-1.14.0]# make

安装

make install  (make install是把这些编译出来的可执行文件和库文件复制到合适的地方)

[root@instance-3lm099to nginx-1.14.0]# make install

启动

参数 -c 指定了配置文件的路径,如果不加的话就是使用默认的配置文件

[root@instance-3lm099to nginx-1.14.0]# /usr/local/nginx/sbin/nginx -c /usr/local/nginx/conf/nginx.conf

 

-------------------------------------以下是关于项目在nginx中的配置-------------------------------------

配置文件内容(只展示中server中重要部分,其他相关配置查询官网)     nginx.conf 

server {
    #监听的端口 也就是浏览器要访问的端口
        listen       80;
        server_name  localhost;

        #charset koi8-r;

        #access_log  logs/host.access.log  main;

     # / 后面可以加项目名 也就是浏览器访问的端口后面直接跟的项目名
        location / {
        #前端代码的位置 可以直接将html文件放入到 nginx下面的html中 也可以指定路径  如 \data\qianduan
            root   html;
            index  index.html index.htm;
       #/index.html 项目的首页地址,前面需要加上自己的文件名 \data\qianduan\ 下的项目名+首页文件所在的路径
        try_files $uri $uri/ /index.html
       }

  

------------------------------------------个人笔记,仅供参考---------------------------------------------------
https://www.cnblogs.com/shamo89/p/7645792.html
posted @ 2020-10-14 18:49  二小子  阅读(335)  评论(0)    收藏  举报