New server building - Summary: Download nginx, jdk8, docker compose (install mysql,redis) with installation

Preface

For example, the company bought a new 4-core 16G server and had to rebuild the environment, so it had to do one by one and make a record

1.nginx: manual installation

2.jdk8: manual installation

3. Install docker and docker compose

3. Docker compose encoding, one click docker to install mysql, redis

nginx installation

Available articles: https://www.cnblogs.com/xxoome/p/5866475.html

Before installing nginx, make sure that gcc, PCRE devel, zlib devel and OpenSSL devel are installed in the system.

  1. Setup command preparation environment
yum -y install gcc pcre-devel zlib-devel openssl openssl-devel

For specific installation, see other articles: https://www.cnblogs.com/sitongyan/p/11264116.html

Check whether the installation is successful:

/usr/local/nginx/sbin/nginx -v

Installation directory / usr/local/nginx

Install jdk8

Procedure: upload and install to server > unzip > configure system environment > source configuration environment takes effect

/Add the specified configuration to ect/profile

export NGINX_HOME=/usr/local/nginx
export NGINX_PATH=${NGINX_HOME}/sbin

export JAVA_HOME=/usr/local/java/jdk1.8.0_141
export JRE_HOME=${JAVA_HOME}/jre
export CLASSPATH=.:${JAVA_HOME}/lib:${JRE_HOME}/lib:$CLASSPATH
export JAVA_PATH=${JAVA_HOME}/bin:${JRE_HOME}/bin
export PATH=$PATH:${JAVA_PATH}

export PATH=$PATH:${NGINX_PATH}
 

For specific installation, please refer to the article: https://blog.csdn.net/weixin_38339025/article/details/89702572

Install docker and docker compose

 

View document: https://www.cnblogs.com/ruanqin/p/11082506.html 

Among them, docker compose is too slow to use curl-l https://github.com/docker/compose

Recommended implementation:

curl -L https://get.daocloud.io/docker/compose/releases/download/1.24.0/docker-compose-`uname -s`-`uname -m` > /usr/local/bin/docker-compose

 

docker-compose --version

 

Docker compose choreography (install mysql,redis)

 

Note in advance that the docker installation and drop-down are too slow. It is recommended to modify it (otherwise, more than 1 hour will be wasted)

Modify docker image source

Modify or add / etc/docker/daemon.json

Edit json file

vi /etc/docker/daemon.json

{

"registry-mirrors": ["http://hub-mirror.c.163.com"]

}

Restart the docker service linxu command

systemctl restart docker.service

 

docker-compose.yml file

version: '3'
services:
  redis: 
    image: redis:latest
    container_name: sc-redis
    restart: always
    volumes:
      - /usr/local/redis/redis.conf:/etc/redis/redis.conf
      - /usr/local/redis/data:/data
    environment:
      - REDIS_PASSWORD=root@123
    networks:
      - sc-net
    ports:
      - 6379:6379

  mysql:
    image: mysql:5.7
    container_name: sc-mysql
    restart: always
    networks:
      - sc-net
    ports:
      - 3306:3306
    volumes:
      - /usr/local/mysql/data:/var/lib/mysql           # Mount data directory
      - /usr/local/mysql/conf.d:/etc/mysql/conf.d      # Mount profile directory
      - /usr/local/mysql/my.cnf:/etc/mysql/my.cnf
      - /usr/local/mysql/mysql-files:/var/lib/mysql-files/
    environment:
      TZ: Asia/Shanghai
      MYSQL_ROOT_PASSWORD: root@123
     
networks:
  sc-net:
    external: false

Where, the host must be created first, and the directory is given here

 

 

mysql.cnf configuration

[mysqld]
user=mysql
character-set-server=utf8
default_authentication_plugin=mysql_native_password
secure_file_priv=/var/lib/mysql
expire_logs_days=7
sql_mode=STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_ENGINE_SUBSTITUTION
max_connections=1000

[client]
default-character-set=utf8

[mysql]
default-character-set=utf8

redis.conf

#Number of databases in redis
databases 15
#redis password
requirepass root@123

 

Note:

volumes: is the mount configuration; the former is the host directory and the latter is the container directory

networks:

sc-net:

external: false

Indicates that the SC net network is used, external:false, otherwise, the SC net network will be created automatically

 

 

linux, executed in the same level directory of docker-compose.yml file

docker-compose up -d 

1. Start container: docker compose start

2. Stop the container: docker compose stop

3. Restart container: docker compose restart will cause the container to restart

4. Rebuild container: docker compose up - D -- build

 

 

 

Baidu cloud share

nginx-1.9.9

Link: https://pan.baidu.com/s/12dq67e3ZiSHxsiKN4rNCxg
Extraction code: nfqm

jdk8

Link: https://pan.baidu.com/s/1HtliVzyO9ODCCCVxWtZJug
Extraction code: kdu7

 

 

In fact, you can install docker first, and then use docker compose to install nginx, JDK

But no one seems to be doing that

The host in java environment is afraid that it will be used in other places, so it's still installed. But I still want to use docker with one click. I'm not familiar with it, but I'm still trying to be stable!

Keywords: Programming Docker MySQL Redis Nginx

Added by elgoog on Wed, 11 Dec 2019 15:55:03 +0200