Guide for building the JavaEE environment on the CentOS server (Remote Desktop + JDK + Tomcat + MySQL) and centosjavaee

Source: Internet
Author: User
Tags centos server

Guide for building the JavaEE environment on the CentOS server (Remote Desktop + JDK + Tomcat + MySQL) and centosjavaee
--------------------------------------------------------------------------------
1. system settings:

1.1 remote desktop settings: Set in the window
System -- preferences -- Remote Desktop
Select: allow other users to control your desktop
Cancel: You must confirm each access for this machine
Set access password

1.2 Set firewall
System -- Management -- firewall -- Option
Disable the firewall.
// Command method: Firewall shutdown and startup
/Etc/init. d/iptables status
/Etc/init. d/iptables stop
Permanently disable the Firewall:
Chkconfig -- level 35 iptables off
Service iptables stop
// Add port 8080 to the firewall configuration, regardless of the firewall. perform the following operations:
[Root @ localhost ~] # Vi +/etc/sysconfig/iptables
# Add the following code
-A RH-Firewall-1-INPUT-m state -- state NEW-m tcp-p tcp -- dport 8080-j ACCEPT
// Restart the Firewall
[Root @ localhost ~] # Service iptables restart

--------------------------------------------------------------------------------

2. Install JDK:

Jdk-7u45-linux-i586.rpm
// Switch the root user
[Root @ localhost ~] # Su root
// Enter the downloaded rpm directory and execute the following command
[Root @ localhost ~] # Rpm-ivh jdk-7u45-linux-i586.rpm
// Edit system environment variables
[Root @ localhost ~] # $ Vi/etc/profile
// Input o and add the following content at the end: wq (save and quit), q! (Exit without saving)
JAVA_HOME =/usr/java/jdk1.7.0 _ 45
JRE_HOME =/usr/java/jdk1.7.0 _ 45/jre
PATH = $ PATH: $ JAVA_HOME/bin: $ JRE_HOME/bin
CLASSPATH =.: $ JAVA_HOME/lib/dt. jar: $ JAVA_HOME/lib/tools. jar: $ JRE_HOME/lib
[Root @ localhost ~] # Export JAVA_HOME JRE_HOME PATH CLASSPATH
// Make the environment variable take effect immediately
[Root @ localhost ~] # $ Source/etc/profile
// Test whether the installation is successful. Enter java, java-version, and javac in sequence to view the output information, such
[Root @ localhost ~] # Java
[Root @ chenpc-cent tools] # java-version

--------------------------------------------------------------------------------

3. install apache-tomcat

Apache-tomcat-7.0.54.tar.gz
// Enter the downloaded apache-tomcat directory and execute the following command
[Root @ localhost ~] # Tar-zxv-f apache-tomcat-7.0.54.tar.gz // extract the compressed package
[Root @ localhost ~] # Rm-rf apache-tomcat-7.0.54.tar.gz // Delete package
// Move the apache-tomcat directory to/usr/local/and execute the following command
[Root @ localhost ~] # Mv apache-tomcat-7.0.54/usr/local/apache-tomcat-7.0.54
(If it cannot be moved, you can also create a directory: mkdir-p/usr/local/apache-tomcat-7.0.54)

// Add Environment Variables
CATALINA_BASE:/usr/local/apache-tomcat-7.0.54
CATALINA_HOME:/usr/local/apache-tomcat-7.0.54
CATALINA_TMPDIR:/usr/local/apache-tomcat-7.0.54/temp
JRE_HOME:/usr/java/jdk1_7_45/jre
CLASSPATH:/usr/local/apache-tomcat-7.0.54/bin/bootstrap. jar:/usr/local/apache-tomcat-7.0.54/bin/tomcat-juli.jar

// Start tomcat
[Root @ localhost ~] #/Usr/local/apache-tomcat-7.0.54/bin/startup. sh
// View the startup log
[Root @ localhost ~] #/Usr/local/apache-tomcat-7.0.54/logs/catalina. out

Verify Tomcat installation and running
// Check whether tomcat works properly at the following address:
Http: // 127.0.0.1: 8080/
// The tomcat System Interface is displayed, indicating that the installation is successful!
// Stop Tomcat
[Root @ localhost ~] #/Usr/local/apache-tomcat-7.0.54/bin/shutdown. sh

