常见问题解决
80端口已占用
guangbo@guangbo-laptop:/usr/local/apache2.2.16$ sudo ./bin/apachectl -k start
httpd: Could not reliably determine the server's fully qualified domain name, using 127.0.1.1 for ServerName
(98)Address already in use: make_sock: could not bind to address 0.0.0.0:80
no listening sockets available, shutting down
Unable to open logs
解决方法:查看占用80端口程序,用最后一个命令就行
ps auxw
netstat –ln
sudo netstat -lnp|grep 80
可以看到nginx占用80端口
tcp 0 0 0.0.0.0:80 0.0.0.0:* LISTEN 762/nginx
tcp6 0 0 :::8080 :::* LISTEN 995/java
查看并kill掉nginx
ps 762
PID TTY STAT TIME COMMAND
762 ? Ss 0:00 nginx: master process /usr/sbin/nginx
sudo kill -9 762
再次启动apache,如果启动再次有占用情况,再杀一次。我杀了两次才杀掉
sudo /usr/local/apache2.2.16/bin/apachectl -k start
ServerName问题
httpd: Could not reliably determine the server's fully qualified domain name, using 127.0.1.1 for ServerName
这是一个 warning,出现在apache2启动或重起时。主要是因为在配置 apache2 时,没有指定相应的主机名,即 ServerName。修改 /usr/local/apache2.2.16/httpd.conf。
sudo gedit /usr/local/apache2.2.16/conf/httpd.conf
在最前加入 ServerName localhost:80 即可。
sudo /usr/local/apache2.2.16/bin/apachectl -k stop
sudo /usr/local/apache2.2.16/bin/apachectl -k start