我正在尝试设置虚拟主机/redirect点,以便在一个站点上可以有两个不同的系统。
到目前为止,这是我有:
NameVirtualHost 89.104.220.207:80 NameVirtualHost 89.104.220.207:1500 # # NOTE: NameVirtualHost cannot be used without a port specifier # (eg :80) if mod_ssl is being used, due to the nature of the # SSL protocol. # # # VirtualHost example: # Almost any Apache directive may go into a VirtualHost container. # The first VirtualHost section is used for requests without a known # server name. # <VirtualHost 89.104.220.207:80> ServerAdmin [email protected] DocumentRoot /var/www/******/html ServerName www.******.dk ServerAlias ******.dk ErrorLog /var/www/*****.dk/logs/error_log </VirtualHost> <VirtualHost 89.104.220.207:1500> ServerAdmin [email protected] DocumentRoot /var/www/******/ ServerName ******* ServerAlias ******.dk ErrorLog /var/www/*****.dk/logs/error_log </VirtualHost>
我的想法是,如果我去89.104.220.207:1500那么我应该打开/var/www/foo/
然而,这似乎并没有工作:当我尝试进入我为foo没有发生或好,我得到一个错误。 如果你去89.104.220.207:1500你会看到你得到一个错误。
要让apache在非标准端口上进行侦听,您需要将Listen指令添加到httpd.conf :
Listen 1500
在受SELinux保护的机器上,这将导致apache无法启动,因为SELinux将阻止访问所有非标准的http端口。
要解决这个问题:
# semanage port -a -t http_port_t -p tcp 1500
然后确认它添加了:
# semanage port -l | grep '^http_port_t' http_port_t tcp 1500, 80, 443, 488, 8008, 8009, 8443
注意: semanage在policycoreutils-python包中。
apache现在应该启动,虚拟主机应该在非标准端口上工作。
请记住,使用非标准端口时,可能需要打开防火墙:
# iptables -I INPUT -p tcp --dport 1500 -j ACCEPT # service iptables save