It’s very painful to set up a variety of environments every time, and encounter various problems. Therefore, write this article to record the construction process, problems and solutions of some environments under centos7. The construction of other environments will also be updated. This article is not worth reading, but can be collected, has been prepared for a rainy day. This paper mainly refers to the development server of enterprise Java e-commerce website from 0
Modify software source
Changing to domestic Yum source can speed up the download
Reference articles
The cloud server of Tencent cloud does not need to be changed. It is the source of Tencent by default
Linux learning materials
- Linux software installation management
- Basic rights of Linux privilege management
- Linux talent cultivation plan I
- Linux service management
- Using iptables to build a powerful security shield
JDK installation
- JDK Download
- JDK historical version address
- download
wget https://download.oracle.com/otn/java/jdk/8u231-b11/5b13a193868b4bf28bcb45c792fce896/jdk-8u231-linux-x64.rpm
(you can’t download this way, because there is a broken agreement, you need to download it first and then upload it.)
The SCP command can be used to upload to the server
scp [email protected] :/home/ test.txt . // download file
scp test.txt [email protected] : / home // upload file
scp -r [email protected] : / home / test. // download directory
scp -r test [email protected] : / home // upload directory
- Uninstall the default JDK, if any
- Judge whether there is JDK
rpm -qa | grep jdk
- delete
yum remove xxx
- Grant permissions to the downloaded JDK RPM file
chmod 777 jdk.xxx.rpm
#The highest authority is directly given here. Please be careful
- install
rpm -ivh jdk.xxx.rpm
- Default installation path / usr / Java
- Configure environment variables
- Configuration file / etc / profile
- Configure path, classpath, Java_ HOME
- source /etc/profile
Add the following variables to / etc / profile
#Here is Java_ Home is the installation directory of Java
export JAVA_HOME=/usr/java/jdk1.8.0_202-amd64
export PATH=$PATH:$JAVA_HOME/bin
export CLASSPATH=.:$JAVA_HOME/jre/lib/rt.jar:$JAVA_HOME/lib/tools.jar
- Verify JDK
java -version
Tomcat installation
- Download (historical version address https://tomcat.apache.org/dow… )
wget http://mirrors.tuna.tsinghua.edu.cn/apache/tomcat/tomcat-8/v8.5.50/bin/apache-tomcat-8.5.50.tar.gz
- decompression
- Configure environment variables
#I haven't matched this before. It seems to be of little use
export CATALINA_HOME=/devlib/apache-tomcat-8.5.50
- It is not necessary to configure utf-u character set to support Chinese
# ${CATALINA_HOME}/conf/server.xml URIEncoding="UTF-8"
<Connector port="8080" protocol="HTTP/1.1"
connectionTimeout="20000"
redirectPort="8443" URIEncoding="UTF-8"/>
- verification
#Enter ${Catalina_ HOME}/bin
./startup.sh
#Visit http: // ${IP}: 8080/
- Common commands
- Start ${Catalina_ HOME}/bin/ startup.sh
- Close ${Catalina_ HOME}/bin/ shutdown.sh
Maven installation
- download
wget http://mirrors.tuna.tsinghua.edu.cn/apache/maven/maven-3/3.6.3/binaries/apache-maven-3.6.3-bin.tar.gz
- decompression
- Configure environment variables
- MAVEN_ Home = installation directory
- Add the bin directory to your path
- verification
mvn -version
- Common commands
- Clear: MVN clean
- Compiling: MVN compile
- Package: MVN package
- Mvpackage: skip test unit- Daven.test.skip=true
FTP service setup (vsftpd)
- install
yum -y install vsftpd
- The configuration file is located in / etc / vsftpd/ vsftpd.conf
- Must add / SBIN / nologin to / etc / shells (this card has been used for a long time, please pay attention, otherwise the nologin users will not be able to connect)
- Create virtual user
- Create a directory as the FTP directory, such as / ftpfile
- Add the anonymous user useradd – M – S / SBIN / nologin ftpuser – m to indicate that the directory is not home
- Modify permission: chown – R ftpuser.ftpuser /ftpfile
- Reset ftpuser password passwd ftpuser
- to configure
cd /etc/vsftpd
vim chroot_list
Add the new ftpuser to the configuration file
- VIM / etc / SELinux / config modify SELinux = disable
If 550 is encountered, setsebool – P FTP is executed_ home_ dir 1
- vsftpd.conf to configure
Configuration description reference
http://learning.happymmall.co…
Pay attention to several points:
- local_root
- local_enable
- anonymous_enable
- pasv_min_port
- pasv_max_port
- Solution to the error of vsftpd: 500 oops: vsftpd: reusing to run with writable root inside chroot()
Add a line to this configuration
allow_writeable_chroot=YES
- Firewall configuration
#This is CentOS 7, 6 is different
Start: systemctl start firewalld
Close: systemctl stop firewalld
View status: systemctl status firewalld
Boot disabled: systemctl disable firewalld
Boot enabled: systemctl enable firewalld
Open port firewall CMD -- zone = public -- add port = 80 / TCP -- permanent
Close port firewall CMD -- zone = public -- remove port = 80 / TCP -- permanent
View open ports firewall CMD -- zone = public -- List ports
Update firewall rule: firewall CMD -- reload
- verification
- start-up
·
service vsftpd start
- Try to connect with the client
- Common commands
- Start: Service vsftpd start
- Stop: Service vsftpd restart
- Close: Service vsftpd stop
#Set boot up
systemctl enable vsftpd.service
#Start
systemctl start vsftpd.service
#Stop
systemctl stop vsftpd.service
#View status
systemctl status vsftpd.service
#Restart
systemctl restart vsftpd.service
nginx
- Installing GCC
yum install -y gcc
gcc -v
- Install PCRE
yum install -y pcre-devel
- Install zlib
yum install -y zlib zlib-devel
- Install OpenSSL (support SSL)
yum install -y openssl openssl-devel
- The above can be installed with one command
yum install -y gcc pcre-devel zlib zlib-devel openssl openssl-devel
- Download nginx
Historical version http://nginx.org/download/
wget http://nginx.org/download/nginx-1.13.6.tar.gz
- decompression
- Enter the decompressed directory to execute
./configure
#Add -- prefix = / usr / nginx to specify the installation directory
Where is nginx can query the installation directory, which is / usr / local by default/
- Execute make and then make install
- Common commands
- Test configuration file correctness
/nginx/sbin/nginx -t
- start-up
/nginx/sbin/nginx
- stop it
/nginx/sbin/nginx -s stop
or
nginx -s quit
- restart
/nginx -s reload
- Process view
ps -ef|grep nginx
- graceful restart
Kill - P process
- to configure
- Decompose configuration file
In / usr / local / nginx / conf/ nginx.conf Add include Vhost / *. Conf to make it easier to configure a configuration file for each domain name
Point to port
server {
default_type 'text/html';
charset utf-8;
listen 80;
#Open index
autoindex on;
server_name learning.happymmall.com;
access_log /usr/local/nginx/logs/access.log combined;
index index.html index.htm index.jsp index.php;
#error_page 404 /404.html;
if ( $query_string ~* ".*[\;'\<\>].*" ){
return 404;
}
#Pay attention to this
location / {
proxy_pass http://127.0.0.1:81/aa;
#Don't write that in the real world
add_header Access-Control-Allow-Origin *;
}
}
Point to directory
server {
listen 80;
#Note that indexing is prohibited here
autoindex off;
server_name img.happymmall.com;
access_log /usr/local/nginx/logs/access.log combined;
index index.html index.htm index.jsp index.php;
#error_page 404 /404.html;
if ( $query_string ~* ".*[\;'\<\>].*" ){
return 404;
}
location ~ /(mmall_fe|mmall_admin_fe)/dist/view/* {
deny all;
}
location / {
root /product/ftpfile/img/;
add_header Access-Control-Allow-Origin *;
}
}
mysql
- install
yum install -y mysql-server
(this does not work in centos7. There is no such source in the software source. You need to download the source and install it again, as follows)
Reference articles https://www.cnblogs.com/codin…
- Configuration file location / etc/ my.cnf
- Configure MySQL self start
You can also use the above method to configure vsftpd auto start
chkconfig mysqld on
#2-5 on demand
chkconfig --list mysqld
- Firewall opening 3306
- Start validation
Start: systemctl start mysqld.service
Stop: systemctl stop mysqld.service
Restart: systemctl restart mysqld.service
View service status: systemctl status mysqld.service
- Job for appears mysqld.service Failed because the control process exited with error code problem
Delete / var / lib / MySQL and restart
- Log in (if you can log in, you can prove it)
mysql -u root
- Login error
ERROR 1045 (28000): Access denied for user ‘root’@’localhost’ (using password: NO)
Modify / etc/ my.cnf Add a line of skip grant tables under [mysqld]
After logging in, change the root password and remove the line
How to change the password
Alter user 'root' @'localhost 'identified by' your password ';
- MySQL user and permission related configuration
https://www.cnblogs.com/gycho…
Create user
Create user 'test1' @'localhost 'identified by''password ';
Flush privileges; refresh permissions
Where localhost refers to the local connection
It can be changed to% to indicate that any IP can be connected
You can also specify an IP connection
Change Password
Alter user 'test1' @'localhost 'identified by' new password ';
flush privileges;
to grant authorization
grant all privileges on *.* to 'test1'@'localhost' with grant option;
With Gran option means that the user can grant permissions to other users, but it is impossible to exceed the existing permissions of the user
For example, user a has select and insert permissions, and can also give other users authorization, but it is impossible to assign delete permission to other users, except select and insert
This sentence can be added or not, depending on the situation.
All privileges can be changed to select, update, insert, delete, drop, create, etc
For example: Grant select, insert, update, delete on *. * to 'test1' @'localhost ';
The first * represents the general configuration database, which can only be operated by new users
For example: grant all privileges on database;
The second * represents the universal configuration table. You can specify a table under the database that new users can only operate on
For example: grant all privileges on database. Specify the table name to 'test1' @'localhost ';
查看用户to grant authorization信息
show grants for 'test1'@'localhost';
Revocation of authority
revoke all privileges on *.* from 'test1'@'localhost';
Users are allowed to withdraw whatever permissions they have
delete user
drop user 'test1'@'localhost';
reference material
- Independently complete the development of enterprise Java e-commerce website (server) from 0
- CentOS image
- Operation command of centos7 firewall
- Fast open port configuration method of CentOS 7 firewall
- Mysql8 create and delete users, authorization and cancellation operations
(continuous update…)