preface

In the first contact, I VPS host, virtual host, cloud server and other terms are really a face meng, in order to let the later contact of the people less take some detdetments, but also to make some notes for themselves, also appeared this article. This article covers learning about servers > choosing a server > buying a server > using a server > deploying a project. The first half of this article is mainly to distinguish between different servers. If you simply need to understand the operation, you can start by purchasing a server. I hope you have a good harvest!

Understanding the Server

The basic concept

Servers are usually divided into independent servers (physical servers), VPS hosts, virtual hosts, and cloud servers. At the same time, whether virtual host, VPS host or cloud server, its essence is a computer, they are composed of operating system and server resources.

VPS host

A VPS host is a physical server divided into multiple operating systems using virtualization technology. Each VPS can be allocated with independent public IP addresses, independent operating systems, independent large space, independent memory, independent CPU resources, independent execution programs, and independent system configuration, and has great autonomy. It has an exclusive share of operating system and server resources (a VPS resource).


Virtual host

Compared to VPS host, multiple virtual hosts share an operating system and server resources, it can be said that multiple users share a VPS resource. At the same time ali cloud virtual host is divided into two kinds. Shared virtual host and exclusive virtual host, their main difference is different IP, shared virtual host is shared IP and exclusive virtual host is exclusive IP.

VMS with shared IP addresses can be classified into VMS with independent IP addresses. The differences are as follows:

  • Security, site collection: shared IP because many sites share an IP, so if the site is often attacked by hackers or SEO bad will affect other sites. Standalone IP does not have this problem.
  • Access: VMS with independent IP addresses can be accessed using IP addresses and domain names, but VMS with shared IP addresses can be accessed using domain names only.

Cloud server

Cloud server is the resource pool of server cluster (multiple physical servers) using virtualization to achieve, in other words, the integration of computer resources together, make it in the form of on-demand, at this time you can freely apply for resources and release resources. This is why cloud server resources can be scaled flexibly.

Common cloud servers:

  • ECS Ali Cloud server
  • CVM Tencent cloud server
  • BCC Baidu Intelligent Cloud

Note: if the VPS mother server is out of order, it means that all the virtual hosts in it are also out of order, belonging to the loss of all. While the cloud server cluster a server problem, there are image files, there will be no interruption.

Server development

  • At the beginning, servers are physical servers, but due to the need to purchase hardware, wiring, network Settings, etc., its cost is too high, but the final hardware utilization rate is not high.
  • In order to improve the utilization of physical servers and reduce costs, so VPS came into being. When virtualization is used to virtualize the operating system of a physical server into multiple independent operating systems, these independent operating systems are called VPS. Virtualization is an abstraction layer that separates the physical hardware from the operating system to provide higher IT resource utilization and flexibility.
  • Although there is virtualization technology, but users need to install their own operating system and environment when using the server, very time-consuming and laborious, so there is a virtual host. Virtual host is actually multiple users have a common set of configured environment (PHP + MySQL, etc.) operating system. Users can use the generated system directly, but it is limited by the primary server system and by other virtual hosts preempting resources.
    • Now add a user, for example, the virtual host management procedures set directly in the path to create a new folder, create a child in the database, database, user page code via FTP and transferred to the new folder, and the data into the new database, the site has been done. After the domain name is resolved, it can be used directly. Simple and fast, but because it is shared with others in a set of environment, freedom is not high, more restrictions, so when many people share its performance is very general.
  • Cloud services have emerged in order to integrate computer resources into a pay-as-you-go, pay-as-you-go format. Cloud computing is the collection of a large number of servers, networks, and storage resources into a large cluster. When needed, the resources are allocated from the pile and released after use.

The basic concept

Virtual host

