How to deploy Vue project under nginx

How to deploy Vue project under nginx

Today I will use the server nginx, and I also need to deploy my vue project to the server, so I will write it down.

First, go to the nginx official website to download nginx:

Download address: https://nginx.org/en/download.html

這里寫圖片描述

The downloaded file will be an unzipped package, unzip it to the folder you want to put it in

這里寫圖片描述

Run nginx.exe, then open the browser and enter localhost. If the following picture is displayed, it means success:

這里寫圖片描述

If it doesn't work, don't panic, it may be that your port is occupied by other content. Then you can open your nginx directory and find conf

這里寫圖片描述

Click in and find a nginx.conf file

這里寫圖片描述

Then open it with an editor, and find the server's listen, which is your port number. The default is port 80. You can rewrite it according to your own unoccupied port. After rewriting, save it and open your localhost: the port number you rewrote is OK.

 server {
      listen 8088;
      server_name localhost;

      #charset koi8-r;

      #access_log logs/host.access.log main;

      location / {
        root html;
        index index.html index.htm;
    } 

這里寫圖片描述

The above is the method to install and configure the nginx server. The following are the steps on how to deploy your own vue project to the nginx server you installed and configured:

First find your own vue project and enter the command npm run build. It will generate a dist folder in your vue directory, which contains your vue project.

這里寫圖片描述

Then open the dist folder and copy the contents. There will be two files in it, one is index.html which is the main directory and the other is the static folder.

這里寫圖片描述

Copy them and open the html file in your nginx directory. There will be two default files. Delete them directly and paste the files you just copied into them.

這里寫圖片描述

Then open the browser and enter the port number you changed at the beginning: localhost: the port number you changed, press Enter; you will see your Vue project running. Mine is like this:

這里寫圖片描述

That's it. ~ ~~~~

The above is the full content of this article. I hope it will be helpful for everyone’s study. I also hope that everyone will support 123WORDPRESS.COM.

You may also be interested in:
  • How to deploy Vue project on nginx (history mode)
  • How to deploy multiple Vue projects under the same domain name using nginx and use reverse proxy
  • Solution to the problem of not finding js css files when deploying vue project with nginx
  • Solve the problem of refreshing blank when deploying Vue project nginx to non-root directory
  • Implementation of deploying vue project to nginx/tomcat server
  • Vue.js project nginx deployment tutorial
  • How to solve the problem that CSS style does not take effect when Vue is packaged and deployed to Nginx
  • The server uses Nginx to deploy the Vue project

<<:  Four practical tips for JavaScript string operations

>>:  Learn the principles and common operations of MySQL partition tables through examples

Recommend

Development details of Vue3 components

Table of contents 1. Introduction 2. Component De...

Detailed explanation of Vue's live broadcast function

Recently, the company happened to be doing live b...

IE8 provides a good experience: Activities

Today I had a sneak peek at IE8 beta 1 (hereafter...

How to configure Hexo and GitHub to bind a custom domain name under Windows 10

Hexo binds a custom domain name to GitHub under W...

Implementing circular scrolling list function based on Vue

Note: You need to give the parent container a hei...

How to allow remote connection in MySql

How to allow remote connection in MySql To achiev...

js to achieve simulated shopping mall case

Friends who are learning HTML, CSS and JS front-e...

Install mysql5.7.17 using RPM under Linux

The installation method of MySQL5.7 rpm under Lin...

MySQL index knowledge summary

The establishment of MySQL index is very importan...

Detailed tutorial on MySql installation and uninstallation

This article shares the tutorial of MySql install...

How to install jupyter in docker on centos and open ports

Table of contents Install jupyter Docker port map...

Pure CSS and Flutter realize breathing light effect respectively (example code)

Last time, a very studious fan asked if it was po...