zoukankan      html  css  js  c++  java
  • 【Linux】Linux下配置apache

    一.获取软件: http://httpd.apache.org/   httpd-2.4.10.tar.gz

    二.安装步骤:

    解压源文件:

            1) tar zvxf  httpd-2.4.10.tar.gz 

            2) cd httpd-2.4.10

            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服务具有网页地址重写功能。

    三.启动apache:

            /usr/local/apache2/bin/apachectl start


    四,验证是否成功安装

           浏览器中直接输入:http://localhost

           在/var/www/html 中加入testp.php文件然后在浏览器中输入:http://localhost/test.php


    五,将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

  • 相关阅读:
    【LeetCode】17. Letter Combinations of a Phone Number
    【LeetCode】16. 3Sum Closest
    【LeetCode】15. 3Sum 三个数和为0
    【LeetCode】14. Longest Common Prefix 最长前缀子串
    【LeetCode】13. Roman to Integer 罗马数字转整数
    【LeetCode】12. Integer to Roman 整型数转罗马数
    【LeetCode】11. Container With Most Water
    【LeetCode】10. Regular Expression Matching
    Models of good programmer
    RSA Algorithm
  • 原文地址:https://www.cnblogs.com/lxjshuju/p/7103342.html
Copyright © 2011-2022 走看看