CentOS server deployment (YUM)

Mount the disk##

Mounted disk space size

df -h

1 ) View disk partition information

fdisk -l

Appears similar

Disk/dev/vdb:1073.7 GB,1073741824000 bytes, 2097152000 sectors
Units =Sector of1*512=512 bytes
Sector size(logic/physical): 512 bytes/512 bytes
I/O size(The smallest/optimal): 512 bytes/512 bytes
  1. If the disk is /dev/vdb format partition
mkfs.ext4 /dev/vdb
  1. Mount after formatting
mkdir /data
mount /dev/vdb /data
  1. Auto mount at boot

After the above configuration, the disk will not be automatically mounted after booting. The configuration for automatic mounting is as follows

vim /etc/fstab

Add at the end of the file

/dev/vdb    /data    ext4    defaults    00

Save and exit ESC``:wq

  1. Check the remaining space of the disk
df -hl

Ali YUM Mirror##

  1. Backup
mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.backup
  1. Download the new CentOS-Base.repo to /etc/yum.repos.d/
  1. Generate cache
yum makecache

Configure time synchronization##

  1. Install chrony (time synchronization client)

Centos/redhat/alios:

yum install -y chrony

ubuntu/debian:

apt-get install chrony
  1. Delete the default server
sed -i "/server/d"/etc/chrony.conf
  1. Open /etc/chrony.conf and add a new line
vim /etc/chrony.conf

Add to

server ntp.aliyun.com iburst
  1. Restart chrony
systemctl restart chronyd

or

service chronyd restart
  1. Check if it is normal
chronyc tracking

or

date
  1. boot

CentOS7

systemctl enable chronyd.service

CentOS6

chkconfig chronyd on

Service Operation Command##

Features CentOS7 CentOS6
View self-starting services ls /etc/systemd/system/multi-user.target.wants/systemctl list-unit-files chkconfig --list
Start on boot systemctl enable nginx.service chkconfig nginx on
Cancel auto start systemctl disable nginx.service chkconfig nginx off
Start service systemctl start nginx.service service nginx start
Stop service systemctl stop nginx.service service nginx stop
Restart service systemctl restart nginx.service service nginx restart
Load failed service systemctl –failed
Reload systemctl reload nginx.service
View status systemctl status nginx.service

View application location##

whereis nginx

Connect to Linux

ssh [email protected]

root is the username
112.112.112.112 Server ip

Restart the system##

reboot

Memcached

Install Memcached

Installation dependencies

yum install -y libevent libevent-deve

Install MemCached

yum install memcached

Run Memcached

CentOS7

systemctl restart memcached

CentOS6

service memcached start

or

/usr/bin/memcached -p 11211-u root -m 256-c 10240

Basic settings of memcached:

Configuration path

CentOS7

vim /etc/sysconfig/memcached

CentOS6

vim /etc/init.d/memcached

shut down

pkill -9 memcached

Set boot up

CentOS7

systemctl enable memcached.service

CentOS6

chkconfig memcached on

Cancel startup

CentOS7

systemctl disable memcached.service

CentOS6

chkconfig memcached off

JDK

Official download of JDK URL

Or link: https://pan.baidu.com/s/1JdPCMMEq178hXV5V4Ild3Q Password: 03l1

For example, the downloaded file is jdk-8u221-linux-x64.rpm

Change file permissions

chmod 755 jdk-8u221-linux-x64.rpm

installation

rpm -ivh jdk-8u221-linux-x64.rpm

The path after installation is /usr/java/jdk1.8.0_221-amd64

Delete Files

rm jdk-8u221-linux-x64.rpm

Query java version

java -version

View java-home

echo $JAVA_HOME

If it is empty, configure java-home, otherwise you cannot configure Tomcat as a service

Open the file /etc/profile

vi /etc/profile

Add at the end of the profile file:

export JAVA_HOME=/usr/java/jdk1.8.0_221-amd64 
export PATH=$JAVA_HOME/bin:$PATH   
export CLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar

Configuration takes effect immediately

source /etc/profile

Tomcat7(yum way)

Inquire

yum list tomcat*

installation

yum -y install tomcat

Start tomcat

service tomcat start

Set to boot

chkconfig tomcat on

The default tomcat folder path

cd /usr/share/tomcat

Tomcat8 (non-yum mode)

(1) download

If the download address is not available, get a new address from http://tomcat.apache.org/

wget http://mirrors.tuna.tsinghua.edu.cn/apache/tomcat/tomcat-8/v8.5.42/bin/apache-tomcat-8.5.42.tar.gz

(2) installation

tar -xzvf apache-tomcat-8.5.42.tar.gz
mv apache-tomcat-8.5.42/opt/tomcat8

run

cd /opt/tomcat8/bin
. /startup.sh

(3) Configuration

It is not safe to use root in a production environment, so

useradd -s /sbin/nologin tomcat
chown -R tomcat:tomcat /opt/tomcat8

For service, start with the operating system

cd /opt/tomcat8/bin
tar -xzvf commons-daemon-native.tar.gz
cd commons-daemon-1.1.0-native-src/unix/./configure 
make
cp jsvc ../..
cd ../..

Error 1

configure: error: no acceptable C compiler found in $PATH

Solve 1

yum -y install gcc