Set to enable auto-start:
[Root @ localhost ~] # Vi/etc/rc. d/rc. local
Export JAVA_HOME =/usr/java/jdk1.7.0 _ 45
Export CLASSPATH =.: $ JAVA_HOME/jre/lib/rt. jar: $ JAVA_HOME/lib/dt. jar: $ JAVA_HOME/lib/tools. jar
Export PATH = $ PATH: $ JAVA_HOME/bin
Export CATALINA_HOME =/usr/local/apache-tomcat-7.0.54
# Tomcat self-start
/Usr/local/apache-tomcat-7.0.54/bin/startup. sh


--------------------------------------------------------------------------------
4. Install Mysql

MySQL-5.6.20-1.el6.x86_64.rpm-bundle.tar
Check whether mysql is installed: rpm-qa | grep mysql
// View the current mysql process of the system
[Root @ localhost ~] Ps aux | grep mysq *
// If other mysql versions have been installed or reinstalled, delete all directory residues of mysql and execute the following command
Rpm-e -- nodeps MySQL-server-5.6.17-1.el6.i686
Rm-rf/var/lib/mysql
Rm-rf/usr/lib/mysql
Rm-rf/home/undoner/mysqldata (mysqldata can also be used to customize other folders)
Rm-rf/etc/my. cnf
Rm-rf/usr/my. cnf
Rm-rf/root/. mysql_secret

There are three installation methods:
A default RPM installation method (use the default configuration)
B custom RPM installation (custom database path, my. cnf configuration, log Path, etc)
C. Use the source code compilation package for custom installation (not included)
D. Use CentOS built-in yum tool for automatic installation (earlier version)

--------------------------------------------------------
A default RPM installation method (use the default configuration)
// Enter the downloaded mysql directory and execute the following command
[Root @ localhost ~] # Cd/home/undoner/software
// Decompress the compressed package
[Root @ localhost ~] # Tar-xvf MySQL-5.6.20-1.el6.x86_64.rpm-bundle.tar
// Run the rpm file, which must be installed on the server.
[Root @ localhost ~] Cd/home/undoner/software/
[Root @ localhost ~] Rpm-iv MySQL-server-5.6.20-1.el6.x86_64.rpm
[Root @ localhost ~] Rpm-iv MySQL-client-5.6.20-1.el6.x86_64.rpm
[Root @ localhost ~] Rpm-iv MySQL-devel-5.6.20-1.el6.x86_64.rpm
(If you install mysql directly, no default mysql group or mysql user is displayed)
Option: Add mysql groups and users.
[Root @ localhost ~] # Groupadd mysql
[Root @ localhost ~] # Useradd-g mysql
[Root @ localhost ~] # Passwd mysql // change the User Password

* ****************** Description of the default installation directory of mysql
/Var/lib/mysql database file
/Usr/share/mysql command and configuration file
/Usr/bin (commands such as mysqladmin and mysqldump)

* ***************** Modify/var/lib/mysql Permissions
// Any user in this directory has all Permissions
[Root @ localhost ~] Chmod-R 777/var/lib/mysql
// Alternative: If a mysql user is created, change the directory owner from root to mysql.
[Root @ localhost ~] Chown-R mysql/var/lib/mysql

* ****************** Start mysql:
[Root @ localhost ~] Service mysql status
Result: "SUCCESS" is running.
"FAILED" is not running
Start: [root @ localhost ~] Service mysql start
Close: [root @ localhost ~] Service mysql stop

* ***************** Other MySQL service commands
A. Check whether mysql is in the auto start list: #/sbin/chkconfig -- list
B. add mysql to the system self-starting service group: #/sbin/chkconfig -- add mysql
C. Delete mysql from the startup Service Group: #/sbin/chkconfig -- del mysql
D. stop the mysql service: # service mysql stop
E. Run the script to start the mysql service: #/etc/rc. d/init. d/mysqld start
F. Run the script to stop the mysql service: #/etc/rc. d/init. d/mysqld stop
// Start automatically by default! 2-5 is enabled
[Root @ localhost ~] /Sbin/chkconfig -- list

