【Apache系列】linux下Apache的常用操作

1. 启动/停止

1.1假设你的apahce安装目录为/usr/local/apache2,这些方法适合任何情况

   apahce启动命令: /usr/local/apache2/bin/apachectl start   

   apache停止命令: /usr/local/apache2/bin/apachectl stop 

   apache重新启动命令: /usr/local/apache2/bin/apachectl restart

   要在重启 Apache 服务器时不中断当前的连接,则应运行: /usr/local/sbin/apachectl graceful

 

1.2 如果apache已安装成为linux的服务的话,可以用以下命令操作:

   service httpd start 启动

   service httpd restart 重新启动

   service httpd stop 停止服务

 

FAQ


 

启动时遇到以下问题

 

原因分析:apache启动时可能会查询DNS来验证ServerName的配置,没有对服务器域名与本地ip绑定,所以需要对httpd.conf文件进行配置

解决方案

  1)进入apache配置文件的目录:<apache安装目录>/apache/conf/httpd.conf

  2)编辑httpd.conf文件:

    搜索"#ServerName",添加ServerName <localhost>:<port>

[root@centos httpd]# vi httpd.conf

#
# ServerName gives the name and port that the server uses to identify itself.
# This can often be determined automatically, but we recommend you specify
# it explicitly to prevent problems during startup.
#
# If your host doesn't have a registered DNS name, enter its IP address here.
#
#ServerName www.example.com:80

    改为:ServerName <localhost>:<port>  例如:ServerName 192.9.100.242:80

    注意,要去掉开头的 #

  3)再重新启动apache 即可。

    [root@centos httpd]# /usr/local/apache2/bin/apachectl restart

    启动成功啦!   显示    It works!

posted @ 2014-04-23 11:06  钟灵.毓秀  阅读(573)  评论(0编辑  收藏  举报