這篇文章將為大家詳細(xì)講解有關(guān)如何搭建JavaWeb服務(wù)器,小編覺得挺實(shí)用的,因此分享給大家做個(gè)參考,希望大家閱讀完這篇文章后可以有所收獲。
站在用戶的角度思考問題,與客戶深入溝通,找到輪臺(tái)網(wǎng)站設(shè)計(jì)與輪臺(tái)網(wǎng)站推廣的解決方案,憑借多年的經(jīng)驗(yàn),讓設(shè)計(jì)與互聯(lián)網(wǎng)技術(shù)結(jié)合,創(chuàng)造個(gè)性化、用戶體驗(yàn)好的作品,建站類型包括:網(wǎng)站設(shè)計(jì)、成都網(wǎng)站制作、企業(yè)官網(wǎng)、英文網(wǎng)站、手機(jī)端網(wǎng)站、網(wǎng)站推廣、域名與空間、虛擬空間、企業(yè)郵箱。業(yè)務(wù)覆蓋輪臺(tái)地區(qū)。1、安裝jdk7
//檢查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庫中的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
//從官網(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ì)看到類似以下的信息
<DATE> org.apache.catalina.util.SessionIdGenerator createSecureRandom INFO: Creation of SecureRandom instance for session ID generation using [SHA1PRNG] took [5172] milliseconds.
關(guān)于本問題請參考官方文章末尾有說明 官方說明
問題說明:
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
[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
//安裝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 端口號; server_name 域名/ip; ... //啟動(dòng)nginx [root@iZwz9catu2mrq92b07d1d0Z conf.d]# chkconfig nginx on [root@iZwz9catu2mrq92b07d1d0Z conf.d]# service nginx start //在瀏覽器上訪問域名或ip,顯示nginx的歡迎頁面即配置成功
4、安裝MySQL
下載官方y(tǒng)um庫
https://dev.mysql.com/downloads/repo/yum/
安裝說明
https://dev.mysql.com/doc/mysql-yum-repo-quick-guide/en/
//下載MySQL Yum庫 [root@iZwz9catu2mrq92b07d1d0Z ~]# wget https://repo.mysql.com//mysql57-community-release-el6-11.noarch.rpm //安裝yum庫 [root@iZwz9catu2mrq92b07d1d0Z ~]# yum -y localinstall mysql57-community-release-el6-11.noarch.rpm //檢查庫安裝成功,默認(rèn)已開啟子庫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),超級用戶會(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:
//x值為數(shù)據(jù)庫用戶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ù)器”這篇文章就分享到這里了,希望以上內(nèi)容可以對大家有一定的幫助,使各位可以學(xué)到更多知識,如果覺得文章不錯(cuò),請把它分享出去讓更多的人看到。
網(wǎng)頁題目:如何搭建JavaWeb服務(wù)器-創(chuàng)新互聯(lián)
文章URL:http://muchs.cn/article26/dpgjcg.html
成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供網(wǎng)站制作、網(wǎng)站營銷、網(wǎng)站排名、微信小程序、標(biāo)簽優(yōu)化、營銷型網(wǎng)站建設(shè)
聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請盡快告知,我們將會(huì)在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場,如需處理請聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來源: 創(chuàng)新互聯(lián)
猜你還喜歡下面的內(nèi)容