Virtual host is also known as virtual server, it is the use of virtual technology will be a physical server or VPS host divided into many “virtual” servers. All virtual hosts are independent of each other, with their own IP, memory, CPU, document storage space, etc. In the outside world, virtual host is equivalent to an independent host, so this virtualized logical host is called “virtual host”.

  • advantages
    • Convenient management: Because all virtual hosts are in the same host, they can share the same configuration and Settings with each other, thus saving management manpower and cost
    • Cost reduction: the emergence of virtual host greatly reduced the cost of building physical host, due to multiple virtual host users jointly bear the physical host hardware maintenance, network maintenance, communication maintenance, so the cost has a certain degree of reduction.
    • Low cost: Software configuration, antivirus, anti-attack and other security measures are provided by professional service providers, greatly reducing the complexity of operation. Web hosting basically eliminates the need to manage and maintain your host; Internet providers do most of the administration.
  • disadvantages
    • Poor autonomy: virtual host can not be installed by customers at will software and remote operation.
    • Function, traffic limitation: some functions will be limited by service providers, while some service providers have certain restrictions on the flow of the website, so that when the site is relatively large, it will not be able to access.
    • Resource grab: Because there are many virtual hosts sharing server resources on the server, if other virtual hosts perform some operations to occupy traffic and bandwidth, it is likely to affect other users.

Cloud Server (ECS)

The standard definition of Elastic Compute Service (ECS) is a simple, efficient, secure, and scalable computing Service. Its management mode is simpler and more efficient than physical servers. Cloud host is the virtualization of multiple physical server resources, which means good disaster recovery capability and scalability, with independent broadband and IP, users can install various operating systems and configure the corresponding running environment according to their own requirements, and can upgrade and degrade its functions according to their own requirements.

  • advantages
    • Quick deployment: The language and system type can be configured during initialization.
    • Security: The platform provides free DDoS protection, Trojan horse detection and killing, and violence prevention services.
    • Strong disaster recovery: The cloud server has automatic recovery and live migration capabilities. Therefore, even if a hardware failure or fire occurs, the cloud server can quickly migrate data and continue to use the cloud server.
    • Elastic expansion: Cloud server users can configure CPUS, memory, and bandwidth based on service loads. Data will not be lost after the configuration is upgraded.
  • disadvantages
    • High starting cost: need to have professional ability of personnel management.

    • Network dependent, unlike physical servers where data is stored locally.

Since I was learning how to configure Nginx, I finally chose Ali’s cloud server ECS.

NginxWhat is?

Nginx is a lightweight HTTP server with an event-driven asynchronous non-blocking processing framework, which gives it excellent IO performance and is often used for server-side reverse proxies and load balancing.

NginxNode.jsThe relationship of language:

Node.js can implement most of the functionality in Nginx, but they can be used together for better results because of their different focuses. Node.js is good at the processing of specific business logic, while Nginx is good at the processing of underlying server resources, such as static resource forwarding, direction proxy, load balancing, etc.

Forward agent

The kexue web tool we usually use is the forward proxy, which can proxy the user’s request to a server that can access the external network, and then return the information back to the customer. The proxy server is opaque to the user, who needs to manually select the proxy.

The reverse proxy

In large web pages, most use reverse proxies. When a client requests data from a server. The request is actually made to the proxy server, and then forwarded by the proxy server to its local area network server. In other words, a unified Proxy portal is provided for external clients. All requests of clients go through the Proxy server first, and the Proxy controls which server content they really access on the Intranet.

The reverse proxy is transparent to users.

In this case, the direction of the forward proxy is the client proxy and the reverse proxy is the server proxyNginxIs to act as this Proxy.

Reasons for using a reverse proxy are as follows:

1. Security and permissions: Some unauthorized or insecure requests can be filtered through Nginx. It also improves security because users cannot access the real server directly.

2. Load balancing: When there are multiple servers, you can use Nginx to balance the load. Nginx checks whether the server is abnormal and does not send requests to the server until the server recovers. Requests are also distributed to the servers. This ensures the security and stability of the server.

