Speaking of doing an Ali server ECS configuration article is also because bought a server for several years, has not played well, the basic is to put some of their own Node project and VUE project display, today initialize the server, reconfigure some, incidentally make a novice notes for everyone reference

Server Configuration

This is my own server configuration, playing by myself is enough

ECS cloud server configuration and environment

  • Log in to aliyun server official website

  • In the left navigation tree, go to the console

  • Access the CLOUD server ECS

  • Enter the instance
Choose the server room you purchased at that timeCopy the code

  • management
- Stop (shutdown) - to switch the systemCopy the code

  • Go back to the instance and find more disks and mirrors. Replace the system disk

  • Public mirror (mirror is the same as me, otherwise it will be slightly different)
CentOS 7.2 64Copy the code
  • Set the password
- All letters + lowercase letters + numbers - try to make it as simple as possibleCopy the code

  • After the system is successfully started, all configurations are performed on the command line

Putty Connects to the ECS server

Software I uploaded to baidu network disk out of the box, less than 1M volume, of course, there are other software please baidu

  • IP
Public IP address of your serverCopy the code
  • port
22
Copy the code
  • Connection type
ssh
Copy the code
  • The login
- Generate key for first time - own PC yes - Public PC noCopy the code
  • The putty command line
- root - Password (password set when switching the system) - Enter the password without prompting - To enter the serverCopy the code

  • Remote connection (provided by aliyun official website)
The first one will pop up and let you record your password, which is very important, save it on your computer, and you'll use it a lotCopy the code

Node Environment Construction

Setting up a Node environment on a Windows PC is easy, as are servers

  • Download FileZilla
It is convenient to create directories and upload filesCopy the code
  • Log on to the site

  • Create a new file to manage
I've created a new tomato file for my configuration so I can find it myselfCopy the code
  • Open the putty cli
cd/ Go to the root directory ls to view the directorycdTomato/node/into the node of the tomato of the files that I just created folder wget https://nodejs.org/dist/v12.11.0/node-v12.11.0-linux-x64.tar.gz to download the node package tar XVF node-v12.11.0-linux-x64.tar.gz Decompress the node package rm -rf node-v12.11.0-linux-x64.tarcdNode-v12.11.0 -linux-x64/bin ls Check the directory and you will see node NPMCopy the code

Set global (environment variables), node and NPM commands can be run in any directory

ln -s/ tomato/node/node - v12.11.0 - Linux - x64 / bin/node/usr /local/bin/node
ln -s/ tomato/node/node - v12.11.0 - Linux - x64 / bin/NPM/usr /local/bin/npm
Copy the code

After the above configuration, you can run the Node and NPM commands in any directory

Upload projects using FileZilla

- Host - Public IP address - Port number - 22 - Protocol - SSH - Login type - Normal - Username - root - Password - Your passwordCopy the code

Write a JS, run it with Node, and access it via a public IP address. Here I write a simple interface fileCopy the code

http.js

const http = require('http')
const request = require('http').request
const fs = require('fs') // proxy cross-domain const fn = response => {const options = {host:"localhost",
        port: 4001,
        method: "get",
        path: "/"} const req = request(options, res => {// console.log(res);let data = {}
        res.setEncoding("utf8")
        res.on("data", (chunk) => {console.log(' body of the response:${chunk}`); // Assign data to the data requested by the third-party proxy data = chunk}) res.on("end", (chunk) => {response.write(data) response.end()})})"error", err => {
        console.log(err);
    })
    req.write("") req.end()} const server = http.createserver ((request, response) => { Responsetheader () : response.setheader ()"Access-Control-Allow-Origin"."*") // Sets the response header, the first parameter is the HTTP status code, and the second parameter is an object // Response.writehead (2010, {//"Content-Type": "text/pligin; charset=utf-8"Response.write () can be called many times // Response.write ()0 returns data to the client. The returned Chinese characters will be garbled, so we need to set response header // Response.write ("Return data to client ~~~"Response.write (request.url) // Request path // Response.write (request.method) // Request method // Response.write (json.stringify (request.headers)) // Request header information // Response.end ()"~~~ I am the data returned by response.end()") // End can also return data, which must be passed as a stringif (request.method === "GET") {
        response.writeHead(200, {
            "Content-Type": "text/html; charset=utf-8"
        })
        switch (request.url) {
            case "/":
                // response.write(fs.readFileSync(".. /demo/index.html"."utf8"Write (json.stringify ({a: 1, b: 2})) response.end()break;
            case "/home":
                //home
                fs.readFile(".. /demo/index.html"."utf8", (err, data) => {// asynchronously execute Response.write (data) response.end()})break
            case "/request": // Proxy cross-domain fn(response)break
            default:
                // 404
                response.write("< h1 > < h1 > 404 page")
                response.end()
                break; }} // response.end() // configuration request}) // Listen on port 6300 server.listen(6300, () => {console.log()"Service listening on port 6300.");
})
Copy the code

If you use the public IP address to access the IP address, you cannot access the IP address because no open port is available

Security groups open access ports

N/A Enter instance n/A Security group N/A Set rule N/A Add security rule N/A Protocol Type TCP-80/80-6000/9999-443/443 N/A Protocol type HTTP/HTTPS - 80/80 N/A Authorization type: Address segment access - Authorization object - 0.0.0.0/0Copy the code

Domain name binding server

  • Buy a domain name on Aliyun

  • Access the Node project from the domain name

Domain name needs to be recorded

Only need to enter the record area in accordance with the process operation, the official flow chart, you can record the success of the record time about the fastest need 15 days or so, slow words need a month through the record, can use the domain name to access the virtual host projectCopy the code

LAMP environment setup and configuration

Linux + Apache + mysql + PHP for a long time servers can use commands to operate the default is no graphical interface, but you can install its own Baidu graphical interface centOS graphical interfaceCopy the code

Documents from ali Cloud official forum can be configured according to this document

LAMP refers to Linux+Apache+MySQL/MariaDB+Perl/PHP/Python, which is a group of open source software commonly used to build dynamic websites or servers. They are separate programs in their own right, but because they are often used together, they are increasingly compatible and together form a powerful Web application platform.

Common commands

// ECS server cat /etc/redhat-release // View the system version systemctl status firewalld // View the current firewall status systemctl stop firewalld // After the firewall is disabled temporarily, ystemctl is enabled on the firewall after Linux is restarteddisableFirewalld // Permanently disable the firewall // Apache HTTPD -v // Check the Apache version systemctl start HTTPD // Start the Apache service systemctl restart HTTPD // Restart the Apache service systemctlenableHTTPD // Start the Apache server // MySQL systemctl start MySQL // Start MySQL systemctlenableSince the launch of the mysql / / boot mysql service mysqladmin -u root password / / modify the mysql root password mysql - uroot - p/login/mysql database \ q / / mysqlCopy the code

Ali Cloud ECS server coupon code /Coupon address

Cloud server ECS series related articles

Aliccloud server ECS configuration and LAMP environment construction and configuration (the first round of the beginner’s guide)

Jenkins automatic package deployment of VUE project in Aliccloud server configuration