您的位置:首页 > 理论基础 > 计算机网络

Linux下安装Apache Http Server 的配置+一些错误信息的解决方法

2017-05-25 15:54 861 查看
原文来自http://blog.csdn.net/u013835877/article/details/39555345,对里面一些内容进行了补充

1.下载安装包,需要下面3个安装包

[root@bes2 apache]# ll

总用量 8520

-rw-r--r--. 1 root root 1020833 9月  18 17:47 apr-1.5.1.tar.gz

-rw-r--r--. 1 root root  874462 9月  18 17:48 apr-util-1.5.3.tar.gz

-rw-r--r--. 1 root root 6820719 9月  18 17:40 httpd-2.4.10.tar.gz

ps:下载可以去apache官网下载http://www.apache.org/,点击download进入下载页面,点击http://mirror.bit.edu.cn/apache/,选择apr和httpd文件夹,下载相应的安装包

2.解压下载的安装包

[root@bes2 apache]# tar -zvxf httpd-2.4.10.tar.gz

[root@bes2 apache]# tar -zvxf apr-1.5.1.tar.gz

[root@bes2 apache]# tar -zvxf apr-util-1.5.3.tar.gz

[root@bes2 apache]# ll

总用量 8532

drwxr-xr-x. 27 1000  1000    4096 4月  16 07:37 apr-1.5.1

-rw-r--r--.  1 root root  1020833 9月  18 17:47 apr-1.5.1.tar.gz

drwxr-xr-x. 19 1000  1000    4096 11月 14 2013 apr-util-1.5.3

-rw-r--r--.  1 root root   874462 9月  18 17:48 apr-util-1.5.3.tar.gz

drwxr-xr-x. 11 test games    4096 7月  16 01:15 httpd-2.4.10

-rw-r--r--.  1 root root  6820719 9月  18 17:40 httpd-2.4.10.tar.gz

问题:可以看见上面解压出来的文件夹的属主和组别与压缩包文件不一致

原因:登录下载生成的文件属主就是那个用户,至于文件压缩包里面文件的属性是由打包时原文件状态决定的。

若希望解压出来的文件的属主和组别与压缩包一致,可以使用以下解压方式

[root@bes2 apache]# tar --no-same-owner -zvxf httpd-2.4.10.tar.gz

[root@bes2 apache]# tar --no-same-owner -zvxf apr-1.5.1.tar.gz

[root@bes2 apache]# tar --no-same-owner -zvxf apr-util-1.5.3.tar.gz

[root@bes2 apache]# ll

总用量 8532

drwxr-xr-x. 27 root root    4096 4月  16 07:37 apr-1.5.1

-rw-r--r--.  1 root root 1020833 9月  18 17:47 apr-1.5.1.tar.gz

drwxr-xr-x. 19 root root    4096 11月 14 2013 apr-util-1.5.3

-rw-r--r--.  1 root root  874462 9月  18 17:48 apr-util-1.5.3.tar.gz

drwxr-xr-x. 11 root root    4096 7月  16 01:15 httpd-2.4.10

-rw-r--r--.  1 root root 6820719 9月  18 17:40 httpd-2.4.10.tar.gz

3.安装apr                                                                                                                                                    

[root@bes2 apache]# cd apr-1.5.1

[root@bes2 apr-1.5.1]# ./configure --prefix=/usr/local/apr     ——配置

报错:

config.status: executing libtool commands

rm: cannot remove `libtoolT': No such file or directory

config.status: executing default commands


解决方法:

[root@bes2 apr-1.5.1]# yum install libtool   ——安装libtool 

// 这一步的解决方式我和原文使用的有一点区别 来自http://blog.csdn.net/a673341766/article/details/9078011

在configure里面把RM='$RM'改为RM='$RM  -f'

完成后,重新执行配置apr命令,接着又出现下面错误

config.status: executing libtool commands

rm: cannot remove `libtoolT': No such file or directory

config.status: executing default commands

config.status: include/apr.h is unchanged

config.status: include/arch/unix/apr_private.h is unchanged


解决方法:

直接打开/usr/local/src/apr-1.5.1/configure  把 $RM “$cfgfile” 那行删除掉 

$RM “$cfgfile”  大约在 42302 行

然后再重新运行  ./configure  --prefix=/usr/local/apr  就可以了

[root@bes2 apr-1.5.1]# make            ——编译

[root@bes2 apr-1.5.1]# make install               ——安装

4.安装apr-util

[root@bes2 apr-1.5.1]# cd ../apr-util-1.5.3

[root@bes2 apr-util-1.5.3]# ./configure --prefix=/usr/local/apr-util --with-apr=/usr/local/apr   ——配置

[root@bes2 apr-util-1.5.3]# make     ——编译

[root@bes2 apr-util-1.5.3]# make install          ——安装

5.安装httpd

[root@bes2 apache]# cd httpd-2.4.10

