简体   繁体   English

Apache2 VirtualHost(ProxyPass和Alias)配置可在Ubuntu中使用,但不能在OSX上使用

[英]Apache2 VirtualHost (ProxyPass and Alias) configuration works in Ubuntu but not on OSX

I have been using an Ubuntu machine for my development environment for years and am attempting to migrate to OSX (Mountain Lion). 多年来,我一直在开发环境中使用Ubuntu计算机,并试图迁移到OSX(Mountain Lion)。 The only hiccup at this point is the apache2 configuration. 此时唯一的麻烦是apache2配置。

On the Ubuntu machine "apache2 -v" reveals 在Ubuntu机器上,“ apache2 -v”显示

Server version: Apache/2.2.22 (Ubuntu)
Server built:   Nov  8 2012 21:37:30

On the OSX machine "httpd -v" reveals 在OSX机器上,“ httpd -v”显示

Server version: Apache/2.2.22 (Unix)
Server built:   Aug 24 2012 17:16:58

So you can imagine that I'm thoroughly confused as to why the virtual host config isn't migrating well. 因此,您可以想象一下,为什么虚拟主机配置不能很好地迁移,我感到非常困惑。

The following ProxyPass and Alias bits of my VirtualHost config work very well when used on my first apache2 instance but not on the second. 在第一个apache2实例上使用但在第二个apache2实例上使用时,VirtualHost配置的以下ProxyPass和Alias位可以很好地工作。 The directory structures on both machines 两台机器上的目录结构

For all intents and purposes, the virtual host config is as follows 出于所有目的和目的,虚拟主机配置如下

NameVirtualHost *:80

<VirtualHost *:80>

   ProxyPass /img !
   Alias /img /somedir/media/img

   ProxyPreserveHost On
   ProxyPass / http://127.0.0.1:8080/
   ProxyPassReverse / http://127.0.0.1:8080/

</VirtualHost>

with the goal being that apache will serve all images and the app server at port 8080 doing the heavy lifting (common pattern). 目标是apache将提供所有图像,端口8080上的应用服务器将承担繁重的工作(通用模式)。

In Ubuntu this works great. 在Ubuntu中,这很好用。 On the macbook, the images aren't being served up. 在Macbook上,没有提供图像。

Verify that the proxy module is being loaded. 验证是否正在加载代理模块。 This would either be done with a dynamic load config line in the conf file: 这可以通过conf文件中的动态加载配置行来完成:

LoadModule  proxy_http_module    modules/mod_proxy_http.so

Or compiled into Apache: 或编译成Apache:

./httpd -l | grep proxy
mod_proxy.c
mod_proxy_connect.c
mod_proxy_ftp.c
mod_proxy_http.c
mod_proxy_scgi.c
mod_proxy_ajp.c
mod_proxy_balancer.c

You can likely pull the mod_proxy_http.so from the other server. 您可能可以从另一台服务器拉出mod_proxy_http.so。

Turns out the default apache config defined a very restrictive default site configuration. 原来,默认的apache配置定义了一个非常严格的默认站点配置。 Commenting that out and restarting the server cleaned things up nicely. 注释掉并重新启动服务器可以很好地清理工作。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM