Centos Configure the JavaWeb Environment from the head

The memory is too bad, I still have to write a tutorial to summarize the tutorial on configuring javaweb. This tutorial is also a synthesis of many tutorials on the Internet.

Environment

Server: Alibaba Cloud ESC Centos 7.3

Local: Mac OS X 10.10.5

Pre-preparation

It was only recently discovered that Alibaba Cloud does not recommend upgrading the server’s kernel and operating system versions. It is estimated that Tencent Cloud is also the same. Will be used all the time, the system version is also the latest 7.3, which was originally 7.2

In order to prevent the kernel and system version from being upgraded when the software is updated, according to the help document given by Alibaba Cloud, we do Modify as follows

Open the yum.conf file

1
vi /etc/yum.conf

Add code

< tbody>

1
2

pre>
exclude=kernel*
exclude=centos-release*

This will prevent the upgrade, if you still don’t understand, please refer to the help file< /p> < p>Then we can start to upgrade the software package

1
yum -y update

The -y parameter is the default selection yes for interaction encountered during execution

Install JDK

Visit Oracle's official website to download jdk, because Oracle engages in cookie verification, wget is inconvenient

Download address-http:// www.oracle.com/technetwork/cn/java/javase/downloads/jdk8-downloads-2133151-zhs.html

Before installing jdk, be sure to uninstall the previous version

Check the previously installed jdk rpm

1< /span>
rpm -qa | grep jdk

After finding the package name, we can uninstall it

1
< pre>rpm -e package name

Download After installing the package, we use the scp command to upload to the server

1
scp ~/Downloads/jdk-8u111-linux-x64 .rpm [email protected]:/usr/local/src

Because I have Add trust, so you don’t need to enter the password.

If you must use wget to download directly from the server, I will provide the following method

1
2
3
wget --no-check- certificate --no-cookies --header "Cookie: oraclelicense=accept-securebackup-cookie" http://download.oracle.com/otn-pub/java/jdk/8u111-b14/jdk-8u111-linux-x64. rpm
# or
wget --no-cookie s --no-check-certificate --header "Cookie: gpw_e24=http%3A%2F%2Fwww.oracle.com%2F; oraclelicense=accept-securebackup-cookie" http://download.oracle.com/otn- pub/java/jdk/8u111-b14/jdk-8u111-linux-x64.rpm

The rpm package will be installed below

span>
1
rpm -ivh jdk-8u111-linux-x64.rpm

After installation, configure environment variables in the /etc/profile file

1

< /td>

vi /etc/profile

Add the following content

1
2
3
 export JAVA_HOME=/usr/java/default
export PATH=$PATH:$JAVA_HOME/bin
export CLASSPATH=.:$JAVA_HOME/jre/lib:$JAVA_HOME/lib:$JAVA_HOME/lib/tools.jar

View version number

1
java -version or javac -version

View environment variables

1
2
echo $PATH
#output /usr/local/sbin :/usr/local/bin:/usr/sbin:/usr/bin:/root/bin:/usr/java/default/bin

Install Tomcat

I downloaded tomcat 8.5, the download address is-http://tomcat.apache.org/download-80.cgi

1
wget http: //apache.fayea.com/tomcat/tomcat-8/v8.5.11/bin/apache-tomcat-8.5.11.tar.gz

Unzip

< span class="line">1
tar?zxvf apache-tomcat-8.5 .11.tar.gz

Transfer files

< td class="code">

mv apache-tomcat-8.5.11 /usr/local/tomcat
1

Run Tomcat

1
2
< /pre>
cd bin
./startup.sh

Stop Tomcat

1
< pre>./shutdown.sh

Install mysql

Download and install rpm

 1
2
3
cd /usr/local/src
wget http: //dev.mysql.com/get/mysql57-community-release-el7-9.noarch.rpm
rpm -ivh mysql57-community-release-el7-9 .noarch.rpm

Install mysql

1
yum install mysql-community-server

It took a long time to install mysql, but the internet was disconnected midway. It’s a tragedy