// View the current Default root Account Password (random value generated by installation)
[Root @ localhost ~] Vim/root/. mysql_secret
// Copy the current root account password and log on to mysql
[Root @ localhost ~] Mysql-uroot-p
// Change the current password after logging on to mysql
Mysql> set password = PASSWORD ('root ');
Mysql> show databases;
Mysql> quit
// Use the new password "root" to log on again to check whether remote connection is allowed (denied by default) and add the remote root user access permission.
Mysql> use mysql;
Mysql> select host, user, password from user;
Mysql> grant all privileges on *. * to root @ "%" identified by 'root' with grant option;
Change the default MySQL character set (the default character set is the same as the operating system character set, so you do not need to set it)
// View the mysql character set:
Mysql> show variables like 'character _ set _ % ';
// Add the mysql configuration file and set the default encoding Character Set
[Root @ localhost ~] Service mysql stop
[Root @ localhost ~] Cp/usr/share/mysql/my-default.cnf/etc/my. cnf
[Root @ localhost ~] Vim/etc/my. cnf
[Mysql]
Default-character-set = utf8
[Client]
Port = 3306
Socket =/var/lib/mysql. sock
Default-character-set = utf8
[Mysqld]
Bind-address = 0.0.0.0
User = root
Port = 3306
Default_storage_engine = InnoDB
Character-set-server = utf8
Lower_case_table_names = 1
Socket =/var/lib/mysql. sock
...
[Root @ localhost ~] Service mysql start
[Root @ localhost ~] Mysql-uroot-p
// Log on again to view the default mysql Encoding
Mysql> show variables like 'character _ set _ % ';
// View mysql Log Information
Cat/var/lib/mysql/localhost. localdomain. err


**************************************** *****************
// Modify/etc/init. d/mysql. If it is null by default, it indicates the directory. You do not need to change it.
Vi/etc/init. d/mysql
Datadir =/var/lib/mysql
Basedir =/var/lib/mysql
Mysql_install_db -- user = root -- basedir =/var/lib/mysql -- datadir =/var/lib/mysql-defaults-file =/etc/my. cnf
**************************************** *****************

--------------------------------------------------------

B custom RPM installation (custom database path, my. cnf configuration, log Path, etc)

// Enter the downloaded mysql directory and execute the following command
[Root @ localhost ~] # Cd/home/undoner/software
[Root @ localhost ~] # Tar-xvf MySQL-5.6.17-1.el6.i686.rpm-bundle.tar // extract the compressed package

// Run the rpm file
[Root @ localhost ~] Cd/home/undoner/software/
[Root @ localhost ~] Rpm-iv MySQL-server-5.6.17-1.el6.i686.rpm
[Root @ localhost ~] Rpm-iv MySQL-client-5.6.17-1.el6.i686.rpm
[Root @ localhost ~] Rpm-iv MySQL-devel-5.6.17-1.el6.i686.rpm

// Modify the data storage path and put the default mysql database file in your home directory:
[Root @ localhost ~] Cp-r/var/lib/mysql/home/undoner/mysqldata

// Modify the default configuration file
[Root @ localhost ~] Vi/etc/my. cnf
/Usr/share/mysql/my-huge.cnf is the built-in template configuration file, modify Add the following content:
[Root @ localhost ~] Vi/etc/my. cnf
My. cnf file content:
[Mysql]
# CLIENT #
Port = 3306
Socket =/home/undoner/mysqldata
Default-character-set = utf8
[Mysqld]
# GENERAL #
Bind-address = 0.0.0.0
Port = 3306
# Datadir =/var/lib/mysql
# Data storage #
Datadir =/home/undoner/mysqldata
Basedir =/home/undoner
# Socket =/var/lib/mysql. sock
Socket =/tmp/mysql. sock
Default_storage_engine = InnoDB
Character-set-server = utf8
User = root
# Disabling symbolic-links is recommended to prevent assorted security risks
Symbolic-links = 0
# MyISAM #
Key_buffer_size = 32 M
Myisam_recover = FORCE, BACKUP
# SAFETY #
Max_allowed_packet = 16 M
Max_connect_errorrs = 1000000
Skip_name_resolve
# Binary logging #
# Log_bin =/data/mysql-bin
Expire_logs_days = 14
Sync_binlog = 1
# Caches and limits #
Tmp_table_size = 32 M
Max_heap_table_size = 32 M
Query_cache_type = 0
Query_cache_size = 0
Max_connections = 500
Thread_cache_size = 50
Open_files_limit = 65535
Table_definition_cached = 1024
Table_open_cache = 2048
# INNODB #
Innodb_flush_method = O_DIRECT
Innodb_log_files_in_group = 2
Innodb_log_file_size = 256 M
Innodb_flush_log_at_trx_commit = 1
Innodb_file_per_table = 1
Innodb_buffer_pool_size = 10G
Innodb_thread_concurrency = 12
Thread_handling = pool-of-threads
# Auto_increment_increment = 2
# Auto_increment_offset = 0
# LOGGING #
Log_error =/tmp/mysql-error.log
Log_queries_not_using_indexes = 1
Slow_query_log = 1
# Slow_query_log_file =/tmp/mysql-slow.log
[Mysqld_safe]
Log-error =/tmp/mysql. log
Pid-file =/tmp/mysql. pid

