我在 Debian Jessie 上安装了 apache 2.4,并将多个网站作为虚拟主机托管。其中一个网站在 jsp 上运行,因此我安装了 tomcat 8 并使用 mod_jk。
我的 apache 虚拟主机配置文件是:
<Directory /var/www/dimitros-apartments.gr>
AllowOverride None
Require all denied
</Directory>
<VirtualHost *:80>
ServerName dimitros-apartments.gr
ServerAlias www.dimitros-apartments.gr
#<Location "/">
# JkUriSet worker ajp13:localhost:8009
#</Location>
JkMount /dimitros-apartments.gr/* ajp13_worker
JkMount /dimitros-apartments.gr ajp13_worker
DocumentRoot /var/www/dimitros-apartments.gr/web
# DocumentRoot /var/lib/tomcat8/webapps/dimitros-apartments.gr
# ApJServMount /servlet /ROOT
# <Directory "/var/lib/tomcat8/webapps/dimitros-apartments.gr/WEB-INF">
# Options None
# Deny from all
# </Directory>
ServerAdmin [email protected]
ErrorLog /var/log/ispconfig/httpd/dimitros-apartments.gr/error.log
Alias /error/ "/var/www/dimitros-apartments.gr/web/error/"
ErrorDocument 400 /error/400.html
ErrorDocument 401 /error/401.html
ErrorDocument 403 /error/403.html
ErrorDocument 404 /error/404.html
ErrorDocument 405 /error/405.html
ErrorDocument 500 /error/500.html
ErrorDocument 502 /error/502.html
ErrorDocument 503 /error/503.html
<IfModule mod_ssl.c>
</IfModule>
<Directory /var/www/dimitros-apartments.gr/web>
# Clear PHP settings of this website
<FilesMatch ".+\.ph(p[345]?|t|tml)$">
SetHandler None
</FilesMatch>
Options +FollowSymLinks +Indexes
AllowOverride None
Require all granted
</Directory>
<Directory /var/www/clients/client1/web12/web>
# Clear PHP settings of this website
<FilesMatch ".+\.ph(p[345]?|t|tml)$">
SetHandler None
</FilesMatch>
Options +FollowSymLinks +Indexes
AllowOverride None
Require all granted
</Directory>
# suexec enabled
<IfModule mod_suexec.c>
SuexecUserGroup web12 client1
</IfModule>
# php as fast-cgi enabled
# For config options see: http://httpd.apache.org/mod_fcgid/mod/mod_fcgid.html
<IfModule mod_fcgid.c>
FcgidIdleTimeout 300
FcgidProcessLifeTime 3600
# FcgidMaxProcesses 1000
FcgidMaxRequestsPerProcess 5000
FcgidMinProcessesPerClass 0
FcgidMaxProcessesPerClass 10
FcgidConnectTimeout 3
FcgidIOTimeout 600
FcgidBusyTimeout 3600
FcgidMaxRequestLen 1073741824
</IfModule>
#<Directory /var/www/dimitros-apartments.gr/web>
# <FilesMatch "\.php[345]?$">
# SetHandler fcgid-script
# </FilesMatch>
# FCGIWrapper /var/www/php-fcgi-scripts/web12/.php-fcgi-starter .php
# FCGIWrapper /var/www/php-fcgi-scripts/web12/.php-fcgi-starter .php3
# FCGIWrapper /var/www/php-fcgi-scripts/web12/.php-fcgi-starter .php4
# FCGIWrapper /var/www/php-fcgi-scripts/web12/.php-fcgi-starter .php5
# Options +ExecCGI
# AllowOverride All
# Require all granted
# </Directory>
#<Directory /var/www/clients/client1/web12/web>
# <FilesMatch "\.php[345]?$">
# SetHandler fcgid-script
# </FilesMatch>
# FCGIWrapper /var/www/php-fcgi-scripts/web12/.php-fcgi-starter .php
# FCGIWrapper /var/www/php-fcgi-scripts/web12/.php-fcgi-starter .php3
# FCGIWrapper /var/www/php-fcgi-scripts/web12/.php-fcgi-starter .php4
# FCGIWrapper /var/www/php-fcgi-scripts/web12/.php-fcgi-starter .php5
# Options +ExecCGI
# AllowOverride All
# Require all granted
# </Directory>
# add support for apache mpm_itk
<IfModule mpm_itk_module>
AssignUserId web12 client1
</IfModule>
<IfModule mod_dav_fs.c>
# Do not execute PHP files in webdav directory
<Directory /var/www/clients/client1/web12/webdav>
<ifModule mod_security2.c>
SecRuleRemoveById 960015
SecRuleRemoveById 960032
</ifModule>
<FilesMatch "\.ph(p3?|tml)$">
SetHandler None
</FilesMatch>
</Directory>
DavLockDB /var/www/clients/client1/web12/tmp/DavLock
# DO NOT REMOVE THE COMMENTS!
# IF YOU REMOVE THEM, WEBDAV WILL NOT WORK ANYMORE!
# WEBDAV BEGIN
# WEBDAV END
</IfModule>
</VirtualHost>
在 tomcat 的 server.xml 上我有一个主机记录:
<Host name="www.dimitros-apartments.gr" appBase="/var/lib/tomcat8/webapps" >
<Alias>dimitros-apartments.gr</Alias>
<Context path="" docBase="/var/lib/tomcat8/webapps/dimitros-apartments.gr" />
网站正在运行http://www.dimitros-apartments.gr
我访问时出现权限被拒绝错误http://www.dimitros-apartments.gr。
我使用 ispconfig,对于每个域,我必须有其目录,apache 的域目录驻留在该目录中,无论该域是由 apache 提供服务还是在我的情况下是由 tomcat 提供服务。因此,对于这个域,我在 apache 和 tomcat 上都有相应的目录。我在 tomcat 域根目录和 apache 的域根目录中都有一个 index.jsp。
当我访问http://www.dimitros-apartments.gr/index.jsp我在浏览器上看到一个未编译的 jsp 页面(我看到了源代码)。奇怪的是,这个未编译的页面不是来自 tomcat 的目录,而是来自 apache 的域目录。
任何帮助都将受到赞赏。
提前致谢,Christoforos
答案1
看来我看的是旧文档。因为每个人都可能遇到同样的问题,所以
JkMount /dimitros-apartments.gr/* ajp13_worker
JkMount /dimitros-apartments.gr ajp13_worker
必须改为
JkMount /* ajp13_worker