How to deploy vue project on linux

Installation of nginx prelude

Installation depends

    yum -y install gcc zlib zlib-devel pcre-devel openssl openssl-devel  
Create a folder
    cd /usr/local  

    mkdir nginx  

    cd nginx  
Download Nginx tar pack and unpack
     wget http://nginx.org/download/nginx-1.13.7.tar.gz  tar -xvf nginx-1.13.7.tar.g

Install nginx

Enter nginx directory
    cd /usr/local/nginx
Excuting an order
    ./configure
Make the installation command (you can first view the current command is not supported make make -v)
    yum -y install gcc automake autoconf libtool make
Run make install command to install nginx
    make && make install  

Well, if there is access to the current IP page display case then nginx is installed successfully

Now start setting Nginx configuration file

Nginx configuration file path /user/local/nginx/conf/nginx.conf

In a new server inside
location / {
              alias  /home/wwwroot/default/dist/; #默认访问vue静态文件目录(dist路径)
              index  index.html; #默认访问文件
              try_files $uri $uri/ /index.html; #目录不存在则执行index.html
          }

As still do not know if you see it below! Two important places marked ** is to configure a static read vue project file path (this is all Nginx configuration file)

    server
    {
        listen 80 default_server reuseport;
        include enable-php.conf;
 **     location / {
          alias  /home/wwwroot/default/dist/; #默认访问目录
          index  index.html; #默认访问文件
          try_files $uri $uri/ /index.html; #目录不存在则执行index.html
     }

    location /nginx_status
    {
        stub_status on;
        access_log   off;
    }

    location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$
    {
        expires      30d;
    }

    location ~ .*\.(js|css)?$
    {
        expires      12h;
    }

    location ~ /.well-known {
        allow all;
    }

    location ~ /\.
    {
        deny all;
    }

Guess you like

Origin www.cnblogs.com/zhonglinke/p/11906211.html