0 Base deployment of Javaweb projects on Linux servers

Source: Internet
Author: User
Tags save file filezilla java web

Download link for the tool used in this tutorial: Http://pan.baidu.com/s/1sl1qz2P Password: 43PJ

I. Installing the JDK

1, first to see the server version of the system, is 32-bit or 64-bit

[Plain]View PlainCopy
    1. #getconf Long_bit
    2. 64

2. Download the 64-bit version of the JDK

: http://www.Oracle.com/technetwork/Java/javase/downloads/jdk8-downloads-2133151.html

Version: jdk-8u91-linux-x64.rpm

3, using FTP tools such as FILEZILLA,XFTP,WINSCP, download good files to the server, I was uploaded to the home folder

4. See if you currently have a JDK installed

[HTML]View PlainCopy
    1. #rpm-qa |grep JDK
    2. jdk-1.7.0_65-fcs.i586

? [HTML]View PlainCopy
    1. #rpm-qa |grep JDK
    2. jdk-1.7.0_65-fcs.i586
?

If any, remove

[HTML]View PlainCopy
    1. #rpm-E jdk-1.7.0_65-fcs.i586

5, enter the installation command, do not need to give permission, can directly execute

[HTML]View PlainCopy
    1. #rpm-ivh/home/jdk-8u91-linux-x64.rpm

6. Set Environment variables (add at end of file)

[HTML]View PlainCopy
    1. #vim/etc/profile
    2. Export java_home=/usr/java/jdk1.8.0_91
    3. Export classpath=.: $JAVA _home/lib/dt.jar: $JAVA _home/lib/tools.jar
    4. Export path= $PATH: $JAVA _home/bin
    5. Export Java_home CLASSPATH PATH

Wq save file and Exit VI

7. Enter the command to check if the settings are installed (no need to restart the server)

[HTML]View PlainCopy
    1. #java-version
    2. #java
    3. #javac


Two. Tomcat Configuration deployment

1. Download Tomcat

Select the tar.gz package download below core

2. Upload and install

I put the uploaded software in the home folder, decompression can be installed, installation directory I put it under the/usr/local

[HTML]View PlainCopy
    1. #tar-ZXVF apache-tomcat-8.0.33.tar.gz//Unzip file or: Tar xvf apache-tomcat-8.0.33.tar.gz
    2. #cp-R apache-tomcat-8.0.33/usr/local/tomcat//move and rename

3. Enter directory cd/usr/local/tomcat/bin/, start and test tomcat

[HTML]View PlainCopy
    1. #./startup.sh//execute this command in the Tomcat Bin directory and display the following information
    2. Using catalina_base:/usr/local/tomcat
    3. Using Catalina_home:/usr/local/tomcat
    4. Using Catalina_tmpdir:/usr/local/tomcat/temp
    5. Using Jre_home:/usr/java/jdk1.7.0_67
    6. Using CLASSPATH:/usr/local/tomcat/bin/bootstrap.jar:/usr/local/tomcat/bin/tomcat-juli.jar
    7. Tomcat started.

Test: Access http://ip:8080, check whether the port is successful, if not successful,

[HTML]View PlainCopy
    1. #netstat-ano|grep 8080

You can modify the port number in the/conf/server.xml if the ports are occupied

Use./stratup.sh start to see the detailed log information, if you want to see the details, you can use the./catalina.sh run to start, you can view the boot information like in the

4, under the/usr/local/tomcat/bin has the executable procedure
Start Tomcat #./startup.sh
Close Tomcat #./shutdown.sh

5. See if Tomcat starts

[HTML]View PlainCopy
    1. # Ps-ef |grep Tomcat

If you return a message similar to the following, Tomcat does not start

[HTML]View PlainCopy
    1. 502 19258 8770 0 7:14 pm ttys000 0:00.01 grep Tomcat

