Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to deploy a Vue project using Nginx

2025-04-01 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)05/31 Report--

This article mainly explains "how to use Nginx to deploy Vue project", interested friends may wish to take a look. The method introduced in this paper is simple, fast and practical. Let's let Xiaobian take you to learn "How to use Nginx to deploy Vue project"!

First, install Nginx

1. Connect to our servers using XShell

2. Configure EPEL Source

sudo yum install -y epel-releasesudo yum -y update

3. install Nginx

sudo yum install -y nginx

Here are some things to remember, especially configuration files.

After successful installation, the default website directory is: /usr/share/nginx/html

The default configuration file is/etc/nginx/nginx.conf

4. Open ports 80 and 443.

If you open the firewall first.

systemctl start firewalld.service

Restart firewall: firewall-cmd --reload

View firewall status firewall-cmd --state

systemtl stop firewall.service

Open port firewall-cmd --add-port=8890/tcp --permanent (replace 8890 with the port to be opened)

Open 80 and 443 firewall-cmd--permanent --zone=public --add-service=httpfirewall-cmd --permanent --zone=public --add-service=https

After opening, remember to restart the firewall 5. Server open port numbers 80 and 443

Open Server, click Firewall, then click Add Rule

Just add what we need to the port range, here we add 80 and 443

6. Nginx Basic Command

Start: systemctl start nginx

Restart: systemctl restart nginx

Close: systemctl stop nginx

View status: systemctl status nginx

Start automatic startup: systemctl enable nginx

Turn off automatic startup: systemctl disable nginx

7. Verify successful installation

Enter the IP address of the server in the computer browser, and welcome to nginx will represent success, then you can take the next step.

II. Deployment of VUE

1. Package vue project

npm run build //this depends on the situation if it is version then according to the situation

2. uploaded to the server

We put this in the/usr/local/webapp folder here

We can upload using xftp

3. nginx configuration

Run vim /etc/nginx/nginx.conf to enter the configuration file

So our VUE deployment is complete.

Remember to restart nginx

4. test

Enter the IP address of our server in the browser and add the port number.

If it is another port, then consider whether the server and Alibaba Cloud have opened the port number

At this point, I believe that everyone has a deeper understanding of "how to use Nginx to deploy Vue projects", so let's actually operate it! Here is the website, more related content can enter the relevant channels for inquiry, pay attention to us, continue to learn!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 238

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report