[root@bes2 httpd-2.4.10]# ./configure --prefix=/usr/local/httpd --enable-module=so --with-apr-util=/usr/local/apr-util/          ——配置

报错:

checking for pcre-config... false

configure: error: pcre-config for libpcre not found. PCRE is required and available from http://pcre.org/

解决方法:安装pcre,安装完成后重新执行上述配置命令

[root@bes2 httpd-2.4.10]# yum install pcre

使用上述方法还是不行,下载压缩包进行安装

[root@bes2 apache]# wget ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/pcre-8.35.tar.gz

[root@bes1 pcre-8.35]# ./configure --prefix=/usr/local/pcre

报错:

configure: error: You need a C++ compiler for C++ support.

安装gcc c++

[root@bes1 ~]# yum install -y gcc gcc-c++

成功后重新安装pcre,执行上面的配置命令,完成后继续往下

[root@bes1 pcre-8.35]#make            ——编译

[root@bes1 pcre-8.35]#make install     ——安装

上述完成后,继续安装httpd

[root@bes2 httpd-2.4.10]# ./configure --prefix=/usr/local/httpd --enable-module=so --with-apr-util=
b2f6
/usr/local/apr-util --with-pcre=/usr/local/pcre     ——配置
//这里我还遇到一个错误checking for void pointer length... yes configure: error: Size of "void *" is less than size of "long“
解决方法来自http://blog.csdn.net/avilifans/article/details/13292999


解决方法vi configure 
if test "$ap_cv_void_ptr_lt_long" = "yes"; then
    as_fn_error $? "Size of \"void *\" is less than size of \"long\"" "$LINENO" 5
改为if test "$ap_cv_void_ptr_lt_long" != "yes"; then
    as_fn_error $? "Size of \"void *\" is less than size of \"long\"" "$LINENO" 5
保存重新编译


[root@bes2 httpd-2.4.10]# make 

[root@bes2 httpd-2.4.10]# make install

6.配置apache

[root@localhost httpd-2.2.6]#cd /usr/local/httpd/conf   //进入httpd配置文件的目录     

[root@localhost conf]#cp -a httpd.conf httpd.conf.bak     //备份apache配置文件

[root@localhost conf]#cd /usl/local/httpd/bin

ps:如果没有httpd服务,则不需要执行下面这段代码

[root@localhost conf]#chkconfig  --list httpd     //查看httpd服务是否已存在

[root@localhost conf]#chkconfig httpd off    //关闭系统自带了httpd的服务,如果存在httpd服务   

[root@localhost conf]#service httpd status    //查看自带httpd服务状态

[root@localhost conf]#/usr/local/httpd/bin/apachectl -k start    //linux启动apache命令              

[root@localhost conf]#netstat -an | grep :80    //查看linux80端口是否开启

[root@localhost conf]#ps -aux | grep httpd     //linux下查看apache进程

[root@localhost conf]#cd ../..

[root@localhost bin]#cp apachectl /etc/rc.d/init.d/httpd //拷贝apache启动脚本

[root@localhost bin]#vi /etc/rc.d/init.d/httpd    // 这里是编辑apache启动脚本

  在开头的#!/bin/sh  下面加上

              #chkconfig: 2345  85  15

[root@localhost bin]#chkconfig --add apache //添加apache服务 

//这句话执行报错 报错信息是error reading information on service apache: No such file or directory

我感觉这个可能有点问题,写成chkconfig --add httpd就可以,如果你不报错,或者明白原因的请给我留言

[root@localhost bin]#chkconfig --list apache    //列出apache服务

//也修改为 chkconfig --list httpd

[root@localhost bin]#service apache stop    //停止apache服务

//  修改为service httpd stop 

[root@localhost bin]#netstat -an | grep :80     //查看linux的80端口是否关闭

[root@localhost bin]#ps -aux | grep httpd     //查看是否存在httpd服务,若果之前自带httpd服务启动的话会导致新添加的apache服务启动失败

[root@localhost local]#service apache start    //启动apache服务

//修改为service apache start

这一块有明白的朋友麻烦帮我解解惑

问题:在web页面输入http://ip,遇到问题,页面无法打开

原因:防火墙未添加端口

解决方法:在防火墙添加端口

[root@bes1 conf]# cd /etc/sysconfig/

[root@bes1 sysconfig]# cp -r iptables iptables.bak

[root@bes1 sysconfig]# vim iptables

添加下面这一行

-A INPUT -m state --state NEW -m tcp -p tcp --dport 80 -j ACCEPT

[root@bes1 sysconfig]# service iptables restart

iptables:清除防火墙规则:                                 [确定]

iptables:将链设置为政策 ACCEPT:filter                    [确定]

iptables:正在卸载模块:                                   [确定]

iptables:应用防火墙规则:                                 [确定]

[root@bes1 sysconfig]# service httpd restart

----完成上述操作后,在前台页面输入访问地址 http://安装apache的ip,可正常访问
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息