Basic Concepts:

  • Region and availability: refers to the physical location of the ECS instance.

  • Example: A VM that contains basic computing components such as cpus, memory, operating system, network, and disks.

  • Instance specification: indicates the configuration of the instance, including the number of vCPU cores, memory, and network performance. Instance specifications determine the computing and storage capabilities of ECS instances.

  • Image: a template used to run an ECS instance, including the operating system and pre-installed software. The operating system supports multiple Linux distributions and different versions of Windows.

  • Block storage: includes cloud disks, shared block storage based on the distributed storage architecture, and local storage based on local disks on physical servers.

  • Snapshot: indicates the data backup of an elastic block at a point in time.

  • Network type:

  • Private network: An isolated network environment based on the Ari Cloud. Private networks are logically isolated from each other. For more information, see Private Network VPC.

  • Classic network: uniformly deployed in aliyun public foundation, aliyun is responsible for planning and management.

  • Security group: a virtual firewall consisting of trusted instances that have the same protection requirements in the same area. It is used to set network access control for the instance.

Mirror selection:

The public image

It is the basic system image provided by ali Cloud official or third-party cooperative merchants, including only the initial system environment. Configure the application environment or related software based on your actual situation.

Custom mirror

Generated based on user system snapshots, including the initial system environment, application environment, and related software configuration. Select a custom image to create a cloud server, saving the time of repeated configuration.

Sharing the mirror

It is a custom mirror of another account that is actively shared to you. Ali Cloud does not guarantee the integrity and security of the images shared by other accounts. Learn more about a Shared image >

Mirror market

It provides a high-quality image that has been strictly reviewed and is preinstalled with the operating system, application environment, and various software. It does not require configuration and can be deployed with a cloud server. Meet the personalized needs of website construction/application development/visual management. Learn about Mirror Market Services

CentOS and Ubuntu are the two main distributions of Linux.

CentOS

Ubuntu

Based on Red Hat Linux Enterprise Based on the Debian
Update frequency is low Updated frequently
It’s more stable and secure because it’s not updated as often. May the updated software package be unstable or insecure? No, because they did a lot of testing before releasing to the official version.
Not enough tutorials and a small user base (LCTT) Rich documentation, an active community and plenty of online tutorials
Difficult for beginners, because Red Hat-based desktop distributions are not popular Easier to use for beginners already familiar with the desktop version of Ubuntu
Support the cPanel Do not support the cPanel
RPM package and “yum” package manager Deb package and “apt-get” package manager

Novice: More suitable for useUbuntu.

1. Thanks to his strong community, many problems can be solved immediately

2.Ubuntu servers will be much easier for people who have used Ubuntu desktops before. Other distributions are the same, but the Ubuntu desktop version is more popular than any other Linux-based home desktop.

Commercial: useCentos

1.CentOS is more stable and secure. Due to the low update frequency and long test time, there are few bugs.

2. Most control panels (including the most popular control panel – cPanel) only support CentOS. It is better to choose Centos if you need control panel.

Buying a server

The purchase of cloud server ECS can be divided into one-click purchase and customized purchase according to your specific needs.

  • One-click purchase: There are specific recommendations and templates

Custom purchase

Use the wizard to create the instance

Learning path

Using the path

Create the instance and do the rest

First, enter the ECS console and connect according to the steps in the figure. Finally, the remote login account is root and the password is the server password.

Note: Passwords must be complex or they can be easily hacked. Then save all relevant account passwords so they don’t get lost. When connecting to a remote server, I use xShell. The login state can be automatically saved during login.

Connect the instance using XShell

Xshell + Xftp personal version download address, enter the name and email can get download link download.

Create a session and enter the public IP address in the instance.

Access port 22 must be allowed in the security group.

The installationNginx

Nginx.org is the open source community that manages the Nginx Open Source edition.

Nginx.com is the business community that manages the Nginx Plus Business edition.

Here we use the open source Nginx official website

Use Xshell to enter the account password to enter the interface, directly according to the official website, operation.

Installation environment

sudo apt install curl gnupg2 ca-certificates lsb-release
Copy the code

Set up theNginxApt repository

echo "deb http://nginx.org/packages/ubuntu `lsb_release -cs` nginx" \
    | sudo tee /etc/apt/sources.list.d/nginx.list
