New server configuration environment

The general idea of ​​this chapter is:

 

1. Connect to the server remotely

For direct remote connection, the part before @ is the name of the directory you want to connect to, and the part after @ is the public IP of the server.

ssh [email protected] 

Remotely connect to different ports of the server

-p followed by the port name

ssh [email protected] -p xxxx

Then enter the password and that's it.

2. Create a sub-user

Because the permissions of the root directory are too large and there are many configuration files, developing in sub-users will avoid some problems.

2.1 Create a user

First enter the root directory, enter the command, XXX is the name you gave the user.

adduser XXX

2.2 Assign sudo permissions

Because using some commands in the sub-user requires sudo authority, the sub-user must enter the password every time when using it. In order to avoid entering the password every time, the sub-user can be added to the user group of the root directory. Enter the following commands. XXX is the name of the user who needs to assign permissions.

usermod -aG sudo XXX

3 Configure the working environment

3.1 The old configuration is transferred over

        When you get a new server, you can pull over the previously used server configuration file to ensure smooth use. Maybe everyone's habits are different. There are many configuration files on the Internet, you can find them yourself. It was given by my yxc, and AcWing is the entry door.

        First, you need to enter the original server, and then transfer these three files to the new server. server_name is the alias after password-free login is set. If there is no password-free login, the format is [email protected] directory name@public network IP, and then enter the password.

scp .bashrc .vimrc .tmux.conf server_name:  

So far, the usage is exactly the same as before.

3.2 install tmux

        Tmux is an important tool in development. All work is carried out in tmux, which can prevent the loss of work progress after accidentally closing the terminal, and the installation is relatively simple.

        First, you need to enter your own server, and then enter the following command.

sudo apt-get update
sudo apt-get install tmux

3.3 Configure docker environment

3.3.1 Install docker

Enter the official website:  Install Docker Engine on Ubuntu | Docker Documentation

Just follow the tutorial and just copy the commands one by one.

 Then enter the command to check the docker version. Basically, as long as you can check the version, the installation is successful.

docker --version

3.3.2 Mirror preparation

Package your previous docker into a tar file, then transfer it from the original server to the sub-user of the new server, and load it locally.

XX represents the image file name, server_name is the password-free login alias, if there is no password-free login, the format is [email protected] directory name@public network IP, and then enter the password.

scp /XX.tar server_name:

scp /var/lib/acwing/docker/images/docker_lesson_1_0.tar server_name: //AcWing image

3.3.3 Load the image locally and set the container password

         First enter your own server sub-user to load the image locally. xxx image file name.

docker load -i xxx.tar

docker load -i docker_lesson_1_0.tar //AcWing image

Then there is creating and running the image. xxx is the name you give the image, -itd is the image information you just loaded locally, yyy is the name of the image loaded locally, and zz is equivalent to the version number.

docker run -p 20000:22 --name xxx -itd yyy:z.z

docker run -p 20000:22 --name my_docker_server -itd docker_lesson:1.0//AcWing镜像

Then it is to enter its own container XXX.

docker attach XXX

The last thing is to set a password for the root directory of your container. After entering the command, enter the password as required.

passwd

At this point, your container is equivalent to a new server, and then create a sub-user in your container, because the container has only one root directory at this time, and the permissions are relatively large. The steps are the same as before, refer to the above.

According to the above steps, you can go on infinitely in the container, tsk tsk. But that's basically enough.

Guess you like

Origin blog.csdn.net/qq_64468032/article/details/131552467