Open daemon.sh

cd /opt/tomcat8/bin
vi daemon.sh

At the beginning of the text, which is below the comment, add the following five lines of content

# chkconfig:23451090 
# description: Starts and Stops the Tomcat daemon. 

JAVA_HOME=/usr/java/jdk1.8.0_201-amd64
CATALINA_HOME=/opt/tomcat8
CATALINA_OPTS="-Xms512m -Xmx1024m -XX:PermSize=128m -XX:MaxPermSize=256m"

Configure to prevent log Chinese garbled

Find JAVA_OPTS= and modify it to

JAVA_OPTS="-Dfile.encoding=UTF8 -Dsun.jnu.encoding=UTF8"

Save and exit

: wq

Add to service

cp daemon.sh /etc/init.d/tomcat8
chkconfig --add tomcat8

boot

chkconfig tomcat8 on

an examination

chkconfig --list|grep tomcat8

Start service

service tomcat8 start

Delete service

service tomcat8 stop
chkconfig tomcat8 off
chkconfig --del tomcat8
rm -rf /etc/init.d/tomcat8

Firewall add trust rules

open a file

vim /etc/sysconfig/iptables

Add rule

- A INPUT -m state --state NEW -m tcp -p tcp --dport 8080-j ACCEPT

Restart firewall

service iptables restart

Apache

Install Apache

yum install httpd httpd-devel

Uninstall

yum -y remove httpd*

Start apache

service httpd start

Set to boot

chkconfig httpd on

Reload configuration

service httpd reload

View version

httpd -v

Configuration file location /etc/httpd/conf/httpd.conf

Set up virtual host directory
Add at the end of the file

Listen 9999  
NameVirtualHost *:9999<VirtualHost *:9999>  
	ServerName localhost:9999  
	DocumentRoot "/data/staticFile"</VirtualHost>

PHP5.4

Server security software (install one)

Safety Dog###

Download and install

wget http://down.safedog.cn/safedog_linux64.tar.gz
tar xzvf safedog_linux64.tar.gz
cd safedog_an_linux64_2.8.19005/
chmod +x *.py
. /install.py

Missing component installation during installation in the previous step

Login account (cannot log in temporarily)

sdcloud -u Service Cloud Account

Enter the operation interface

sdui

Suspended mirror###

Xmirror server side

A key installation

wget -O install.sh http://dl.xmirror.cn/a/install.sh && sh install.sh

Recommended Posts

CentOS server deployment (YUM)
CentOS7.6 server deployment VNC
CentOS deployment Harbor
Centos7 installation and deployment of gitlab server
Centos7 YUM install MariaDB 10.0
CentOS 7.2 Yum install MySQL 5.6
Centos7 YUM install MariaDB 10.0
CentOS 5 to CentOS 5.8 YUM source
Swift Perfect-Ubuntu server deployment
[CentOS environment deployment] Java7/Java8 deployment under CentOS
centos install mysql through yum
Centos7.4 deployment configuration Elasticsearch5.6 cluster
Build OpenLDAP server under CentOS7
Centos 6.10 reinstall python and yum
Deployment of graphite on centos7
CentOS 7.2 deploy mail server (Postfix)
Centos7.2 deployment vnc service record
install virtualbox on centos server
CentOS 7 yum install PHP7.3 tutorial
Install Nginx server on CentOS 7
Ceph rapid deployment (Centos7 + Jewel)
CentOS7 yum install and start mysql
CentOS Yum compile and install MySQL 5.6
CentOS server initialization setting detailed instructions
CentOS 8 (2)
Centos6.5 installation and deployment of KVM
RabbitMQ cluster deployment record under Centos6.9
CentOS8.1 build Gitlab server detailed tutorial
Tencent Cloud Centos7 install java server
CentOS configuration git server in VirtualBox
Elasticsearch cluster deployment record under CentOS7
Tencent Cloud Centos7 install java server
Install Percona Server database (in CentOS 8)
Install java in yum mode in Centos
rhel7.2 yum uses CentOS update package
CentOS7 yum install and start mysql
Centos yum install mysql5.6 or above
Build an FTP server under centos7
CentOS 8 (1)
CentOS7 install and use SQL Server
Centos7 build java web server tomcat
CentOS NTP server installation and configuration
CentOS 7 install gogs git code server
CentOS deployment method of flask project
CentOs7 installation and deployment Zabbix3.4 original
Build Yum private warehouse in Centos7.3
FFmpeg environment deployment record under centos7
Modify CentOS server time to Beijing time
Erlang 20.2 installation and deployment under CentOS 7
CentOS7 repairs python to save yum
k8s practice (1): Centos 7.6 deployment k8s (v1.14.2) cluster
PPTP environment deployment record under Centos
Concise summary of Ceph deployment on Centos7
CentOS yum install Apache + PHP + Tomcat7 + MySQL
MySQL 8.0 installation, deployment and configuration under CentOS 6/7
Centos-6.5 installation and deployment of LNMP environment
Centos 8.1.1911 solves the problem of yum reinstallation
Zabbix installation and deployment and localization under CentOS
CentOS 6 add common yum source to transfer
CentOS 7 Apache Multi-port Deployment Web Apps Guide
Jenkins installation and deployment tutorial under CentOS 7