1、安裝jdk7
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
|
//檢查jdk是否已經(jīng)安裝 [root @iZwz9catu2mrq92b07d1d0Z ~]# yum list installed | grep java java- 1.7 . 0 -openjdk.x86_64 java- 1.7 . 0 -openjdk-demo.x86_64 java- 1.7 . 0 -openjdk-devel.x86_64 java- 1.7 . 0 -openjdk-javadoc.noarch java- 1.7 . 0 -openjdk-src.x86_64 tzdata-java.noarch 2017c- 1 .el6 @updates //卸載現(xiàn)有的jdk [root @iZwz9catu2mrq92b07d1d0Z ~]# yum -y remove java- 1.7 . 0 * //查看yum庫(kù)中的Java安裝包 [root @iZwz9catu2mrq92b07d1d0Z ~]# yum -C list java* ... java- 1.7 . 0 -openjdk.x86_64 1 : 1.7 . 0.151 - 2.6 . 11.0 .el6_9 updates java- 1.7 . 0 -openjdk-demo.x86_64 1 : 1.7 . 0.151 - 2.6 . 11.0 .el6_9 updates java- 1.7 . 0 -openjdk-devel.x86_64 1 : 1.7 . 0.151 - 2.6 . 11.0 .el6_9 updates java- 1.7 . 0 -openjdk-javadoc.noarch 1 : 1.7 . 0.151 - 2.6 . 11.0 .el6_9 updates ... //安裝jdk7 [root @iZwz9catu2mrq92b07d1d0Z ~]# yum -y install java- 1.7 . 0 * //安裝成功 [root @iZwz9catu2mrq92b07d1d0Z ~]# java -version java version "1.7.0_151" OpenJDK Runtime Environment (rhel- 2.6 . 11.0 .el6_9-x86_64 u151-b00) OpenJDK 64 -Bit Server VM (build 24.151 -b00, mixed mode) |
2、安裝tomcat7
1
2
3
4
5
6
7
8
9
10
11
|
//從官網(wǎng)下載tomcat7 [cjh @iZwz9catu2mrq92b07d1d0Z ~]$ wget http: //mirrors.tuna.tsinghua.edu.cn/apache/tomcat/tomcat-7/v7.0.82/bin/apache-tomcat-7.0.82.tar.gz //檢查壓縮包文件 [cjh @iZwz9catu2mrq92b07d1d0Z ~]$ tar -ztvf apache-tomcat- 7.0 . 82 .tar.gz //解壓 [cjh @iZwz9catu2mrq92b07d1d0Z ~]$ tar -zxvf apache-tomcat- 7.0 . 82 .tar.gz [cjh @iZwz9catu2mrq92b07d1d0Z ~]$ ls apache-tomcat- 7.0 . 82 apache-tomcat- 7.0 . 82 .tar.gz |
注:當(dāng)我們嘗試啟動(dòng)tomcat時(shí)可能會(huì)遇到啟動(dòng)非常慢的情況,并且在啟動(dòng)日志中會(huì)看到類似以下的信息
1
2
|
<DATE> org.apache.catalina.util.SessionIdGenerator createSecureRandom INFO: Creation of SecureRandom instance for session ID generation using [SHA1PRNG] took [ 5172 ] milliseconds. |
關(guān)于本問題請(qǐng)參考官方文章末尾有說明 官方說明
問題說明:
Tomcat 7+ heavily relies on SecureRandom class to provide random values for its session ids and in other places. Depending on your JRE it can cause delays during startup if entropy source that is used to initialize SecureRandom is short of entropy
譯:tomcat7+嚴(yán)重依賴SecureRandom類為會(huì)話ids和其它地方提供的隨機(jī)值,這會(huì)導(dǎo)致啟動(dòng)過程出現(xiàn)延遲。
解決辦法:
There is a way to configure JRE to use a non-blocking entropy source by setting the following system property: -Djava.security.egd=file:/dev/./urandom
譯:添加jvm參數(shù) -Djava.security.egd=file:/dev/./urandom
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
|
[cjh @iZwz9catu2mrq92b07d1d0Z bin]$ pwd /home/cjh/apache-tomcat- 7.0 . 82 /bin //在開頭注釋后面添加參數(shù) [cjh @iZwz9catu2mrq92b07d1d0Z bin]$ vi catalina.sh ... JAVA_OPTS= "-Djava.security.egd=file:/dev/./urandom" ... //查看jvm運(yùn)行參數(shù),參數(shù)已添加 [cjh @iZwz9catu2mrq92b07d1d0Z bin]$ jps -v ... //重新運(yùn)行tomcat,查看啟動(dòng)日志,啟動(dòng)耗時(shí)正常 ... |
3、安裝反向代理nginx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
|
//安裝nginx [root @iZwz9catu2mrq92b07d1d0Z ~]# yum -y install nginx //安裝完成后查看配置文件路徑 [root @iZwz9catu2mrq92b07d1d0Z ~]# whereis nginx //檢查配置文件內(nèi)容,可以發(fā)現(xiàn)包含了另一個(gè)路徑下的配置文件組 [root @iZwz9catu2mrq92b07d1d0Z ~]# cat /etc/nginx/nginx.conf ... include /etc/nginx/conf.d/*.conf; ... //切換路徑,檢查文件組 [root @iZwz9catu2mrq92b07d1d0Z ~]# cd /etc/nginx/conf.d/ [root @iZwz9catu2mrq92b07d1d0Z conf.d]# ls -l | grep .conf -rw-r--r-- 1 root root 408 Nov 22 17 : 59 default .conf -rw-r--r-- 1 root root 686 Oct 31 2016 ssl.conf -rw-r--r-- 1 root root 283 Oct 31 2016 virtual.conf //修改default.conf [root @iZwz9catu2mrq92b07d1d0Z conf.d]# vi default .conf ... listen 端口號(hào); server_name 域名/ip; ... //啟動(dòng)nginx [root @iZwz9catu2mrq92b07d1d0Z conf.d]# chkconfig nginx on [root @iZwz9catu2mrq92b07d1d0Z conf.d]# service nginx start //在瀏覽器上訪問域名或ip,顯示nginx的歡迎頁(yè)面即配置成功 |
4、安裝MySQL
下載官方y(tǒng)um庫(kù)
https://dev.mysql.com/downloads/repo/yum/
安裝說明
https://dev.mysql.com/doc/mysql-yum-repo-quick-guide/en/
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
|
//下載MySQL Yum庫(kù) [root @iZwz9catu2mrq92b07d1d0Z ~]# wget https: //repo.mysql.com//mysql57-community-release-el6-11.noarch.rpm //安裝yum庫(kù) [root @iZwz9catu2mrq92b07d1d0Z ~]# yum -y localinstall mysql57-community-release-el6- 11 .noarch.rpm //檢查庫(kù)安裝成功,默認(rèn)已開啟子庫(kù)mysql57-community [root @iZwz9catu2mrq92b07d1d0Z ~]# yum -C repolist enabled //安裝MySQL5.7 [root @iZwz9catu2mrq92b07d1d0Z ~]# yum -y install mysql-community-server //啟動(dòng)服務(wù) [root @iZwz9catu2mrq92b07d1d0Z yum.repos.d]# chkconfig mysqld on [root @iZwz9catu2mrq92b07d1d0Z ~]# service mysqld start Initializing MySQL database: [ OK ] Starting mysqld: [ OK ] |
注:服務(wù)在初次啟動(dòng)時(shí)會(huì)進(jìn)行初始化(僅5.7),超級(jí)用戶會(huì)被創(chuàng)建,并且它的密碼已被設(shè)置并存儲(chǔ)在/var/log/mysqld.log,而非空
A superuser account 'root'@'localhost' is created. A password for the superuser is set and stored in the error log file. To reveal it, use the following command:
1
2
3
4
5
6
7
8
9
|
//x值為數(shù)據(jù)庫(kù)用戶root的密碼 [root @iZwz9catu2mrq92b07d1d0Z ~]# cat /var/log/mysqld.log | grep password 2017 - 11 -22T14: 27 : 56 .638229Z 1 [Note] A temporary password is generated for root @localhost : x //進(jìn)入成功 [root @iZwz9catu2mrq92b07d1d0Z ~]# mysql -uroot -p Enter password: Welcome to the MySQL monitor. Commands end with ; or \g. ... |
以上就是本次小編整理的關(guān)于搭建JavaWeb服務(wù)器的詳細(xì)內(nèi)容以及步驟,希望我們整理的內(nèi)容對(duì)大家有所幫助,感謝大家對(duì)服務(wù)器之家的支持。
原文鏈接:http://www.cnblogs.com/cjh-notes/p/7868262.html