If a return similar to the following information appears, it means that Tomcat is started, the first one is the user who started the process, the second is the ID of the process, and the third is the percentage of CPU consumed.
The fourth one is the percentage of memory consumed

[HTML]View PlainCopy
  1. root      2078     1 33 09:32  pts/0    00:00:01 /usr/java/jdk1.8.0_91/bin/java - Djava.util.logging.config.file=/usr/local/tomcat/conf/logging.properties - Djava.util.logging.manager=org.apache.juli.classloaderlogmanager -djava.endorsed.dirs=/usr/local/tomcat/endorsed -classpath /usr/local/tomcat/bin/ Bootstrap.jar:/usr/local/tomcat/bin/tomcat-juli.jar -dcatalina.base=/usr/local/ Tomcat -dcatalina.home=/usr/local/tomcat - djava.io.tmpdir=/usr/local/tomcat/temp org.apache.catalina.startup.bootstrap start  
  2. Root 2091 2019 0 09:32 pts/0 00:00:00 grep --color=auto Tomcat


6. How to set up tomcat boot

1, modify the/etc/rc.d/rc.local
Vi/etc/rc.d/rc.local
2, add the following two lines of script, remember that is two lines, only the second line is not, you must add the first row.

At the end of the/etc/rc.d/rc.local file, add

[HTML]View PlainCopy
    1. Export java_home=/usr/java/jdk1.8.0_91
    2. /usr/local/tomcat/bin/startup.sh start

Description:/usr/java/jdk1.8.0_91 is the JDK installation directory
/usr/local/tomcat is a tomcat-installed directory
3, note, enter/ETC/RC.D modify rc.local file for executable, such as: chmod +x rc.local

Three. Deployment of Java Web Apps

Export the Web application into the war package file in Eclipse and copy it into the Tomcat/wabapps directory
The folder of the referenced items is also tested in the Tomcat/wabapps directory
Start Tomcat again after shutting down
Enter HTTP://IP address when accessing: 8080/war file name/....
For example, the war file is named Wapinfo.war
Then enter HTTP://IP address: 8080/wapinfo/....
To access

