最近在 Ubuntu 上安装了 Apache2。
我在访问显示 Apache2 已成功安装的页面时遇到了一些问题。
运行
ip addr show eth0 | grep inet | awk '{ print $2; }' | sed 's/\/.*$//'
什么都不返回。
运行“服务 apache2 状态”
apache2 is running
如果我在终端中运行命令“apache2”会给我一个错误列表:
AH00558: apache2: Could not reliably determine the server's fully qualified domain name, using 127.0.1.1. Set the 'ServerName' directive globally to suppress this message
(13)Permission denied: AH00072: make_sock: could not bind to address [::]:80
(13)Permission denied: AH00072: make_sock: could not bind to address 0.0.0.0:80
no listening sockets available, shutting down
AH00015: Unable to open logs
然而,使用 'sudo apache2' 给了我这个:
[Tue May 26 11:40:48.514878 2015] [core:warn] [pid 4554] AH00111: Config variable ${APACHE_LOCK_DIR} is not defined
[Tue May 26 11:40:48.514923 2015] [core:warn] [pid 4554] AH00111: Config variable ${APACHE_PID_FILE} is not defined
[Tue May 26 11:40:48.514935 2015] [core:warn] [pid 4554] AH00111: Config variable ${APACHE_RUN_USER} is not defined
[Tue May 26 11:40:48.514939 2015] [core:warn] [pid 4554] AH00111: Config variable ${APACHE_RUN_GROUP} is not defined
[Tue May 26 11:40:48.514950 2015] [core:warn] [pid 4554] AH00111: Config variable ${APACHE_LOG_DIR} is not defined
[Tue May 26 11:40:48.519904 2015] [core:warn] [pid 4554] AH00111: Config variable ${APACHE_LOG_DIR} is not defined
[Tue May 26 11:40:48.519999 2015] [core:warn] [pid 4554] AH00111: Config variable ${APACHE_LOG_DIR} is not defined
[Tue May 26 11:40:48.520009 2015] [core:warn] [pid 4554] AH00111: Config variable ${APACHE_LOG_DIR} is not defined
AH00526: Syntax error on line 74 of /etc/apache2/apache2.conf:
Invalid Mutex directory in argument file:${APACHE_LOCK_DIR}
不确定这是否与我试图找到运行 apache 的本地服务器 IP 的问题有关。
任何帮助或指导表示赞赏!
运行 ifconfig 后编辑
eth0 Link encap:Ethernet HWaddr 28:d2:44:db:55:6e
UP BROADCAST MULTICAST MTU:1500 Metric:1
RX packets:0 errors:0 dropped:0 overruns:0 frame:0
TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:0 (0.0 B) TX bytes:0 (0.0 B)
Interrupt:20 Memory:f0600000-f0620000
lo Link encap:Local Loopback
inet addr:127.0.0.1 Mask:255.0.0.0
inet6 addr: ::1/128 Scope:Host
UP LOOPBACK RUNNING MTU:65536 Metric:1
RX packets:39387 errors:0 dropped:0 overruns:0 frame:0
TX packets:39387 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:4256292 (4.2 MB) TX bytes:4256292 (4.2 MB)
wlan0 Link encap:Ethernet HWaddr 18:cf:5e:be:29:7a
inet addr:10.0.1.15 Bcast:10.0.1.255 Mask:255.255.255.0
inet6 addr: fe80::1acf:5eff:febe:297a/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:806787 errors:0 dropped:0 overruns:0 frame:0
TX packets:634100 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:880453718 (880.4 MB) TX bytes:122151075 (122.1 MB)
最佳答案
一个接一个。
ip addr show eth0 | grep inet | awk '{ print $2; }' | sed 's/\/.*$//'
这只会在连接确实通过 eth0 时显示。运行
ifconfig
查看您正在使用哪个界面。这还将向您显示您的机器具有的 IP 地址。运行后遇到的错误
apache2
是多方面的。对于
Could not reliably determine the server's
... you can fix that specific one here接下来的三行提示套接字是因为 apache2 已经在运行并且无法绑定(bind)到端口,因为其他一些进程(正在运行的 apache 实例)已经绑定(bind)到它们。
该 block 中关于日志的最后一行是因为您以非特权用户身份运行 apache2 并且您的日志文件受到保护。
当您使用 sudo 运行 apache2 时,您会收到一大堆关于配置变量的错误,因为您尝试错误地启动 apache。
sudo service apache2 start|stop|restart
将从 /etc/apache2/envvars
加载值在启动 apache 之前进入您的环境。这是您应该控制 apache 的方式。
关于Apache 配置问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30464334/