Initial experience of deploying a project to a server

I actually learned some node.js when I was in school, but I gave it all back to the teacher. After going to the front end, I had to pick up Node. A year ago, the architect asked me to deploy the project. Finally, with the help of my colleagues, I used nginx reverse proxy to deploy it. This time, due to the requirements of the project and the fact that I really wanted to learn about deployment, my colleague gave me a small update of deployment. After a wave of silent thanks, I found that I was often defeated by my inner fear rather than a rusty concept.

Writing in the front

Before completely had no contact with the server, the concept of the server is also a little understanding, so this article is suitable for and I like the small rookie watch, hope big guy don’t laugh. First of all, what exactly is a server?

The server

Officially, servers fall into two categories: application servers, which focus on dynamic resources and parse code. Front-end services are generally built based on node.js, a parsing JS language. Common ones are Tomcat, Apache,express, and so on. Another category is gateway servers, which focus on static resources, proxy forwarding, load balancing, and so on. Such as Nginx, etc.

My understanding of a server is a computer that can be accessed remotely, or even a host, or a virtual machine on a computer. When we use it, it’s just like when we use our own computers.

Logging In to the Server

The company uses a cloud server, Linux system (learning a wave of basic Linux operations) first applied for a permission, using the key to log in. Enter on the command line

SSH name @ addressCopy the code

Or use visual software to log in. I use Xshell, which I think XFTP is very convenient when uploading files. Software operation is not troublesome, create a connection, enter the address and port number, the default is 22, choose password or key mode. The connection is OK.

Find the XFTP flag to transfer files between the local and server.

Packaged deployment

This project was built using VUE, and the NPM run build package project was directly executed. Generate the DIST file after packaging. Write a simple Express to deploy the project using Node.js.

const express = require('express')
const path = require('path')
const app = express()
app.use(express.static(path.join(__dirname, 'dist')))
app.listen(8080 () => {
  console.log('app listening on port 8080')})Copy the code

Put dist folder and app.js in the same directory on the server, execute Node app.js and open ‘server address’ : 8080 in the browser to access our project successfully.

conclusion

A relatively rough novice deployment process, business is not skilled, but also need to practice more after the ~