我試圖在Ubuntu上使用Apache啓動本地主機應用程序,並將其代理到Tomcat,以便我可以在我的應用程序中使用.jsp頁面。看來這是可能的,我認爲我很接近,但我似乎無法完全理解。任何幫助是極大的讚賞!我從來沒有使用Apache或Tomcat,所以如果任何一個看起來很愚蠢,請不要恨我。通過在URL中鍵入本地主機/ hello.html的使用AJP將Apache連接到Tomcat
<VirtualHost *:80>
ServerName localhost
ServerAlias test.com
DocumentRoot /var/www/test.com/helloworld
<Directory />
Options FollowSymLinks
AllowOverride None
</Directory>
<Directory /var/www/>
Options Indexes FollowSymLinks MultiViews
AllowOverride None
Order allow,deny
allow from all
</Directory>
ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
<Directory "/usr/lib/cgi-bin">
AllowOverride None
Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
Order allow,deny
Allow from all
</Directory>
ErrorLog ${APACHE_LOG_DIR}/error.log
# Possible values include: debug, info, notice, warn, error, crit,
# alert, emerg.
LogLevel warn
CustomLog ${APACHE_LOG_DIR}/access.log combined
Alias /doc/ "/usr/share/doc/"
<Directory "/usr/share/doc/">
Options Indexes MultiViews FollowSymLinks
AllowOverride None
Order deny,allow
Deny from all
Allow from 127.0.0.0/255.0.0.0 ::1/128
</Directory>
</VirtualHost>
這讓我成功地瀏覽到我的網頁hello.html的:
我有阿帕奇託管在本地主機站點使用此代碼的主機。我已閱讀,從這個角度,我需要插入一些代碼,如:
ProxyRequests Off
ProxyPreserveHost On
<Proxy *>
Order deny,allow
Allow from all
</Proxy>
ProxyPass /(appname) ajp://localhost:8009/(appname)
ProxyPassReverse /(appname) ajp://localhost:8009/(appname)
然後到tomcat應該得到的請求。在這種情況下,appname會是什麼?我的網頁位於/var/www/test.com/helloworld/hello.html
,所以我認爲它會是「helloworld」,但這不起作用。當我將appname留空時,我看到Tomcat「恭喜,您已經成功安裝了Tomcat」。當我導航到本地主機,但無法找到我的頁面。
請幫忙。這正在慢慢變成一場噩夢。謝謝!
我知道這並沒有回答這個問題,但你知道JBoss是一個全功能的免費應用服務器,它已經嵌入了Tomcat。不知道是否由於某種原因需要使用Apache,但JBoss對您來說可能是更好的解決方案。 – Jim
聽起來很棒。不幸的是,我認爲我僅限於Apache。我正在爲已經在他們的服務器上擁有Apache主機的人建立一個Web服務,我想他們希望我能夠適應它們。 :(謝謝大家!如果我有選擇,我一定會使用它。 –