Install jdk, redis, mysql and nginx on linux

1, jdk installation

  1. Download jdk:

    Official address: https://www.oracle.com/java/technologies/javase-downloads.html

  2. Unzip the downloaded package:

    #Use command:
    tar -zxvf jdk-8u291-linux-x64.tar.gz
    #To facilitate management after decompression:
    mv jdk-8u291-linux-x64/ /usr/core/jdk
    
    #I like to use core as a common (core) and immovable directory package
    
  3. Path configuration

    Use the command: vi /etc/profile
    Add at the end of the file:

    export JAVA_HOME=/usr/jdk8
    export CLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar
    export PATH=$JAVA_HOME/bin:$PATH
    export JRE_HOME=/usr/jdk8/jre
    
  4. Reload and test:

    Reload the configuration file with the command: source /etc/profile,
    Test command: java -version
    If the following information is displayed, the installation is successful

    [root@yomsz /]# java -version
    java version "1.8.0_291"
    Java(TM) SE Runtime Environment (build 1.8.0_291-b10)
    Java HotSpot(TM) 64-Bit Server VM (build 25.291-b10, mixed mode)
    

2, nginx installation

  1. Download ngingx:

    Official address: http://nginx.org/en/download.html
    Stable version is a stable version. The latest stable version 1.20.1 is selected here
  2. Unzip the downloaded package:

    Use command:
    tar -zxvf nginx-1.20.1.tar.gz
    #To facilitate management after decompression:
    mv nginx-1.20.1/ /usr/local/sbin/nginx/nginx-1.20.1
    
  3. Installation dependency:

    yum -y install gcc gcc-c++ pcre-devel zlib-devel openssl openssl-devel
    
    What is the specific use? I won't explain it in detail here. I'll Baidu myself
  4. Perform configuration and install:

    ./configure --prefix=/usr/local/sbin/nginx --with-pcre 
    --with-http_stub_status_module --with-http_ssl_module 
    --with-http_gzip_static_module --with-http_realip_module
    
    If there is an error, check whether the dependency is installed.
    If no error is reported, execute make & & make install
  5. Configure nginx and start

    The configuration file is located in nginx.exe under the conf directory of the installation directory conf
    The compilation command is: VI / usr / local / SBIN / nginx / conf / nginx conf
    Start nginx:/ usr/local/sbin/nginx/sbin/nginx
    If you use ip to access the nginx interface in the browser, the installation is successful

3, redis installation

  1. Download reids:

    Official address: https://redis.io/download
    Stable is a stable version. The latest stable version 6.2.4 is selected here
  2. Unzip the downloaded package:

    Use command:
    tar -zxvf redis-6.2.4.tar.gz
    #Unzip and enter the folder:
    cd redis-6.2.4
    
  3. Compile and install:

    make PREFIX=/usr/local/sbin/redis install
    
    If the error gcc is reported, please do the following:
    # Check whether the gcc version is above 5.3, CentOS 7 6 default installation 4.8.5
    gcc -v
    # Upgrade gcc to 5.3 and above, as follows:
    yum -y install centos-release-scl
    yum -y install devtoolset-9-gcc devtoolset-9-gcc-c++ devtoolset-9-binutils
    scl enable devtoolset-9 bash
     It should be noted that scl Command enable is only temporary, exit shell Or restart will restore the original system gcc edition.
    
  4. Copy the profile and start:

    #Copy profile:
    cp redis.conf  /usr/local/sbin/redis/bin
    #Edit profile:
    vi  /usr/local/sbin/redis/bin/redis.conf
    	#/Search function
    	#/dae 	 Start up and start automatically. Change daemon no to daemon yes
    	#/foo	Connection password requirepass The password set for you later(Can not be set,Well number(#)Just don't delete it)
    	#/The bind connection limit turns down from bind 127.0.0.1 to bind 0.0.0.0 to unrestricted connection ip
    	#/protected- 	 Change remote connection protection to protected mode No
    	#ps: the above settings are configured if remote connection is required. If only local access is required, they do not need to be set**
    #Start nginx:
    cd /usr/local/sbin/redis/bin
    ./redis-server redis.conf
    
    Finally, use Another Redis Desktop Manager to connect to the launched redis
    If the connection is successful, the installation is successful.