1
2
3
4
5
6
/var/run/yum.pid has been locked, and another program with PID 8095 is running. 
Another app is currently holding the yum lock; waiting for it to exit...
Another app The program is: yum
Memory: 88 M RSS (480 MB VSZ)
Started: Wed Mar 1 18:56:02 2017-Before 1:48:09
Status: Sleeping, Process ID: 8095


td>

Only delete the process

1
rm -rf /var/run/yum.pid

Before cleaning Re-download after caching

1
2
yum clean all 
yum install mysql-community-server

The following process is the same as the previous article-Centos7 mysql installation article

Install Nginx

First check the version that yum can install

1
yum info nginx

My version is 1.10.2, so I plan to use his

1
yum install nginx

Because you don’t need to install dependencies yourself, you can use commands to check the version after installation.

< pre>1
nginx -v

Open service

1
systemctl start nginx

View Status

< /tbody>

1
systemctl status nginx

Of course, you can also change the software source, first create a new repo, such as nginx.repo

< tr>

1
vim?/etc/yum.repos.d/nginx.repo

The editing content is as follows

1< /span>
2
3
4
5
[nginx]
name=nginx repo
baseurl =http://nginx.org/packages/mainline/centos/7/$basearch/
gpgcheck=0
enabled=1

The mainline version is configured here, if you want to use For the stable version, just delete the mainline in baseurl

Configure Nginx

Use yum to install nginx, the configuration file is in /etc/nginx/ nginx.confhere

1 
vi /etc/nginx/nginx.conf

Add listening port, because tomcat is port 8080

< table>