// Directly copy the modified configuration file my. cnf to the/etc/directory.
[Root @ localhost ~] Cp/my. cnf/etc/my. cnf

// Modify/home/undoner/mysqldata Permissions
// Any user in this directory has all Permissions
[Root @ localhost ~] Chmod-R 777/home/undoner/mysqldata
// Modify the directory owner to a mysql user
[Root @ localhost ~] Chown-R mysql/home/undoner/mysqldata

// Execute the mysql database installation operation and specify the datadir directory we have defined:
[Root @ localhost ~] Mysql_install_db -- datadir =/home/undoner/mysqldata

// Start the database:
[Root @ localhost ~] Mysqld
Fatal error: Please read "Security" section of the manual to find out how to run mysqld as root!
If the above error occurs, add mysqld in/etc/my. conf.
User = root

// Log on to the database
Mysql-h127.0.0.1-P3371-uroot-p
// No password by default

// Change the password:
Sudo mysqladmin-h127.0.0.1-uroot password root
Or
Enter the password. The initial root password is saved in the '/root/. mysql_secret' file.
Log on to mysql and enter mysql> set password = PASSWORD ('root ');

Ln-s/home/undoner/mysqldata/var/lib/
// Modify/etc/init. d/mysql
Vi/etc/init. d/mysql
Datadir =/home/undoner/mysqldata
Basedir =/home/undoner

Run the command: #/etc/rc. d/init. d/mysql status
Result: "SUCCESS" is running.
"FAILED" is not running

// Configure the remote access and database code, which is the same as that installed on side A. view the error log information:
Cat/home/undoner/mysqldata/localhost. localdomain. err

Bytes ----------------------------------------------------------------------------------------------------------

**************************************** **********************
// Install the Chinese Input Method
[Root @ admin java] # yum install "@ Chinese Support"

// View the number of places in your system in centos
[Root @ localhost ~] # Uname-
Linux localhost. localdomain 2.6.18-164. el5 #1 SMP Thu Sep 3 03:33:56 EDT 2009 i686 i686 i386 GNU/Linux
[Root @ localhost ~] # Getconf WORD_BIT
32
[Root @ localhost ~] # Echo $ HOSTTYPE
I686
This is my machine. If it is 64-bit, the first and third commands will display: x86_64

// Check the number of JDK digits in centos.
# Java-version
Java version "1.6.0 _ 26"
Java (TM) SE Runtime Environment (build 1.6.0 _ 26-b03)
Java HotSpot (TM) Server VM (build between 1-b02, mixed mode)
If it is 64-Bit, the last line will display 64-Bit
# Java-version
Java version "1.6.0 _ 26"
Java (TM) SE Runtime Environment (build 1.6.0 _ 26-b03)
Java HotSpot (TM) 64-Bit Server VM (build between 1-b02, mixed mode)

Bytes ---------------------------------------------------------------------------------------------------------
// Configure the vncserver:
Change the execution permission:
Sudo chmod u + rwx/etc/sysconfig/vncservers
// Modify the configuration file
Su root
Vi/etc/sysconfig/vncservers
// The number 1 corresponds to the connection time, for example, 192.168.1.101: 1
VNCSERVERS = "1: undoner"
VNCSERVERARGS [1] = "-geometry 1024x768-nolisten tcp"
How can I build an apache + php + mysql website running environment through the remote service of the pure centos system ??

You can go to wdlinux to check that there is a one-click installation package.

Question Tag: Linux CentOS 62 Remote Server jdk installation fails.

The file is down.

Your question (answer) is too simple. Please enrich the content and submit it again

Related Article

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.