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

Detailed explanation of Javascript basics loop

Table of contents cycle for for-in for-of while d...

React Hook usage examples (6 common hooks)

1. useState: Let functional components have state...

Copy and paste is the enemy of packaging

Before talking about OO, design patterns, and the ...

18 killer JavaScript one-liners

Preface JavaScript continues to grow and prosper ...

21 MySQL standardization and optimization best practices!

Preface Every good habit is a treasure. This arti...

Markup Language - Title

Click here to return to the 123WORDPRESS.COM HTML ...

How to create and run a Django project in Ubuntu 16.04 under Python 3

Step 1: Create a Django project Open the terminal...

Nginx improves access speed based on gzip compression

1. Why does nginx use gzip? 1. The role of compre...

How to install Nginx and configure multiple domain names

Nginx Installation CentOS 6.x yum does not have n...

JavaScript setinterval delay one second solution

When using setinterval, it is found that it will ...

Things to note when migrating MySQL to 8.0 (summary)

Password Mode PDO::__construct(): The server requ...

Learn asynchronous programming in nodejs in one article

Table of Contents Introduction Synchronous Asynch...

HTML page jump code

Save the following code as the default homepage fi...