1
2
3
4
5< br>6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
server {
listen 80;
#listen [::]:80 default_server;
server_name www.maijinta. top;
root /usr/share/nginx/html;

< span class="line" > # Load configuration files for the default server block.
include /etc/nginx/defaul large column Centos configures the javaweb environment td/*.conf;

location / {
proxy_pass http://127.0 .0.1:8080;
}

error_page 404 /404.html;
location = /40x.html {
}

error_page 500 502 503 504 /50x.html;
location = /50x.html {
}
}

Then restart the service

< td class="gutter">
1

< /td>

Install Redis

The current stable version is 3.2.8, in fact, you should just download the stable version regardless of the version.

systemctl restart nginx
1
wget http://download.redis.io/releases/redis-stable.tar.gz

First you can determine whether tcl is installed

< tr>

1
rpm -qa tcl

Response instructions with version number

You can also use which tcl or whereis tcl

Next, unzip and move to the desired location< /p>

1
2
tar zxvf redis-stable.tar.gz 
mv redis-stable /usr/local/

Enter the redis directory and compile

< /tbody>

1
2
cd /usr/local/redis-stable
make

Then compile and check

 1
2
make test
#O/ All tests passed without errors will be prompted after success!

If it tells you something is missing, just install it

The compilation check lasts for a while, and you can Installed

1

make install

Execute after installation

1
redis-server

Seeing this picture shows success

< /table>

Set the redis service background to start, set in the configuration file redis.conf

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
 _._
_.-``__''-._
_ .-`` `. `_.''-._ Redis 3.2.8 (00000000/0) 64 bit
.-`` .-```. ```/ _.,_''-._
( ', .-` | `,) Running in standalone mode
< span class="line">|`-._`-...-` __...-.``-._|'` _.-'| Port: 6379
| `-._ `._ / _.-' | PID: 20631
`-._ `-._ `-./ _.-' _.-'
|`-._`-._ `-.__.-' _.-'_.-'|
| `-._`-._ _.-'_.-' | http://redis.io
`-._ `-._`-.__.-'_.-' _.-'
|`-._`-._ `-.__.-' _.-'_.-'|
| `-._ `-._ _.-'_.-' |
`-._ `-._`-.__.-'_.-' _.- '
`-._ `-.__.-' _.-'
`-._ _.-'
`-.__.-'
1
 daemonize yes #The default is no

Then start with this configuration

< figure class="highlight plain">

1

redis-server redis.conf

Check the process, and sure enough redis has started

p>

1
2
ps -aux #View all processes
ps -ef|grep redis #Just look at redis

< /figure>

Test with client

< td class="code">

redis-cli
set name frank
get name
1
2
3

Test successful

Close redis service

1
2
redis-cli shut down
pkill redis-server #kill the process

Modify the configuration file

1
2
3
vim redis.conf
#requirepass foobared #Remove the comment here and change the password , Such as requirepass 123456
#bind 127.0.0.1 #Add a comment to allow remote access

View network monitoring

< pre>1
netstat -nlt|grep 6379

See the network monitoring from 127.0.0.1:6379 becomes 0 0.0.0.0:6379, indicating that Redis has allowed remote login access

Change the password of redis-cli, the default is empty

p>

< td class="code">

execute redis-cli #login
execute config get requirepass
Get 1) "requirepass"
2) "" #It can be seen that there is no password
Execute config set requirepass 123456 #Set password
Need to log in again
Execute redis- cli -h 127.0.0.1 -p 6379 -a 123456 or redis-cli -a 123456
1
2
3
4
5
6
7

Startup configuration

1
echo "/usr/l ocal/redis-stable/redis-server /usr/local/redis-stable/redis.conf &" >> /etc/rc.local

Install vsftpd

Direct yum installation

< tbody>

1
yum -y install vsftpd

Start vsftpd Service

1
2
3
systemctl restart vsftpd.service # restart service
systemctl start vsftpd.service # start service
systemctl status vsftpd.service # Service status view

Modify configuration File

1
vim /etc/vsftpd/vsftpd.conf
1
2
3
4
5
6
7
8
9
10
11
12
anonymous_enable=NO # Disallow anonymous access, disable anonymous login
chroot_local_user=YES # Enable restricted users in their home directory
< span class="line">chroot_list_enable=YES
chroot_list_file=/etc/vsftpd/chroot_list< br>use_localtime=YES # When using local (add it yourself)
local_enable=YES # Allow the use of local accounts for FTP user login verification< /span>
allow_writeable_chroot=YES # If you enable limited users, you need to add this configuration in their home directory to solve the error 500 OOPS: vsftpd: refusing to run with writable root inside chroot()
xferlog_enable=YES # Enable the upload and download log function, which is enabled by default.
local_umask=022 # Set the default file mask for local users 022
# Local file permissions on FTP, The default is 077, but the default configuration file after vsftpd installation is 022
ascii_upload_enable=YES #Set support for ASCII mode upload and download functions
ascii_download_enable=YES

From After 2.3.5, vsftpd enhanced the security check. If the user is restricted to its home directory, the user’s home directory can no longer have write permissions

so add allow_writeable_chroot=YES

Create a new user

1
2
3
4
5
6
#Create user ftpuser and specify /var/ftp/public_root directory
useradd -d /var/ ftp/public_root -g ftp -s /sbin/nologin ftpuser
# Set the password of user ftpuser< /span>
passwd ftpuser
# Give the ownership of /home/vsftpd to ftpuser.root
# chown -R ftpuser.root /var/ftp/public_root No need to do this step, it should be fine if you do it

-s: Forbid this user to log in to SSH permissions

/sbin/nologin: This user is not allowed to log in to the system, but can log in FTP

Permission settings

1
2
3
4
< /span>
chown ftpuser /var/ftp/public_root

chmod -R 755 /var/ftp/public_root

< /figure>

Set boot and restart

1
systemctl enable vsftpd.service

Delete user

< td class="gutter">
1
userdel ftpuser

Finally, you can use it when you create a new site in Filezilla

WordPress database error: [Table 'yf99682.wp_s6mz6tyggq_comments' doesn't exist]
SELECT SQL_CALC_FOUND_ROWS wp_s6mz6tyggq_comments.comment_ID FROM wp_s6mz6tyggq_comments WHERE ( comment_approved = '1' ) AND comment_post_ID = 4879 ORDER BY wp_s6mz6tyggq_comments.comment_date_gmt ASC, wp_s6mz6tyggq_comments.comment_ID ASC

Leave a Comment

Your email address will not be published.