日期:2014-05-17  浏览次数:20932 次

一个apache为两个不同端口的网站提供服务

看这篇博客前请先查阅? apache2.2.6 + mongrel_cluster1.0.5负载均衡 ?


一个台服务器开启两个httpd主进程,分别使用不同的配置文件,服务两个不同的网站。




具体步骤:

1. 从源码安装apache服务,安装路径: /usr/local/apache2.2.22


在/usr/local/apache2.2.22/conf 下创建两个配置文件httpd.conf和httpd2.conf。


httpd.conf:

ServerRoot "/usr/local/apache2.2.22"
Listen 127.0.0.1:80


LoadModule cache_module modules/mod_cache.so
LoadModule proxy_module modules/mod_proxy.so
LoadModule proxy_ftp_module modules/mod_proxy_ftp.so
LoadModule proxy_http_module modules/mod_proxy_http.so
LoadModule proxy_scgi_module modules/mod_proxy_scgi.so
LoadModule proxy_ajp_module modules/mod_proxy_ajp.so
LoadModule proxy_balancer_module modules/mod_proxy_balancer.so
LoadModule rewrite_module modules/mod_rewrite.so

<IfModule !mpm_netware_module>
<IfModule !mpm_winnt_module>

User daemon
Group daemon

</IfModule>
</IfModule>


ServerAdmin you@example.com
ServerName 127.0.0.1:80

#DocumentRoot "/usr/local/apache2.2.22/htdocs"

<Directory />
??? Options FollowSymLinks
??? AllowOverride None
??? Order deny,allow
??? Deny from all
</Directory>


<Directory "/usr/local/apache2.2.22/htdocs">
??? Options Indexes FollowSymLinks
??? AllowOverride None
??? Order allow,deny
??? Allow from all
</Directory>

<IfModule dir_module>
??? DirectoryIndex index.html
</IfModule>

<FilesMatch "^\.ht">
??? Order allow,deny
??? Deny from all
??? Satisfy All
</FilesMatch>

ErrorLog "logs/error_log"
LogLevel warn

<IfModule log_config_module>
??? LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"" combined
??? LogFormat "%h %l %u %t \"%r\" %>s %b" common
??? <IfModule logio_module>
????? # You need to enable mod_logio.c to use %I and %O
????? LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\" %I %O" combinedio
??? </IfModule>
???
??? CustomLog "logs/access_log" common
</IfModule>

<IfModule alias_module>
??? ScriptAlias /cgi-bin/ "/usr/local/apache2.2.22/cgi-bin/"
</IfModule>


<Directory "/usr/local/apache2.2.22/cgi-bin">
??? AllowOverride None
??? Options None
??? Order allow,deny
??? Allow from all
</Directory>


DefaultType text/plain

<IfModule mime_module>
??? TypesConfig conf/mime.types
??? AddType application/x-compress .Z
??? AddType application/x-gzip .gz .tgz
</IfModule>

<IfModule ssl_module>
SSLRandomSeed startup builtin
SSLRandomSeed connect builtin
</IfModule>


<Proxy balancer://spacecluster>
??? # cluster members
??? BalancerMember http://www.iche.com:4000
??? BalancerMember http://www.iche.com:4001
??? BalancerMember http://www.ic