Deploy J2EE applications to Linux (practice success)

First, the need for a Linux server (cloud Ali, Tencent cloud, etc.) (CentOS, etc.)

Two, Linux remote connectivity tools: SecureCRT

1, Hostname: Server Address

2, Port: 22 (default)

3, Username: root (default)

connection

 

Third, install FTP

1, Linux command: yum insatll vsftpd -y

Start Service: systemctl start vsftpd.service

Close Services: systemctl stop vsftpd.service

Check the service status: systemctl status vsftpd.service

Check the port is listening (running): netstat -anp | grep 21

 

2, ftp create user

2.1, create a user ftp directory (files are uploaded to the directory)

mkdir -p  /home/ftptest

2.2, create a directory for the user

useradd -d /home/ftptest -g ftp -s /sbin/nologin/ ftptest

(-G ftp ftp means that the user belongs to the group (ftp packet is built, there would have been no need to create their own)
-s / sbin / nologin indicates that the user can not log in to this client secureCRT. This can not landing users also known as virtual user
creation process gives a warning message is normal, it does not matter)

2.3, set the directory permissions

chown -R ftptest /home/ftptest

chmod -R 775 /home/ftptest

(The directory / home / wwwroot / ftptest owner is set to ftptest, the ftptest users have read-write access to this directory)

2.4, set a password for the user

password ftptest

 

3, the configuration of the server user vsftpd

3.1 does not allow anonymous users to log in, open the configuration file: vi /etc/vsftpd/vsftpd.conf

The anonymous_enable = YES to anonymous_enable = NO

ESC to exit edit mode, Shift +; enter the command mode, wq save and quit, q to exit without saving;

Limit user access (to prevent switching of sensitive directory): Open the configuration file: vi /etc/vsftpd/vsftpd.conf

turn up:

#chroot_list_enable=YES

# (default follows)

#chroot_list_file=/etc/vsftpd.chroot_list

And amended as follows:

chroot_list_enable=YES

# (default follows)

chroot_list_file=/etc/vsftpd/chroot_list

3.2, adding users: Open chroot_list file, vi / etc / vsftpd / chroot_list

Add a line: ftptest

Open vsftpd.conf

The last line add: allow_writeable_chroot = YES

3.3, configure the FTP server port

we /etc/vsftpd/vsftpd.conf

Finally, add

pasv_enable = YES

pasv_min_port = 30000

pasv_max_port = 30010

3.4, user authentication

Because the user is ftptest nologin, so there is a problem authenticating. If the authentication problem is not solved, it is the never-ending error 530

we /etc/pam.d/vsftpd

Comment out #auth required pam_shells.so

In this way not authenticated, thereby allowing the user to log ftptest this nologin ftp server.

 

4, restart the FTP server

systemctl restart vsftpd.service

systemctl status vsftpd.service

This: have open ports: 22,3389 ( 22 is the port number SecureCRT Linux servers linked with; 3389 is the port that links with Ali cloud console, is not used here ), then open: 21,30000 ~ 30010 ports.

 

Fourth, install JAVA

yum -y install java-1.8.0-openjdk.x86_64

java -version

 

Five, MySQL

1, the installation:

Mysql yum resources on the problem, so it can not just use yum, yum before using the need to use other mysql command to get Community Edition

cd /tmp

wget http://repo.mysql.com/mysql-community-release-el7-5.noarch.rpm

rpm -ivh mysql-community-release-el7-5.noarch.rpm

installation:

yum install mysql mysql-server mysql-devel -y

start up:

systemctl start mysql.service

verification:

-anq netstat | grep 3306

(Running in Monitor Description)

 

2, set a password and log

mysqladmin -u root password admin

log in

mysql -uroot -padmin

Display Database

show databases

 

Six, Tomcat

1, the installation

(Currently: Download tar.gz decompression with the use ftp to the server)

2, run

tomcat directory: /tomcat/bin/startup.sh

3. Verify

netstat -anp|grep 8080

4, view the boot log

tail -300f /usr/local/tomcat7/logs/catalina.out

5, open port access: 8080

 

Seven, application deployment

1, the transfer application folders or files to the war package ftp server and sql

2、MySQL:

2.1, to solve the case sensitive:

Open the mysql configuration file: vi /etc/my.cnf

Add add [mysqld] After

lower_case_table_names=1

Restart: systemctl restart mysqld.service

2.2, create a database

First, connect to the database

mysql -uroot -padmin

Then create a database

CREATE DATABASE tmall DEFAULT CHARACTER SET utf8;

Finally, view the database already exists

show databases;

ctrl + c to exit the console

Import Data:

mysql -u root -padmin --default-character-set=utf8 tmall < /home/wwwroot/ftptest/tmall.sql

Re-log into mysql, use the following command to verify that the import was successful

mysql -uroot -padmin

use tmall;

show tables;

select count(*) from product;

 

3、Tomcat

Use vi Open server.xml

we /usr/local/tomcat7/conf/server.xml

Then add the line <host below

<Context path="/tmall" docBase="/home/wwwroot/ftptest/tmall/web" debug="0" reloadable="false" />

After modifications are complete, save and exit.

Restart tomcat

/usr/local/tomcat7/bin/shutdown.sh

/usr/local/tomcat7/bin/startup.sh

 

The last visited page detect it.

 

Another: from the start:

ftp:

systemctl enable vsftpd.service

mysql:

systemctl enable mysqld.service

(Off mode:

systemctl disable vsftpd.service

systemctl disable mysqld.service

tomcat (using a script):

There is a file called rc.local, put the script into the family to stay.

But this script centos7 Lane was downgraded, and can not be executed, so to execute the following statement so that it can be carried out first

chmod +x /etc/rc.d/rc.local

Then modify /etc/rc.d/rc.local, tomcat script can be placed

we /etc/rc.d/rc.local

Add to:

/usr/local/tomcat7/bin/startup.sh

 

Published 22 original articles · won praise 6 · views 4876

Guess you like

Origin blog.csdn.net/qq_37651252/article/details/102727086