Method for installing mysql jdk and tomcat under CentOS

  • 2020-05-12 06:38:38
  • OfStack

Create a personal folder


#  use  yum  The installation tomcat  and  mysql 
#  Create folder  
cd /usr/local 
mkdir hehe 

1. Install rzsz


# 1.  The installation rzsz 
yum list lrzsz* 
yum install lrzsz -y 

2. The installation of JDK, path and so on has been set up automatically


# 2.  The installation JDK 
yum list java* 
yum install java-1.7.0-openjdk* -y 

3. Install mysql


# 3.  The installation mysql 
yum list mysql* 
yum install mysql-server* -y 
#  Modify the  /etc/my.cnf  Set the default database encoding and storage location , Optimize the memory configuration if possible  
vi /etc/my.cnf 

3.1 the general mysql configuration file is as follows:


[mysqld] 
# datadir=/var/lib/mysql 
datadir=/usr/local/hehe/mysql_data 
socket=/var/lib/mysql/mysql.sock 
user=mysql 
# Disabling symbolic-links is recommended to prevent assorted security risks 
symbolic-links=0 
default-character-set=utf8 
[mysqld_safe] 
log-error=/var/log/mysqld.log 
pid-file=/var/run/mysqld/mysqld.pid 
[mysql] 
default-character-set=utf8 

Among them, vi enters command mode by default. To enter edit mode, you can use the button "i" to represent insert and insert mode.
Exit edit mode, use Esc key, exit edit mode, will be in command mode, command mode input in the command mode will not be added to the content,

In command mode, directly enter the line number, such as 22, enter, and the cursor will jump to line 22. Using the colon plus command, you can perform related operations, such as


:wq  Means to write to a file and exit  
:wq!  Means force to write to a file and exit, suitable for read-only files or something.  
:q  Exit without saving  

Remember the enter key.

For memory Settings for MySQL, you can also see: MySQL 5.6 initial configuration tuning

Of course, if you don't consider the mobility, it is recommended to use the MySQL of aliyun, which is 5 yuan per month, which is very easy to worry about. If you use other cloud platforms, you can also use cloud services with high performance and low price to save time, worry and effort.

4. Install tomcat


# 4.  The installation  tomcat 
cd /usr/local 
wget http://mirrors.hust.edu.cn/apache/tomcat/tomcat-7/v7.0.63/bin/apache-tomcat-7.0.63.tar.gz 
tar -zxf apache-tomcat-7.0.63.tar.gz 
mv apache-tomcat-7.0.63 tomcat 

4.1 modify the configuration file


cd /usr/local/tomcat/conf 
#  Modify the configuration file  server.xml, No Chinese . 
#  Configure the port number and bind the domain name , Alias, as well as setting thread pool, map context folder  
vi server.xml 

Of course, you can use ftp or other tools to download it to windows, edit it, and then upload it back. Remember to change the code to UTF-8 if you have Chinese comments or anything else. Otherwise, you can use the default ANSI.


<Service name="Catalina"> 
lt;Executor name="tomcatThreadPool" namePrefix="catalina-exec-" 
maxThreads="250" minSpareThreads="20"/> 
<Connector port="80" protocol="HTTP/1.1" 
connectionTimeout="20000" 
redirectPort="8443" 
compression="on" 
compressionMinSize="2048" 
noCompressionUserAgents="gozilla,traviata" 
compressableMimeType="text/html,text/xml,text/javascript,text/css,text/plain,application/json,application/javascript,application/x-javascript" 
/> 
<Connector port="8009" protocol="AJP/1.3" redirectPort="8443" executor="tomcatThreadPool"/> 
<Engine name="Catalina" defaultHost="wwwhehe.com"> 
<Realm className="org.apache.catalina.realm.UserDatabaseRealm" 
resourceName="UserDatabase"/> 
<Host name="www.hehe.com" appBase="webapps" 
unpackWARs="true" autoDeploy="true" 
xmlValidation="false" xmlNamespaceAware="false"> 
<Alias>localhost</Alias> 
<Alias>hehe.com</Alias> 
<Alias>hehe.cn</Alias> 
<Alias>www.hehe.cn</Alias> 
<Context docBase="/hehe/upload" path="/upload" /> 
<Context docBase="/hehe/myapp" path="" /> 
</Host> 
</Engine> 
</Service> 

5. Start the mysqld service, as well as tomcat


-- 5.  Start the mysqld  Services, and tomcat 
cd /usr/local/hehe 
mkdir mysql_data 
#  You have to change the user, if you do mysql The data file saves the directory  
chown mysql:mysql mysql_data 
service mysqld start 
/usr/local/tomcat/bin/startup.sh 

5.1 set Tomcat to start automatically

There are many ways to do this, such as setting up a service or loading it using rc.local.

Modify/etc/rc. d/rc. local file:


# 1.  The installation rzsz 
yum list lrzsz* 
yum install lrzsz -y 
0

Add the script to start Tomcat and save it. The end result is as follows:


# 1.  The installation rzsz 
yum list lrzsz* 
yum install lrzsz -y 
1

As you can see, we only added the last row. This means that after Linux is started and the other initial scripts are loaded, the command to start Tomcat is executed.
Of course, starting other programs can be done this way, but it's a bit old, and you can't configure and invoke it using chkconfig (that is, you can't install the service).

6. Since the corresponding context of tomcat has been modified, there is no content in the access


# 1.  The installation rzsz 
yum list lrzsz* 
yum install lrzsz -y 
2

The corresponding javaEE app is available below.


Related articles: