Web項目發布的一些設置
阿新 • • 發佈:2018-07-14
tor 裏的 外網 windows 絕對路徑 not classname valve time
比如我們有個項目想要發布到互聯網上,我們首先需要購買域名以及主機,主機的話,推薦雲主機(本人推薦西部數碼或者阿裏雲),性能好;
我們先在雲主機上搭建環境,比如Mysql,Jdk,Tomcat;
然後我們把自己開發的項目打包,打成War包;
具體操作;右擊項目-> Export
然後點擊 Next ;
選擇Browse,我們隨便選個地方 然後點擊Finish即可;
這樣我們就可以生成一個War包了;
我們把War包傳到主機上去,放到Tomcat的webapps下,啟動tomcat的startup.bat,會自動解壓項目;
到了這裏,還不夠。我們只能通過 http://外網IP:8080/項目名稱訪問;
我們現在要幹兩個事情,第一個是去掉端口,第二個是去掉項目名稱
我們找到tomcat安裝包下的conf文件夾下的server.xml文件;
找到Connector節點;
1 2 3 |
< Connector port = "8080" protocol = "HTTP/1.1"
connectionTimeout = "20000"
redirectPort = "8443" />
|
我們把port="8080"改成80端口即可,這樣我們就可以不用端口了。不加端口就是默認訪問80端口;
我們在最後 找到Host節點:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 |
< Host name = "localhost" appBase = "webapps"
unpackWARs = "true" autoDeploy = "true" >
<!-- SingleSignOn valve, share authentication between web applications
Documentation at: /docs/config/valve.html -->
<!--
<Valve className="org.apache.catalina.authenticator.SingleSignOn" /> -->
<!-- Access log processes all example.
Documentation at: /docs/config/valve.html
Note: The pattern used is equivalent to using pattern="common" -->
< Valve className = "org.apache.catalina.valves.AccessLogValve" directory = "logs"
prefix = "localhost_access_log." suffix = ".txt"
pattern = "%h %l %u %t "%r" %s %b" />
</ Host >
|
我們在裏面加一個節點:
<Context path="" docBase="C:\apache-tomcat-7.0.11-windows-x86\apache-tomcat-7.0.11\webapps\Blog" debug="0" reloadable="true" />
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 |
< Host name = "localhost" appBase = "webapps"
unpackWARs = "true" autoDeploy = "true" >
<!-- SingleSignOn valve, share authentication between web applications
Documentation at: /docs/config/valve.html -->
<!--
<Valve className="org.apache.catalina.authenticator.SingleSignOn" />
-->
< Context path = "" docBase = "C:\apache-tomcat-7.0.11-windows-x86\apache-tomcat-7.0.11\webapps\BaiduYun" debug = "0" reloadable = "true" />
<!-- Access log processes all example.
Documentation at: /docs/config/valve.html
Note: The pattern used is equivalent to using pattern="common" -->
< Valve className = "org.apache.catalina.valves.AccessLogValve" directory = "logs"
prefix = "localhost_access_log." suffix = ".txt"
pattern = "%h %l %u %t "%r" %s %b" resolveHosts = "false" />
</ Host >
|
這裏的docBase要給成你的項目所在你服務器的本機的絕對路徑;
其他不用變;
項目數據庫腳本的話自己導入下即可;這樣就完整了項目部署;
我們可以直接通過外網IP直接訪問項目;
域名解析下服務器外網IP。我們就可以通過域名訪問了;
Web項目發布的一些設置