4, mysql installation

  1. Download mysql:

    Official address: https://dev.mysql.com/downloads/mysql/
    Select Linux - Generic

  2. To install mysql:

    Decompression:

    #decompression
    xz -d mysql-8.0.25-linux-glibc2.12-x86_64.tar.xz
    tar -xvf mysql-8.0.25-linux-glibc2.12-x86_64.tar
    #Move to installation directory
    mv mysql-8.0.25-linux-glibc2.12-x86_64 /usr/core/mysql
    #Unzip and enter the folder:
    cd /usr/core/mysql
    #Install dependent files
    yum -y install gcc gcc-c++ cmake ncurses-devel autoconf perl perl-devel
    

    Configure users:

    #Create group mysql
    groupadd mysql
    #Create mysql user and prohibit login
    useradd -r -s /sbin/nologin -g mysql mysql -d /usr/core/mysql 
    

    Edit the required profile:

    touch /etc/my.cnf
    #Grant authority
    chown mysql.mysql /etc/my.cnf
    chmod 644 /etc/my.cnf
    #Edit my cnf
    vi /etc/my.cnf
    

    my.cnf content directly paste the following code, if you need other configuration, Baidu

    [client]
    # Set the default port used by mysql client when connecting to the server
    port=3306
    default-character-set=UTF8MB4
    
    [mysql]
    # Set the default character set of mysql client
    default-character-set=UTF8MB4
    
    [mysqld]
    #Set mysql installation directory
    basedir=/usr/core/mysql
    
    #Set the storage directory of mysql database data
    datadir=/usr/core/data/mysqldata
    
    #Set 3306 port
    port=3306
    
    #If your MySQL database mainly runs overseas, please be sure to adjust this parameter according to the actual situation
    default_time_zone = "+8:00"
    
    #skip-name-resolve
    #skip-grant-tables
    
    #Whether it is sensitive to the case of sql statements. 1 means insensitive
    lower_case_table_names=1
    
    #Maximum connections allowed
    max_connections=200
    
    # Number of connection failures allowed. This is to prevent someone from trying to attack the database system from the host
    max_connect_errors=20
    
    # The character set used by the server is UTF8 by default
    character-set-server=UTF8MB4
    
    # The default storage engine that will be used when creating new tables
    default-storage-engine=INNODB
    
    #Set the character set when the client connects to mysql to prevent garbled code
    init_connect='SET NAMES utf8mb4'
    
    max_allowed_packet=32M
    
    #Set up remote links
    default-authentication-plugin=mysql_native_password
    
    [mysqld_safe]
    #Set the storage directory of mysql database logs and process data
    log-error=/usr/core/data/mysqldata/mysql.log
    pid-file=/usr/core/data/mysqldata/mysql.pid
    

    Create the required folder:

    mkdir /usr/core/data/mysqldata
    chown mysql.mysql /usr/core/data
    chmod 755 /usr/core/data
    

    Initialize mysql:

    ./bin/mysqld --defaults-file=/etc/my.cnf --basedir=/usr/core/mysql --datadir=/usr/core/data/mysqldata --	user=mysql --initialize
    #Detailed explanation of parameters
    --defaults-file=/etc/my.cnf Specify the profile (put first)!)
    --user=mysql Designated user(a key!)
    --basedir=/usr/core/mysql  Specify the installation directory
    --datadir=/usr/core/data/mysqldata Specifies the initialization data directory
    --initialize Last
    

    Focus on copying the last password, which will be used below.

  3. Start and set up mysql:

    #Shortcut
    cp /usr/core/mysql/support-files/mysql.server /etc/init.d/mysql
    #mysql start 
    service mysql start 
    #Or systemctl mysql start 
    

    Log in to mysql and set the password:

    #Login to mysql
    mysql -uroot -p
    
    Enter the password just now(Just copy and paste)
    

    Set mysql password:

    #Set password to root
    alter user 'root'@'localhost' identified by "root";
    

    Change mysql settings:

    use mysql;
    #Change the connection to unlimited
    update user set host='%' where user='root';
    
    #If other users are required to log in
    #New user
    create user 'user name'@'%' identified by 'password';
    #all permissions are granted to the newly created user
    grant all on *.* to 'user name'@'%';
    
    #Refresh permissions
    flush privileges;
    #sign out
    exit;
    
    be careful:Users authorized with the above command cannot authorize other users,If you want this user to authorize,Use the following command: 
    GRANT all ON databasename.tablename TO 'username'@'host' WITH GRANT OPTION; 
    
  4. Connect to mysql:

    Connect using visualization tools, such as navcat
    Extension:
    Join startup Command: chkconfig --add mysql

5, Installation environment and tools used

  1. Environment used in this paper

    As follows:
    Server: Alibaba n4
    Configuration: 1 core 2G 1M
    System: centOS 8.3

  2. Tools used:

    Connection tools: xshell7, xftp7
    Make complaints about finalshell, though I have been told that it is very powerful, but I have not experienced well, such as excessive memory usage (I do not know if mine is being exploited, guess), and I have encountered the Catton garbled when I input the command. It depends on whether it can be optimized in the later stage. After all, it's free. It's already very good.

    Redis connection tool: Another Redis Desktop Manager
      I believe everyone who has contacted redis knows that RDM is paid, which is troublesome to crack. This ARDM is completely free and has similar functions. There are not bb so many links directly
    Domestic image gitee: https://gitee.com/qishibo/AnotherRedisDesktopManager
    github: https://github.com/qishibo/AnotherRedisDesktopManager

    Database connection tool: Navicat
    Download tool: Internet Download Manager (IDM)
      self Baidu, with natural understanding

    Ps: This article is for reference only. If it leads to various situations, we will not be responsible I have a piece of white. If there is any mistake in the article, please correct it thank!

Keywords: Linux MySQL JDK Nginx Redis

Added by karlkatzke on Sun, 30 Jan 2022 20:05:46 +0200