From 0 to 60, the basic configuration of the web server

Table of contents

Why do you need a server

buy server

CPU and memory

positive

connect to the server

Pagoda panel

Anaconda

Open-JDK

nvm

pm2

open port

Why do you need a server

If you have a server of your own, you can deploy any legitimate web project. And based on the fact that the server can work around the clock, you can let it complete many tasks that cannot be done locally, such as complex cryptography experiments. If the computing power of the server is strong enough, such as a GPU server, many deep learning projects can be deployed. In short, a server is a computer that never shuts down, and stable service is its biggest advantage. In addition, if the server is from a foreign country, you can also ping Google, which of course cannot be pinged under normal local conditions.

buy server

In fact, there are roughly two types of servers, cloud servers and application servers. To put it simply, cloud servers serve larger projects and are relatively more expensive; application servers are lighter and suitable for personal use. There are many platforms where servers can be purchased, such as Alibaba Cloud, Tencent Cloud, Huawei Cloud, Azure, etc. Here we take Alibaba Cloud as an example to purchase a server and perform simple configuration.

Purchase link: Lightweight Application Server (aliyun.com)

CPU and memory

In addition to the price of the server, the configuration also has a great influence on the price. The configuration mentioned here includes the number of CPUs and memory size. Of course, the region also has a certain impact on the price.

  • First of all, it is recommended to choose an overseas region because it can ping Google;

  • It is recommended to buy two CPUs, because the more CPUs, the more processes that can be parallelized, the stronger the computing power, and the faster the response speed. When the price is not expensive, two cores are a better choice.

  • The recommended memory is 4G. The larger the memory, the more data can be cached and the faster the response speed. The same TS project has been stuck on a server with 2G memory, but it can run smoothly on a server with 4G memory.

A specific price reference table is as follows (location Singapore):

Just select the configuration you need and place an order. You can choose the image at will. If you are not satisfied, you can go to the console to reset the image later. But there is a principle, no matter what the image is, if there is no special requirement, try to choose a newer version.

After purchase, we need to enter the lightweight application server management console (aliyun.com) to check the server we purchased.

positive

connect to the server

The first choice for connecting to the server is xshell, which is the most classic and the best to use. I have collected many installation packages in the following network disk:

Link: Baidu Netdisk Please enter the extraction code Extraction code: 0505 --Share from super member V5 of Baidu Netdisk

After installation, open xshell, create a new connection, go to the console to copy the IP (public) of your server, and enter the firewall to ensure that port 22 is open.

Click OK, if it is the first connection, a md5 security fingerprint will appear, click accept and save. The user name is root by default, and the password is the server password. If you forget the server password, you can go directly to the console to reset the password and restart, which is very convenient.

After the connection is successful, you can perform any operation you want on the server!

Pagoda panel

Pagoda Panel is a web-based server visualization tool. It can help users build websites and manage servers more conveniently, saves a lot of command operations, and is friendly to novices . There is also a built-in application store, which can automatically install some necessary services and avoid many bad experiences in configuring servers. The pagoda panel also provides quick deployment of many web projects, and the regular version is open source and free, which can be said to be the best panel for servers.

But at the same time I want to say that if you are a Linux expert, you don't need these panels at all. Some of the services provided by Pagoda are not as good as their own command line operations, and there seem to be small bugs that cannot be opened after the update, but fortunately, the Pagoda panel operation and maintenance forum can solve most of the problems.

The installation command is as follows:

wget -O install.sh https://download.bt.cn/install/install-ubuntu_6.0.sh && sudo bash install.sh ed8484bec

Yes all the way to the end, the installation is successful as follows:

It can be seen here that the access port of the pagoda panel is 8888, the security entrance is e4b7c323, and the user name and password are as follows

外网面板地址: https://xx.xx.xx.xx:8888/e4b7c323
内网面板地址: https://xx.xx.xx.xx:8888/e4b7c323
username: ffgehzbl
password: b12c369c

It can be seen that the default port, security entrance, and account password are hard to remember, so we can enter the panel to change it, but if we want to enter the panel, we must first enter the firewall of the console and release the corresponding port.

After entering the browser, enter IP+访问端口/安全入口access panel. Enter the corresponding user name and password to successfully access the pagoda panel, then bind the account of the pagoda panel, and select the LNMP package on the left to install (30min~2h). Here we installed:

  • Nginx-1.22

  • mysql-5.7

  • pureftpd-1.0.49

  • php-7.4

  • phpmyadmin-5.2

This can be said to be a must-have server application. After installation, enter the panel settings to modify the security entrance, user name, and password of the pagoda panel. Be sure to keep the pagoda panel safe! Because if the pagoda panel is infiltrated, it will directly obtain most of the permissions of the server, which is very dangerous.

 

In order to further ensure security, it is also recommended to turn on the security alarm on the panel and bind the WeChat account.

Anaconda

Anaconda is a necessary version management tool for python project deployment. The installation steps are as follows:

wget -P /tmp https://repo.anaconda.com/archive/Anaconda3-2020.02-Linux-x86_64.sh
bash /tmp/Anaconda3-2020.02-Linux-x86_64.sh
// conda init的过程要选 y
source ~/.bashrc
export PATH=$PATH:/root/anaconda3/bin // 写入环境变量
conda update --all // 升级命令
conda -V // 检查版本

Then create some common python virtual environments:

conda create -n python11 python=3.11
conda create -n python38 python=3.8
conda activate 虚拟环境名字
conda deactivate // 退出虚拟环境

Open-JDK

apt search openjdk // 查找版本
sudo apt install openjdk-17-jdk // 也可以是其他版本
java --version

Version switching update-alternativesis implemented using .

sudo update-alternatives --display java

nvm

Nvm is a version management tool for nodejs and npm. The installation method is as follows:

git clone https://gitee.com/mirrors/nvm
cd nvm
bash install.sh
export NVM_DIR="$HOME/.nvm"
source ~/.bashrc
nvm --version

After that install some necessary node version and npm version:

nvm install 18.15.0
nvm use 18.15.0
node -v
npm -v
npm install pnpm -g // 推荐使用pnpm

pm2

pm2 is a nodejs-based process manager that can help us deploy python, Java, and node projects efficiently, and provide monitoring and load balancing services. The installation method is as follows:

npm install -g pm2
pm2 --version

The following blog introduces the common commands of pm2: Complete list of common commands of pm2 - marching snail - blog garden (cnblogs.com)

The recommended method is to write the project startup bash into a start.sh file, and execute the following command in the project root directory:

pm2 start start.sh

open port

firewall-cmd --zone=public --add-port=80/tcp --permanent // permanent永久生效
firewall-cmd --reload // 必须reload才能生效
firewall-cmd --zone=public --list-ports // 查看所有放开端口

After confirming that the port is released, go to the firewall of the Alibaba Cloud console and continue to open the relevant port to ensure that the form of IP+port can be accessed on the Internet.

Guess you like

Origin blog.csdn.net/qq_52504945/article/details/130434526
Recommended