Copy the code

The installationNginx

sudo apt update
sudo apt install nginx
Copy the code

The commonly usedLinuxThe command

cdPath / / into the file ps - ax | grep nginx / / view contained in the running process of nginxkillPort number // The port number can be found in the previous commandkillDelete the process mkdir dirName1 dirName2 // Create a folder ls // View the current directory ll // View the current directory and its permissions rm -rf path // Forcibly deleting path fails to recover rm path // Delete path file cp dirName To exit and save, press Esc and enter: wq cat // to view the folderCopy the code

Common Linux commands are sorted

Initial configuration

Ll // View the current directoryCopy the code

cd. // Go to the next layer (top layer) ll // check the current directoryCopy the code

cd/etc/nginx // Go to the nginx directory ll // and check the directoryCopy the code

Vim nginx.conf // Edit the configuration file I // Enter editing modeCopy the code

Esc // Exit the editing mode: wq // Save the current editing mode // Restart the file to take effectCopy the code

Restart the

Method 1:

Ps - ax | grep nginx / / view contains nginx process in the process of runningkillPort number // Nginx can be queriedCopy the code

Method 2:

nginx -sReload // Restart the serverCopy the code

Nginx command

Nginx directly open the quit nginx - s save after exit stop directly exit nginx nginx - s - s reload directly after the modification of configuration items update # can cooperate with ps - ax | grep nginx to view the current nginx ports usedCopy the code

Enter the IP address of your server to take you directly to the Welcome Nginx page! This is because the configuration item by default references all configuration files in the /conf.d directory.

If not, comment it out. Do it yourself in the nginx.conf file

The specific operational

The configuration,

The basic configuration

Server {# nginx listen 80; # nginx bind domain name server_name localhost; # public static resource location / {index index.html; root /project/airport_pc; # autoindex on where the item is to be placed; # enable directory index}}Copy the code

In the project

Download winSCP or Xftp and log in

Package the Vue into the dist file and put it in the previous configuration location (previously configured /project/ airport_PC)

Open the Gzip

“Simple Performance Tuning” dual-end Gzip guide

All configuration

// etc/nginx# vim nginx.conf file default_type application/octet-stream; D directory. # Load modular configuration files from the /etc/nginx/conf.d directory http://nginx.org/en/docs/ngx_core_module.html#include # for more information. # include /etc/nginx/conf.d/*.conf; gzip on; gzip_comp_level 6; gzip_types text/plain application/javascript application/x-javascript text/css text/javascript ; gzip_static on; gzip_vary on; gzip_buffers 2 4k; Gzip_http_version 1.1; Server {# nginx listen 80; # nginx bind domain name server_name localhost; # public static resource location / {index index.html; root /project/airport_pc/; autoindex on; Add_header cache-control max-age=360000; add_header cache-control max-age=360000; }}}Copy the code

Note:

The difference between the overseas server and the domestic server is mainly that the domestic server needs to record, and the main visitors are Chinese.

If you need to change the server, you do not need to re-record the domain name. You only need to resolve the domain name to the new server.

After the registration is complete, if you want to use another domain name to resolve the DNS server, you cannot directly access the DNS server through the domain name. In this case, you need to re-register the DNS server.

conclusion

It’s finally over! This article is mainly a summary, there are contradictions and duplication of online information, if found errors, welcome to point out!

If it works for you, give it a thumbs up and leave!

Nginx advanced can see Nginx and front-end development, Nginx from the beginning to practice, a thousand words of detailed explanation!

Reference Documents:

  1. Aliyun — Overview of getting started
  2. Ali Cloud – what is cloud server ECS
  3. VPS, cloud server (cloud host), virtual host what are the similarities and differences?
  4. VPS and virtual host difference (need KX Internet access)
  5. CentOS or Ubuntu: Which is better for a server?
  6. The configuration,
  7. Nginx website
  8. Common Linux commands are sorted
  9. “Simple Performance Tuning” dual-end Gzip guideNginx and front-end development
  10. Nginx and front-end development