Four. Installation and configuration of MySQL database (method two: please go to http://blog.csdn.net/u011019141/article/details/70925749 view)

1. Download the database software

Address: Http://dev.mysql.com/downloads/mysql/5.6.html#downloads

I am here because it is a 64-bit operating system, so choose to download the following RPM package:

mysql-server-5.6.30-1.linux_glibc2.5.x86_64.rpm

mysql-client-5.6.30-1.linux_glibc2.5.x86_64.rpm

mysql-devel-5.6.30-1.linux_glibc2.5.x86_64.rpm

2. Upload these RPM packages to a directory on the Linux server via FileZilla, for example:/usr/local/mysql.

3. Start installing the MySQL server using the following command under Path/usr/local/mysql:

[HTML]View PlainCopy
    1. RPM-IVH mysql-server-5.6.30-1.linux_glibc2.5.x86_64.rpm

4, after the server installation is complete, use the following command to install the MySQL client, the command is as follows:

[HTML]View PlainCopy
    1. RPM-IVH mysql-client-5.6.30-1.linux_glibc2.5.x86_64.rpm

5, then install mysql-devel-5.6.30-1.linux_glibc2.5.x86_64.rpm, the command is as follows:

[HTML]View PlainCopy
    1. RPM-IVH mysql-devel-5.6.30-1.linux_glibc2.5.x86_64.rpm

6, after the installation is complete, MySQL is not started, run MySQL command will prompt the following error:

[HTML]View PlainCopy
    1. [[email protected] software]# MySQL
    2. ERROR 2002 (HY000): Can ' t connect to local MySQL server through socket '/var/lib/mysql/mysql.sock ' (2)

You can start MySQL using the following command:

[HTML]View PlainCopy
    1. Service MySQL Start

or use the following command:

[HTML]View PlainCopy
    1. /etc/init.d/mysql start

7. This determines that MySQL has successfully installed the service has started

MySQL installation successfully, modify the initial password (online said there is no initial password, but I have, forget to save in which file)
Stop your MYSLQ services first, service MySQL stop or/etc/init.d/mysqld stop

(1). If there is no root privilege, in this case we can modify the initial password in a way similar to safe mode
Execute command First Mysqld_safe--skip-grant-tables & (set to Safe mode)
&, that means running in the background, no longer running in the background, then open a terminal.
# MySQL
mysql> use MySQL;
mysql> UPDATE user SET Password=password ("test123") WHERE user= ' root '; (You will be prompted to modify the successful query OK)
mysql> flush Privileges;
Mysql> exit;
(2). Outside the MySQL system, use the Mysqladmin
# mysqladmin-u root-p Password "test123"
Enter Password: "Enter the original password"
(3). The MySQL system can be logged in the case by logging in to the MySQL system to modify
# mysql-uroot-p
Enter Password: "Enter the original password"
Mysql>use MySQL;
mysql> Update user Set Password=password ("test") where user= ' root ';
mysql> flush Privileges;
Mysql> exit;

Modify database encoding to modify the MySQL configuration file
VI/ETC/MY.CNF #根据个人配置找到相应文件
#在 [Client] segment add the following code
Default-character-set=utf8
#在 [mysqld] Segment add the following code
#default-storage-engine=innodb #置默认存储引擎为InnoDB, there is no need to add
Character-set-server=utf8
Collation-server=utf8_general_ci
: wq! #保存退出

=============================================================================================================== =

1, Linux under the installation of MySQL is the default: distinguish the case of the table name, do not distinguish between the case of the column name;
2, with the root account login, in the/ETC/MY.CNF [mysqld] After adding add Lower_case_table_names=1, restart the MySQL service, this time has been set success: not distinguish between the case of the table name;
Lower_case_table_names parameter Details:
Lower_case_table_names=0
Where 0: Case sensitive, 1: Case insensitive


MySQL under Linux database name, table name, column name, alias casing rules are like this:
1, database name and table name are strictly case-sensitive;
2, the table alias is strictly case-sensitive;
3, the column name and the alias of the column in all cases are ignored case;
4, variable names are also strictly case-sensitive;
MySQL is case insensitive under Windows.

=============================================================================================================== ===

8. There are many ways to set up boot, such as using the Chkconfig command, or you can add the following MySQL startup command in the/etc/rc.local file, for example:

[HTML]View PlainCopy
    1. /etc/init.d/mysql start

===============================================================================================

To create a remote login user and authorize, enter the following command at the command prompt at MySQL:

[HTML]View PlainCopy
    1. MySQL > use MySQL;
    2. MySQL > Grant all privileges in discuz.* to [email protected] ' 123.123.123.123 ' identified by ' 123456 ';
    3. MySQL > exit;


The above statement means that all permissions to the Discuz database are granted to the TED user, allowing the TED user to remotely log on to the 123.123.123.123 IP and set the TED user's password to 123456.

All privileges means giving all permissions to the specified user, which can also be replaced by assigning a specific permission, such as: Select,insert,update,delete,create,drop, and so on, with the "," half-width comma separated by the specific permissions.

Discuz.* means that the above permissions are for which table, discuz refers to the database, followed by the * for all tables, it can be inferred that: for all of the database is authorized as "*. *" For all tables, the entire table for a database is authorized as "database name. *", A table for a database is authorized as the database name. Table name.

Ted indicates which user you want to authorize, and this user can be either an existing user or a non-existent user.

123.123.123.123 represents the IP address that allows remote connections, or "%" if you want to limit the IP of the link.

123456 is the user's password.

such as: Grant all privileges on * * to [email protected] '% ' identified by ' 1 ';

After executing the above statement, execute the following statement before it can take effect immediately.

Flush privileges;

0 Base deployment of Javaweb projects on Linux servers

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.