我正在Google Cloud的Ubuntu 18.04LTS VM实例中设置新的apache2服务器。我想将其配置为可以在两个不同的端口上工作。它可以在端口80上正常工作([我的IP]:80正确呈现),但是无法在[我的IP]:8087上加载。
跑步时 netstat -atn 在vm上:
Active Internet connections (servers and established)
Proto Recv-Q Send-Q Local Address Foreign Address State
tcp 0 0 127.0.0.1:3306 0.0.0.0:* LISTEN
tcp 0 0 127.0.0.53:53 0.0.0.0:* LISTEN
tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN
tcp 0 448 10.160.0.3:22 74.125.41.97:42740 ESTABLISHED
tcp 0 0 10.160.0.3:49834 169.254.169.254:80 ESTABLISHED
tcp 0 0 10.160.0.3:49836 169.254.169.254:80 ESTABLISHED
tcp 0 0 10.160.0.3:49832 169.254.169.254:80 ESTABLISHED
tcp 0 0 10.160.0.3:49830 169.254.169.254:80 CLOSE_WAIT
tcp6 0 0 :::80 :::* LISTEN
tcp6 0 0 :::22 :::* LISTEN
tcp6 0 0 :::8087 :::* LISTEN
我还编辑了VPC网络->防火墙规则:
Name firewall-8087
Type Ingress
Targets Apply to all
Filters IP ranges: 0.0.0.0/0
Protocols / port tcp:8087 udp:8087
Action Allow
Priority 1000
Network default
我的/etc/apache2/ports.conf文件:
# If you just change the port or add more ports here, you will likely also
# have to change the VirtualHost statement in
# /etc/apache2/sites-enabled/000-default.conf
Listen 80
Listen 8087
<IfModule ssl_module>
Listen 443
</IfModule>
<IfModule mod_gnutls.c>
Listen 443
</IfModule>
# vim: syntax=apache ts=4 sw=4 sts=4 sr noet
我的/etc/apache2/sites-enabled/000-default.conf
<VirtualHost *:80 *:8087>
# The ServerName directive sets the request scheme, hostname and port that
# the server uses to identify itself. This is used when creating
# redirection URLs. In the context of virtual hosts, the ServerName
# specifies what hostname must appear in the request's Host: header to
# match this virtual host. For the default virtual host (this file) this
# value is not decisive as it is used as a last resort host regardless.
# However, you must set it for any further virtual host explicitly.
#ServerName www.example.com
ServerAdmin webmaster@localhost
DocumentRoot /var/www/html
# Available loglevels: trace8, ..., trace1, debug, info, notice, warn,
# error, crit, alert, emerg.
# It is also possible to configure the loglevel for particular
# modules, e.g.
#LogLevel info ssl:warn
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
# For most configuration files from conf-available/, which are
# enabled or disabled at a global level, it is possible to
# include a line for only one particular virtual host. For example the
# following line enables the CGI configuration for this host only
# after it has been globally disabled with "a2disconf".
#Include conf-available/serve-cgi-bin.conf
</VirtualHost>
# vim: syntax=apache ts=4 sw=4 sts=4 sr noet
这是我编辑的仅有的两个文件。