在我的服务器上,我安装了tomcat7和apache2。我停止了tomcat7服务,并希望在端口80(也尝试使用8082进行测试)和端口443(以及442测试)上使用apache2进行监听。在我停止tomcat7之前,我用8082尝试了它,我可以建立网络呼叫并获得网站。但是在我停止了tomcat7并想用apache2监听端口80和443后,我无法建立一个网络呼叫(如果我再次尝试使用8082和442,也不会再次)。
netstat -tulpe返回以下内容:
tobias@<hostname>:/etc/apache2$ netstat -tulpe
(No info could be read for "-p": geteuid()=1000 but you should be root.)
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address Foreign Address State User Inode PID/Program name
tcp 0 0 <hostname>.stratoser:8082 *:* LISTEN root <number> -
tcp 0 0 *:ssh *:* LISTEN root <number> -
tcp 0 0 localhost:smtp *:* LISTEN root <number> -
tcp6 0 0 [::]:ssh [::]:* LISTEN root <number> -
tcp6 0 0 localhost:smtp [::]:* LISTEN root <number> -
tcp6 0 0 [::]:https [::]:* LISTEN tomcat7 <number> -
tcp6 0 0 localhost:8005 [::]:* LISTEN tomcat7 <number> -
tcp6 0 0 [::]:http [::]:* LISTEN tomcat7 <number> -
我的ports.conf:
tobias@<hostname>:/etc/apache2$ cat 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 8082
<IfModule ssl_module>
Listen 442
</IfModule>
<IfModule mod_gnutls.c>
Listen 442
</IfModule>
# vim: syntax=apache ts=4 sw=4 sts=4 sr noet
和000-default.conf
tobias@<hostname>:/etc/apache2$ cat sites-available/000-default.conf
<VirtualHost _default_:8082>
# 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
服务-status-all返回:
[ + ] apache2
[ - ] tomcat7
错误日志显示:
[Sun Jun 19 08:08:09.325184 2016] [core:notice] [pid 18254:tid 139964856280960] AH00094: Command line: '/usr/sbin/apache2'
[Sun Jun 19 08:08:21.312066 2016] [mpm_event:notice] [pid 18254:tid 139964856280960] AH00491: caught SIGTERM, shutting down
[Sun Jun 19 08:09:47.916405 2016] [mpm_event:notice] [pid 18466:tid 140331437791104] AH00489: Apache/2.4.7 (Ubuntu) configured -- resuming normal operations
[Sun Jun 19 08:09:47.916530 2016] [core:notice] [pid 18466:tid 140331437791104] AH00094: Command line: '/usr/sbin/apache2'
(看来这条线只是警告?)
我在服务器的终端上尝试了一个wget并且得到了正确的答案:
tobias@<hostname>:~$ wget http://<server-ip>:8082
--2016-06-19 08:21:38-- http://<server-ip>:8082/
Connecting to <server-ip>:8082... connected.
HTTP request sent, awaiting response... 200 OK
Length: 11510 (11K) [text/html]
Saving to: ‘index.html’
100%[====================================================================================>] 11.510 --.-K/s in 0s
2016-06-19 08:21:38 (370 MB/s) - ‘index.html’ saved [11510/11510]
和sameans一起使用servername。但不是在其他机器上的webbrowser上。为什么不?
顺便说一句:一个lsof -i回来了。为什么不呢?服务器版本:Ubuntu,14.04.4 LTS
答案 0 :(得分:0)
您提供了所有正确的故障排除工具,谢谢!一个建议:省略netstat中的e参数 - 对于这种类型的故障排除,您需要数字端口号,而不是翻译成人类可读的形式。如果你不是root,p参数也没有任何作用,但它也不会受到伤害。
解决问题的关键是netstat输出。您的netstat输出显示Apache正在侦听端口8082,但没有侦听端口442.在您的配置中,您还没有提供任何SSL配置(000-default.conf没有提到任何SSL配置选项),所以很可能是根本没有配置。这就解释了442端口问题。
netstat输出显示的第二件事是Apache正在侦听端口8082,但仅在一个特定的IP地址上侦听。由于您的wget成功,这可能是正确的,这只是一个不寻常的问题(如果您的网络配置发生变化,可能会导致问题)。
您提到的最后一个问题是您无法从任何其他系统访问服务器。在那个,你的配置文件都没有提供线索,但通常,这类问题是你没有在防火墙中打开端口8082。
另外一点:我最初使用telnet而不是使用wget进行测试。由于telnet较低,因此可能会干扰测试的移动部件较少。这只是一个一般的提示 - 在这种情况下,wget确实为您提供了所需的信息。