【发布时间】:2016-06-19 06:33:05
【问题描述】:
在我的服务器上,我同时安装了一个 tomcat7 和一个 apache2。我停止了 tomcat7 服务,并想在端口 80(也尝试使用 8082 测试)和端口 443(也使用 442 测试)上使用 apache2 进行监听。在我停止tomcat7之前,我用8082尝试过,我可以建立webside call并获得webside。但是在我停止 tomcat7 并想用 apache2 监听端口 80 和 443 之后,我无法建立 webside 呼叫(如果我再次尝试使用 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]
和与服务器名称相同的答案。但不是在另一台机器上的网络浏览器上。为什么不?
顺便说一句:一个 lsof -i 返回注释。为什么不呢?
服务器版本:Ubuntu,14.04.4 LTS
【问题讨论】:
标签: apache2 ubuntu-14.04 netstat