Linux Centos7 Deployment Environment Installation-CentOS

Keywords: Programming Nginx MySQL yum Java

Linux Centos7 Deployment Environment Installation-CentOS

Centos7 Deployment Environment Installation and Common Linux Commands

  • The role of folders in centos system
  • centos7 Modify System Default Language
  • centos7 install rz/sz command
  • centos7 install netstat
  • centos7 install lsof command
  • centos7 Download and install jdk and configure environment variables
  • centos7 Install Tomcat
  • centos7 Install Nginx
  • centos7 Install MySQL
  • Common Linux Commands

<!--more-->

The role of folders in centos system

  • /: Root directory, generally only directories are stored under the root directory, do not store files, /etc, /bin, /dev, /lib, /sbin should be placed in a partition with the root directory
  • /bin:/usr/bin: Directory of executable binaries, such as common commands ls, tar, mv, cat, etc.
  • /boot: Places some files used when the linux system starts.
    • /boot/vmlinuz is the kernel file for linux, and/boot/gurb.A separate partition is recommended, with a partition size of 100M
  • /dev: Stores device files under the linux system and accesses a file in that directory, which is equivalent to accessing a device. The common use is mounting the CD-ROM mount/dev/cdrom/mnt.
  • /etc: The directory where system configuration files are stored. It is not recommended to store executable files in this directory. Important configuration files are / etc/inittab, /etc/fstab, /etc/init.d, /etc/X11, /etc/sysconfig, /etc/xinetd.d Remember to back up before modifying configuration files.Note: /etc/X11 stores settings related to x windows.
  • /home: The default user home directory of the system. When user accounts are added, the user's home directory is stored in this directory, ~denotes the current user's home directory, ~test denotes the user's test home directory.It is recommended to partition separately and set up large disk space to facilitate user storage of data
  • /lib:/usr/lib:
    • /usr/local/lib: The directory of the function libraries used by the system. When a program needs to call some extra parameters during execution, it needs the assistance of the function library. The more important directory is/lib/modules.
  • /lost+fount: When a system exception produces an error, some missing fragments are placed in this directory, which usually appears automatically in the device directory.If the hard disk is loaded in/disk, the directory/disk/lost+found will automatically be generated in this directory
  • /mnt:/media: The default mount point for a disc. Usually the disc is mounted under / mnt/cdrom, but it is not always necessary. You can choose any location to mount it.
  • /opt: Directory where additional software is installed for the host.For example, the Fedora Community Development Software used by FC4 can be installed in this directory if you want to install the new KDE desktop software yourself.On previous Linux systems, it was customary to place it in the / usr/local directory
  • /proc: The data in this directory is in memory, such as the system core, external devices, network state. Since the data is stored in memory, it does not occupy disk space. The most important directories are/proc/cpuinfo, /proc/interrupts, /proc/dma, /proc/ioports, /proc/net/*etc.
  • /root: Administrator root's home directory. The first partition started by the system is /, so it is best to place / root and / under one partition.
  • /sbin:/usr/sbin:/usr/local/sbin: Place executable commands used by system administrators, such as fdisk, shutdown, mount, etc.Unlike / bin, these directories are commands for system administrator root, and users can only "view" them rather than set them up and use them.
  • /tmp: A directory where normal users or executing programs temporarily store files, which anyone can access, and where important data cannot be placed
  • /srv: The directory of data that the service needs to access after it starts, such as web page data that the WW service needs to access stored in/srv/ww
  • /usr: application store directory,
    • /usr/bin holds applications,
    • /usr/share holds shared data,
    • /usr/lib stores library files that cannot be run directly, but are necessary for many programs to run.
    • /usr/local: Store the software upgrade package.
    • /usr/share/doc: System description file storage directory.
    • /usr/share/man: Program description file store directory, query/usr/share/man/man1/ls.1.gz content when using man ls recommend separate partitions with large disk space
  • /var: Place files that change frequently during system execution, such as log files/var/log, /var/log/message: all login file storage directories, /var/spool/mail: mail storage directory, /var/run: program or service startup

Common commands for linux Java development

centos7 Modify System Default Language

Check to see if the Chinese language pack is installed on the system

locale -a |grep zh_CN

View System Default Language

echo $LANG

Modify system default language

Modify/etc/locale.conf file to LANG=zh_CN.UTF-8

centos7 Installation Development Kit

English System Installation: # yum-y groupinstall "Development tools" Chinese System Installation: # yum-y groupinstall "Development Tools"

centos7 install rz/sz command

#######install rz/sz command#######
yum install -y lrzsz

#######decompression/compress.tar.gz#######
#decompression
tar -xvzf apache-tomcat-8.5.23.tar.gz
#compress
tar -zcvf file name.tar.gz Files to Compress/Folder
# For example:
tar -zcvf webfile.tar.gz webfile

centos7 install netstat

yum install net-tools

centos7 install lsof command

yum install lsof

centos7 yum Download and install jdk and configure environment variables

  1. Check if java is installed:
yum list installed | grep java
  1. Uninstall java
yum -y remove java-1.8.0-openjdk*
  1. View a list of java packages
yum -y list java*
  1. Download all packages that install Java 1.8 and enter y halfway to confirm the download.
yum install java-1.8.0-openjdk*
  1. Check for successful installation
java -version
  1. Configuring environment variables

The Java installed by yum defaults to / usr/lib/jvm, enter the directory, you can see <code>java-1.8.0-openjdk-1.8.0.222.b10-1.el7.x86_64</code>, JAVA_HOME points to the directory; add at the bottom of the file

6.1 Current user uses:

# vi command to edit ~/.bashrc file, press I to enter edit mode
vi ~/.bashrc

# Add the following line of code
export&nbsp; JAVA_HOME=/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.222.b10-1.el7_7.x86_64

# Save and Exit
:wq

6.2 For all users:


vi /etc/profile

#set&nbsp;java&nbsp;environment-------------start&nbsp;&nbsp;

export JAVA_HOME=/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.222.b10-1.el7_7.x86_64

export CLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar:$JAVA_HOME/jre/lib/rt.jar

export PATH=$PATH:$JAVA_HOME/bin

#set&nbsp;java&nbsp;environment-------------end

# Save and Exit

# Make Configuration Effective
. /etc/profile

  1. View configured environment variables, installation success
# View Configured Environment Variables
echo $JAVA_HOME
# Is the java installation successful

java -version

# Whether the jdk was installed successfully or if documentation appears
javac 

centos7 Install Tomcat

Install jdk, upload the tomcat package, and unzip:

#### Start tomcat
cd apache-tomcat-8.5.23/bin/
sh startup.sh

#### View startup log
cd apache-tomcat-8.5.23/logs/
cat catalina.out

centos7 Install Nginx

Download Nginx

wget http://nginx.org/download/nginx-1.14.0.tar.gz

Unzip the installation package and enter the installation package directory

tar zxvf nginx-1.14.0.tar.gz
cd nginx-1.14.0

Compile Installation

# 1.
./configure 
# 2.
make
# 3.
make install

View nginx version

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

Check Configuration File nginx.conf for Correctness Command

/usr/local/nginx/sbin/nginx -t

The normal results are as follows:

nginx: the configuration file /usr/local/nginx/conf/nginx.conf syntax is ok
nginx: configuration file /usr/local/nginx/conf/nginx.conf test is successful

Common nginx commands

#Start Command
/usr/local/nginx/sbin/nginx
#Reload Configuration File
/usr/local/nginx/sbin/nginx -s reload
#Restart Nginx
/usr/local/nginx/sbin/nginx -s reopen
#Stop Nginx
/usr/local/nginx/sbin/nginx -s stop
#Monitoring whether the Nginx service is running
netstat -anput | grep nginx

Reference Documents

Install Nginx under CentOS and test pass: https://blog.csdn.net/qq_35976320/article/details/80458079

How nginx configures load balancing: https://www.cnblogs.com/yuuje/p/11005992.html

Install MySQL

yum installation mysql5.6 under centos7

View MySQL Available Installation Packages

yum -y list mysql*

View the current list of mariadb installations

rpm -qa | grep mariadb

uninstall

rpm -e --nodeps mariadb-5.5.64-1.el7.x86_64
rpm -e --nodeps mariadb-libs-5.5.64-1.el7.x86_64

Install the yum source for MySQL

Find a link on the website above to install using wget:

wget 'https://dev.mysql.com/get/mysql57-community-release-el7-11.noarch.rpm'

Install yum source

rpm -Uvh mysql57-community-release-el7-11.noarch.rpm

Check that mysql source is installed successfully

yum repolist enabled | grep "mysql.*-community.*"

See which versions of mysql are available:

yum repolist all | grep mysql

>mysql-devel: libraries for development and include files; mysql: mysql client; mysql-server: database server;

Default installation of mysql5.7

yum install -y mysql-community-server

mysql start

#centos7 command starts mysql
systemctl start mysqld
#View Status
systemctl start mysqld

Log in to the database and change the database password

grep 'temporary password' /var/log/mysqld.log

Log in to the database:

mysql -uroot -p

Enter your password, return to mysql, and execute the following commands:

### Don't make the password too simple or the change will fail
SET PASSWORD = PASSWORD('Mysql520!');

Set up remote login

#Step One
GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY 'Mysql520!' WITH GRANT OPTION;
#Step 2
flush privileges;

Modify Profile

vim /etc/my.cnf
Modify database encoding

Add the following at the end, modify the encoding to utf8mb4

[client]
default-character-set = utf8mb4
[mysql]
default-character-set = utf8mb4
[mysqld]
character-set-client-handshake = FALSE
character-set-server = utf8mb4
collation-server = utf8mb4_unicode_ci

Enter the SQL statement: <code>show variables like'char%'; </code>view the character set;

sql supports group by statements
sql_mode=STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION
Set time zone to East Eight
default-time_zone = '+8:00'

Restart the database for the configuration to take effect

systemctl restart mysqld

Set up boot-up

systemctl enable mysqld
systemctl daemon-reload

Open Cloud Server Port 3306

If the connection cannot be successfully tested, open port 3306 of the cloud server.

Reference Documents

centos7 Use below yum Source Installation mysql5.7 Record:[https://www.jianshu.com/p/531cc35b15e7](https://www.jianshu.com/p/531cc35b15e7)

Common Commands

# View ip address
ip addr
# View processes occupying ports
netstat -lnp|grep 8080
#or
lsof -i:8080
# View process-specific information based on process ID
ps axu|grep 2643 
# List all ports
netstat -ntlp
# View process
ps -ef|grep nginx


# Kill Process
kill -9 Process Number

killall -9 Process name

## Delete Files or Folders
# Delete Directory
rm /home/test
# -r is the directory and subdirectory in the recursive delete parameter table
rm -r /home/test
# f Delete all files in the directory without prompting the user
rm -rf /home/test
# -i is the interactive mode
rm -ir /home/test

First blog address, Click to visit: https://www.wanglixia.top/ Original address, Click to read: Linux Centos7 Deployment Environment Installation-CentOS

If you like, please pay attention to the weyoung Public Number.

Posted by Steve Mellor on Wed, 25 Sep 2019 12:01:28 -0700