服务命令Linux安装配置apache

发一下牢骚和主题无关:

     ubuntu 初始化root 密码

    sudo passwd root 然后随意输入密码两次,root密码就设置好了

    

    

    1.获取软件: http://httpd.apache.org/  httpd-2.2.21.tar.gz

    2.安装步骤:

    解压源文件:

1 tar zvxf httpd-2.2.21.tar.gz 
2 cd httpd-2.2.21
3 ./configure --prefix=/usr/local/apache2 --enable-so --enable-rewrite 
4 make
5 make install

运行./configure 命令进行编译源代码,

    --prefix=/usr/local/apach2 是设置编译安装到的系统目录,

 --enable-s  参数是使httpd服务能够动态加载模块功能,

    --enable-rewrite  是使httpd服务拥有网页地址重写功能。

    3.启动apache:

    /usr/local/apache2/bin/apachectl start

    4.将apache加入到系统服务,用service命令来控制apache的启动和停止

    

  •  首先以apachectl脚本为模板生成Apache服务控制脚本:
    每日一道理
盈盈月光,我掬一杯最清的;落落余辉,我拥一缕最暖的;灼灼红叶,我拾一片最热的;萋萋芳草,我摘一束最灿的;漫漫人生,我要采撷世间最重的———毅力。

    grep -v "#" /usr/local/apache2/bin/apachectl  > /etc/init.d/apache

    

  • 用vi编辑Apache服务控制脚本/etc/init.d/apache:

    vi /etc/init.d/apache

    

  • 在文件最前面插入上面的行,使其支撑chkconfig命令:

    #!/bin/sh              

    # chkconfig: 2345 85 15              

    # description: Apache is a World Wide Web server.

    

  • 保存后退出vi编辑器,执行上面的命令增长Apache服务控制脚本执行权限: 

    chmod  +x  /etc/init.d/apache

    

  • 执行上面的命令将Apache服务加入到系统服务:

    chkconfig --add apache

    

  • 执行上面的命令检查Apache服务是不是已生效: 

    chkconfig --list apache              

    

  • 命令输出类似上面的结果:              

    apache          0:off 1:off 2:on 3:on 4:on 5:on 6:off       

    表明apache服务已生效,在2、3、4、5运行级别随系统启动而自动启动,当前可以使用service命令控制Apache的启动和停止。

    

  • 启动Apache服务:  service apache start   
  • 停止Apache服务:        service apache stop   
  • 执行上面的命令关闭开机自启动:   chkconfig apache off

文章结束给大家分享下程序员的一些笑话语录: 祝大家在以后的日子里. 男生象Oracle般健壮; 女生象win7般漂亮; 桃花运象IE中毒般频繁; 钱包如Gmail容量般壮大, 升职速度赶上微软打补丁 , 追女朋友像木马一样猖獗, 生活像重装电脑后一样幸福, 写程序敲代码和聊天一样有**。

原文地址:https://www.cnblogs.com/xinyuyuanm/p/3087238.html