我想要 Apache 来做这件事 >
mydomain.com:80 --- opens var/www1
mydomain.com:81 --- opens var/ww2
mydomain.com:82 --- opens var/www3
问题是我不知道这些端口是否在 Linux 上打开(我如何检查?)
如果不是,我该如何在防火墙中打开它们并让 apache 监听?
我试过这样做
> iptables -A RH-Firewall-1-INPUT -m NEW -m tcp -p tcp –dport 81 -j ACCEPT
iptables v1.3.5: Couldn't load match `NEW':/lib64/iptables/libipt_NEW.so: cannot open shared object file: No such file or directory
我检查了端口……看起来 httpd 正在监听……但我不知道为什么我无法访问我的 URL
> netstat -tulpn | less
tcp 0 0 :::80 :::* LISTEN 6840/httpd
tcp 0 0 :::81 :::* LISTEN 6840/httpd
tcp 0 0 :::82 :::* LISTEN 6840/httpd
答案1
为了扩展 Jeff 的答案,你需要在 apache 配置中添加类似这样的内容
Listen 80
Listen 81
Listen 82
# Listen for virtual host requests on all IP addresses
NameVirtualHost *:80
<VirtualHost *:80>
DocumentRoot /var/www1
ServerName www.example1.com
</VirtualHost>
NameVirtualHost *:81
<VirtualHost *:81>
DocumentRoot /var/www2
ServerName www.example2.org
</VirtualHost>
NameVirtualHost *:82
<VirtualHost *:82>
DocumentRoot /var/www3
ServerName www.example3.org
</VirtualHost>
答案2
答案3
Listen 81
Listen 82
<VirtualHost *:80>
DocumentRoot /var/www1
ServerName mydomain.com
</VirtualHost>
//access -- mydomain.com:80
<VirtualHost *:81>
DocumentRoot /var/www2
ServerName mydomain.com
</VirtualHost>
//access -- mydomain.com:81
<VirtualHost *:82>
DocumentRoot /var/www3
ServerName mydomain.com
</VirtualHost>
//access -- mydomain.com:82