zoukankan      html  css  js  c++  java
  • linux 安装 apache

    安装Apache前准备:

    一、检查该环境中是否已经存在httpd服务的配置文件,默认存储路径:/etc/httpd/httpd.conf(这是centos预装的Apache的一个ent版本,一般我们安装源代码版的Apache)。如果已经存在/etc/httpd/httpd.conf,请先卸载或者关闭centos系统自带的web服务,执行命令:chkconfig  httpd off,再或者把centos自带的httpd服务的80端口改为其他端口,只要不与我们安装的Apache服务的端口冲突就可以啦。

    停止并卸载Linux系统自带的httpd服务:

    1、service httpd stop

    2、ps -ef | grep httpd

    3、kill -9 pid号(逐个删除)

    4、rpm -qa |grep httpd

    5、rpm -e httpd软件包

    [root@localhost bin]# find / -name httpd.conf
    [root@localhost bin]#

    二, 下载Apache安装包 httpd-2.4.10.tar.gz ,下载地址:http://httpd.apache.org/
    在安装Apache时,我分别针对不同版本进行了安装,在编译时是不同的,configure后跟的参数不同。

    ./configure --prefix=/usr/local/apache2 --with-apr=/usr/local/apr --with-apr-util=/usr/local/apr-util/ --with-pcre=/usr/local/pcre  #(除了指定Apache的安装目录外,还要安装apr、apr-util、pcre,并指定参数)
    make
    make install

    在编译Apache(在安装httpd-2.4.10时遇到的问题)时分别出现了apr not found、APR-util not found、pcre-config for libpcre not found的问题,下面就httpd-2.4.10的这些问题解决来实际操作一把。

    1, 解决apr not found问题

    [root@localhost bin]# tar -zxf apr-1.4.5.tar.gz
    [root@localhost apr-1.4.5]# ./configure --prefix=/usr/local/apr
    [root@localhost apr-1.4.5]# make
    [root@localhost apr-1.4.5]# make install

    2.解决APR-util not found问题

    [root@localhost bin]# tar -zxf apr-util-1.3.12.tar.gz
    [root@localhost apr-util-1.3.12]# ./configure --prefix=/usr/local/apr-util -with-apr=/usr/local/apr/bin/apr-1-config
    [root@localhost apr-util-1.3.12]# make
    [root@localhost apr-util-1.3.12]# make install

    3、解决pcre-config for libpcre not found问题

    [root@localhost ~]# unzip pcre-8.31.zip

    [root@localhost ~]# cd pcre-8.31

    [root@localhost pcre-8.31]# ./configure --prefix=/usr/local/pcre

    [root@localhost pcre-8.31]#

    make[root@localhost pcre-8.31]# make install

    apache服务自启动设置

    root@localhost#cp /usr/local/apahe/bin/apachectl /etc/rc.d/init.d/httpd
    root@localhost#vim /etc/rc.d/init.d/httpd

    在httpd中加入
    #chkconfig: 35 85 15
    #description: apache
    保存退出。

    root@localhost# chkconfig --add httpd
    root@localhost# chkconfig httpd on

    查看一下是否添加成功:

    chkconfig --list httpd

    测试:
    root@localhost# service httpd start

    如报 AH00558: httpd: Could not reliably determine the server's fully qualified domain name, using localhost.localdomain. Set the 'ServerName' directive globally to suppress this message

        Apache的配置文件则是conf目录下的httpd.conf文件,将其打开:

          找到ServerName(约213行),将其设置为localhost:80,并将前面的井号删除

    测试:

      [root@localhost ~]# curl http://localhost

      <html><body><h1>It works!</h1></body></html>

  • 相关阅读:
    网络分析(二)定向与非定向
    Flex 找不到html文件,不能自动生成html问题解决
    常用的功能点记录
    git常规操作命令整理
    语境驱动测试7原则
    探索式测试的问与答
    测试建模:Google ACC
    探索式测试:基于测程的测试管理(SessionBased Test Management)
    用Excel展示SQL Server中的数据 (III): IronPython与自动化
    在Ajax中使用Flash实现跨域数据读取
  • 原文地址:https://www.cnblogs.com/lizs/p/4224756.html
Copyright © 2011-2022 走看看