本地机器上的 Apache 配置 Ubuntu 14.04
Posted
技术标签:
【中文标题】本地机器上的 Apache 配置 Ubuntu 14.04【英文标题】:Apache Configuration Ubuntu 14.04 on local machine 【发布时间】:2016-02-23 17:44:59 【问题描述】:我刚刚将 Apache 从 2.2 更新到 2.4。但是我的 Apache 设置不适用于我的本地计算机上的站点。以下是详细信息
<VirtualHost www.letscompete.it:80>
ServerName www.letscompete.it
DocumentRoot /opt/content/letscompete-content/velocity/static/
ProxyRequests Off
ProxyPreserveHost On
ProxyVia On
ProxyTimeout 1000
TimeOut 1000
# Proxy requests to the java application
# trailing slash required at the end of context path or will end up in a redirect loop
ProxyPass / ajp://localhost:8009/letscompete/
# Revrites http headers (Location, Content-Location, URI)
# on http redirect responses to avoid bypassing this gateway
# in redirects coming from the web application
# no trailing slash at the end of context path (optional)
ProxyPassReverse / ajp://localhost:8009/letscompete
# Adjusts the Path string in Set-Cookie headers
# NOTE: no trailing slash at the end of context path or will have redirect (302) issues after authentication
ProxyPassReverseCookiePath /letscompete /
# Filters output html to convert the context path
# generated from the proxyied server to the one
# on this proxy
SetOutputFilter proxy-html
# NOTE: trailing slash required at the end of context path or links will be generated without the context
ProxyHTMLURLMap /letscompete/ /
ProxyHTMLDocType "<!DOCTYPE html>"
AllowEncodedSlashes On
RewriteEngine On
RewriteRule ^/favicon.ico$ /images/favicon.ico [NC,L]
RewriteRule ^/bootshop/(.*)$ /bootshop/$1 [QSA,NC,L]
RewriteRule ^/less/(.*)$ /less/$1 [QSA,NC,L]
RewriteRule ^/css/(.*)$ /css/$1 [NC,L]
RewriteRule ^/img/(.*)$ /img/$1 [NC,L]
RewriteRule ^/images/(.*)$ /images/$1 [NC,L]
RewriteRule ^/js/(.*)$ /js/$1 [NC,L]
RewriteRule ^/font/(.*)$ /font/$1 [QSA,NC,L]
RewriteRule ^/letscompete/(.*)$ /$1 [R]
<Directory "/opt/content/FindBlog-content/velocity/static/">
Options FollowSymLinks
AllowOverride None
Require all granted
</Directory>
</VirtualHost>
<Proxy ajp://localhost:8009>
Order allow,deny
Allow from all
Require all granted
</Proxy>
每当我点击这个地址时,服务器就会抛出错误:
服务不可用 由于维护停机或容量问题,服务器暂时无法满足您的请求。请稍后再试。
我启用了以下模式:
access_compat alias auth_basic authn_core authn_file authz_core authz_host authz_user autoindex deflate dir env filter mime mpm_event 协商代理 proxy_ajp proxy_express proxy_html proxy_scgi proxy_wstunnel rewrite setenvif status xml2enc
这是我的错误日志:
[Sat Nov 21 10:49:29.130742 2015] [proxy_ajp:error] [pid 1833:tid 140289415259904] (104)Connection reset by peer: AH01030: ajp_ilink_receive() can't receive header
[Sat Nov 21 10:49:29.130904 2015] [proxy_ajp:error] [pid 1833:tid 140289415259904] [client 127.0.0.1:45935] AH00992: ajp_read_header: ajp_ilink_receive failed
[Sat Nov 21 10:49:29.130920 2015] [proxy_ajp:error] [pid 1833:tid 140289415259904] (120006)APR does not understand this error code: [client 127.0.0.1:45935] AH00878: read response failed from
127.0.0.1:8009 (localhost)
[Sat Nov 21 10:49:31.731353 2015] [proxy:error] [pid 1832:tid 140289318573824] AH00940: AJP: disabled connection for (localhost)
[Sat Nov 21 10:49:32.604179 2015] [proxy:error] [pid 1833:tid 140289310181120] (111)Connection refused: AH00957: AJP: attempt to connect to 127.0.0.1:8009 (localhost) failed
[Sat Nov 21 10:49:32.604230 2015] [proxy:error] [pid 1833:tid 140289310181120] AH00959: ap_proxy_connect_backend disabling worker for (localhost) for 60s
[Sat Nov 21 10:49:32.604244 2015] [proxy_ajp:error] [pid 1833:tid 140289310181120] [client
127.0.0.1:45948] AH00896: failed to make connection to backend: localhost
[Sat Nov 21 10:49:33.322966 2015] [proxy:error] [pid 1833:tid 140289301788416] AH00940: AJP: disabled connection for (localhost)
[Sat Nov 21 10:49:39.384979 2015] [proxy:error] [pid 1833:tid 140289293395712] AH00940: AJP: disabled connection for (localhost)
至于我的主机文件:
127.0.0.1 localhost
127.0.1.1 www.letscompete.it
【问题讨论】:
【参考方案1】:问题出在我的 server.xml 文件中,通过更改路径字段
来自
上下文 docBase="letscompete" path="/abc" reloadable="true" source="org.eclipse.jst.jee.server:letscompete"/>
到
上下文 docBase="letscompete" path="/letscompete" reloadable="true" source="org.eclipse.jst.jee.server:letscompete"/>
【讨论】:
以上是关于本地机器上的 Apache 配置 Ubuntu 14.04的主要内容,如果未能解决你的问题,请参考以下文章
最近在虚拟机上想配置apache2 上的django时提示mod_python error本地服务器遇到的问题
本地yum仓库的安装配置通过一个Apache作为私有仓库,供局域网内使用