Server environment construction (2): Rich operation commands for the server (please correct me if there are any mistakes, thank you)

        After the new server is installed, it is like a newborn baby with only some basic operation commands and cannot perform more complex operations. Therefore, it is necessary to enrich the operation commands of the server, that is, install various related commands.

        Here are a few key commands: yum and rpm. 

The following is an encyclopedia about the yum command .

Yum (full name Yellow dog Updater, Modified) is a shell front-end package manager in Fedora and RedHat and CentOS. Based on RPM package management, it can automatically download and install RPM packages from a specified server, automatically handle dependencies, and install all dependent packages at one time, without having to download and install tediously again and again .

The following is an encyclopedia about the rpm command .

RPM [1]  is the abbreviation of RPM Package Manager (RPM Package Manager). Although the name of this file format is marked with the RedHat logo, its original design concept is open, and now includes Linux such as OpenLinux, SuSE and Turbo Linux. The distribution version of the system is adopted, which can be regarded as a recognized industry standard. 

        (1) Installation file upload and download instructions: rz and sz

           Installation command: yum install lrzsz -y

            After the download is complete, enter the command rz to upload the file and sz to download the file.

        (2) Install the language pack, the installation command:      yum groupinstall "fonts".

          When the installation command is executed, it will first check whether there is a language pack. If it does not exist, it will prompt to download and unzip it.

        When prompted to enter (y/d/n), enter y to download.

        (3) To check whether the local language package is in accordance with the Chinese language, enter the following command:

         locale -a |grep "zh_CN"

        If the language pack is installed, you can see the following picture:

            

        (4) Install jdk 

        Download the required jdk version on the jdk official website, and the tar.gz ending needs to be installed in the linux environment. 

        Add a new java folder under the /usr directory folder using the command: mkdir /usr/java

        Upload the downloaded installation package to the server using the command rz . After uploading, use tar -zxvf (target file) to decompress, such as tar -zxvf 1111.tar.gz.

        After installation, you can set environment variables and add relevant configuration parameters to the /etc/profile file, as follows:

        #set java environment
        JAVA_HOME=/usr/java/jdk1.8
        JRE_HOME=/usr/java/jdk1.8/jre
        CLASS_PATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar:$JRE_HOME/lib
        PATH=$PATH:$JAVA_HOME/bin:$JRE_HOME/bin

        export JAVA_HOME JRE_HOME CLASS_PATH PATH    

        After configuration, use source /etc/profile to restart the file to make it take effect. Then use the command java -version to check whether the installation is successful. If you see the corresponding information, the installation is successful.

        (5) Install Tomcat server

        After downloading Tomcat, upload Tomcat to the directory where the server needs to be placed and decompress it. This step is basically the same as installing jdk, both need to download files in tar.gz format, the difference is that it can be placed anywhere we want.

        After installation, you can set up the Tomcat service. There is a file server.xml in the conf/ folder of the Tomcat directory, and the name is modified: the parameter of the connector. The default initial value is 8080, which can be modified to any desired value. After modification, use the source command to recompile the file.

        Execute ./startup.sh start; in the bin directory to start the server. After executing the command, you can use the command tail -300f ../logs/catalina.out to check whether the startup is successful. As shown in the figure: 8080 is the external access interface of this service, and you can see that the server starts successfully within 1211ms.


    (6) Check whether Tomcat is successfully installed

       Enter ip+port in the computer browser to access this server, such as: xx.xx.xx.xx:8080/ If the Tomcat management page appears, the installation is successful.

    (7) Modify firewall settings

        Some friends may find that all the work of their server has been completed, the inspection and installation of things have been successful, and the server has also been started, but they cannot be accessed.

        The reason is that each service will be blocked by a firewall for security, so it is necessary to close the firewall to allow the outside world to access, but after closing the firewall, the entire server is exposed to the outside world without protection, so it is recommended to open some specific ports to supply the outside world. Visit, here to demonstrate the development of port 8080.

        Since the Alibaba Cloud server used provides a management console, you can directly operate and modify it through the browser. Find your own instance in the console, click "More"--"Security Group Configuration"--"Set Security Rules": Clone an open port address, edit the type as Custom TCP, and fill in the one you want to open as required port can be. After the port is opened, access the file of the current port again, and find that you can access it, such as:


        

            The above method is to use the security group policy provided by Alibaba Cloud to set the firewall. The following describes the manual setting of the firewall.

          Step 1: Install iptables using the command  yum install iptables -services

         Step 2: Clear the original default rules  

        iptables -F clears the rules of all rule chains in the
        default table filter iptables -X clears the rules in the user-defined chain in the default table filter
        At this time, check the system settings iptables -L -n and you can see that there are no settings

        
        Save the above operation service iptables save and restart the firewall service iptables restart
        Then configure the firewall properties for the system:
        

Before installing  iptables, the system cannot use iptables related instructions, and will report uninstall information. After successful installation, you can use service iptables status to check the firewall status of the current system.


At this time, delete the security rules previously set in the Alibaba Cloud console, and access the port of the server again and find that it cannot be accessed.

 


Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325594855&siteId=291194637
Recommended