zoukankan      html  css  js  c++  java
  • 第15章01章节 Apache服务介绍,安装及排错

    第15章 Apache服务·

    15.1Apache介绍

    Apache是一款Web服务器软件,有多种产品,可以支持SSL技术,支持多个虚拟主机。它快速、可靠并且可通过简单的API扩充,将Perl/Python等解释器编译到服务器中。

    Apache的特点是简单、速度快、性能稳定,并可做代理服务器来使用。它可以在大多数计算机操作系统中运行,由于其跨平台和安全性被广泛使用。

    Apache HTTP Server(简称Apache)是Apache软件基金会的一个开放源码的网页服务器,可以在大多数计算机操作系统中运行,由于其多平台和安全性被广泛使用,是最流行的Web服务器端软件之一。它快速、可靠并且可通过简单的API扩展,将Perl/Python等解释器编译到服务器中。 [2] 

    Apache HTTP服务器是一个模块化的服务器,源于NCSAhttpd服务器,经过多次修改,成为世界使用排名第一的Web服务器软件。

    它可以运行在几乎所有广泛使用的计算机平台上。

    Apache源于NCSAhttpd服务器,经过多次修改,成为世界上最流行的Web服务器软件之一。Apache取自“a patchy server”的读音,意思是充满补丁的服务器,因为它是自由软件,所以不断有人来为它开发新的功能、新的特性、修改原来的缺陷。Apache的特点是简单、速度快、性能稳定,并可做代理服务器来使用。

    本来它只用于小型或试验Internet网络,后来逐步扩充到各种Unix系统中,尤其对Linux的支持相当完美。Apache有多种产品,可以支持SSL技术,支持多个虚拟主机。Apache是以进程为基础的结构,进程要比线程消耗更多的系统开支,不太适合于多处理器环境,因此,在一个Apache Web站点扩容时,通常是增加服务器或扩充群集节点而不是增加处理器。到目前为止Apache仍然是世界上用的最多的Web服务器,市场占有率达60%左右。世界上很多著名的网站如Amazon、Yahoo!、W3 Consortium、Financial Times等都是Apache的产物,它的成功之处主要在于它的源代码开放、有一支开放的开发队伍、支持跨平台的应用(可以运行在几乎所有的Unix、Windows、Linux系统平台上)以及它的可移植性等方面。

    Apache的诞生极富有戏剧性。当NCSAWWW服务器项目停顿后,那些使用NCSAWWW服务器的人们开始交换他们用于该服务器的补丁程序,他们也很快认识到成立管理这些补丁程序的论坛是必要的。就这样,诞生了Apache Group,后来这个团体在NCSA的基础上创建了Apache。

    Apacheweb服务器软件拥有以下特性:

    Apache Server配置界面

    1.支持最新的HTTP/1.1通信协议

    2.拥有简单而强有力的基于文件的配置过程

    3.支持通用网关接口

    4.支持基于IP和基于域名的虚拟主机

    5.支持多种方式的HTTP认证

    6.集成Perl处理模块

    7.集成代理服务器模块

    8.支持实时监视服务器状态和定制服务器日志

    9.支持服务器端包含指令(SSI)

    10.支持安全Socket层(SSL)

    11.提供用户会话过程的跟踪

    12.支持FastCGI

    13.通过第三方模块可以支持JavaServlets 

    15.2 安装Apche

    思路

    1、wget http的包
    2、安装依赖项,pcre zlib-devel pcre-devel gcc gcc-c++  apr-util
    3、解压httpd的包,tar,unzip
    4、./configure --prefix=路径 --user=用户 --group=组,--with加组件名
    5.echo $?
    6.make && make install
    7.进入你httpd的目录,把apachectl加入环境变量,并启动
    8、关闭selinux及防火墙
    9、测试,宿主机去访问,或者curl 127.0.0.1:端口

    安装过程:

    安装httpd两种方法(yum是最简单的,二选一安装就行 )

    [root@httpd ~]# wget http://www.apache.org./dist/httpd/httpd-2.4.39.tar.gz
    [root@httpd ~]# yum install httpd -y

    已加载插件:fastestmirror

    Loading mirror speeds from cached hostfile

     * base: mirror.jdcloud.com

     * extras: mirrors.aliyun.com

     * updates: mirrors.aliyun.com

    软件包 httpd-2.4.6-90.el7.centos.x86_64 已安装并且是最新版本

    无须任何处理

    [root@httpd ~]# rpm  -qa httpd

    httpd-2.4.6-90.el7.centos.x86_64

    顺便普及一下卸载命令

    [root@httpd ~]# rpm  -e(--nodebse) httpd
    [root@httpd ~]# rpm  -qa httpd
    

    安装依赖工具包,整理后的(后面报错涉及到得的安装包也都整理在了这里安装)

    wget https://mirrors.tuna.tsinghua.edu.cn/apache/apr/apr-1.6.5.tar.gz

    wget https://mirrors.tuna.tsinghua.edu.cn/apache/apr/apr-util-1.6.1.tar.gz

    yum install pcre -y

    yum install pcre-config -y

    yum install pcre-lib -y

    yum install pcre-devel -y

    yum install zlib-devel -y

    yum install zlib zlib-level -y

    yum install gcc gcc-c++ -y

     解压及环境配置

    [root@httpd ~]# ls httpd-2.4.39.tar.gz
    httpd-2.4.39.tar.gz
    [root@httpd ~]# ls httpd-2.4.39.tar.gz -l
    -rw-r--r-- 1 root root 9199150 9月  21 23:35 httpd-2.4.39.tar.gz
    [root@httpd ~]# tar xf httpd-2.4.39.tar.gz
    

      

    tar -zxf apr-1.6.5.tar.gz  
    cd  apr-1.6.5  
    ./configure --prefix=/usr/local/apr  
    make && make install  

     

    tar -zxf apr-upr-util-1.6.1.tar.gz  
    cd apr-util-1.6.1  
    ./configure --prefix=/usr/local/apr-util -with-apr=/usr/local/apr/bin/apr-1-config  
    make && make install  
    出错:
    

    解压文档后进入文档,输入以下内容

    ./configure 
    --prefix=/application/apache2.4.39 
    --enable-deflate 
    --enable-expires     缓存
     --enable-headers     激活HTTP的头
    --enable-modules=most 
     --enable-so 
    --with-mpm=worker 
    --with-apr=/usr/local/apr --with-apr-util=/usr/local/apr-util
    --enable-rewrite

    (如果还缺少安装包,可直接进行yum 安装)

    echo $?
    0
    

      检查没有错就进行make

    配置变量环境

    [root@localhost http]# echo "PATH=$PATH:/application/http/bin" >> /etc/profile
    [root@localhost http]# source /etc/profile
    [root@localhost http]# apachectl
    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
    

      

    关闭防火墙及 selinux

    测试,成功

    [root@localhost bin]# curl 127.0.0.1
    <html><body><h1>It works!</h1></body></html>
    

     

    Apache排错总结及排错思路:

    1. 在编译apr-util-1.6.1中报错

    1. 编译中断。

    make[1]: *** [xml/apr_xml.lo] 错误 1
    make[1]: 离开目录“/usr/local/apr-util-1.6.1”
    make: *** [all-recursive] 错误 1
    

     解决:下载安装expat库 yum install expat-devel

    2.安装httpd-2.4.39

    报错:

    make[2]: *** [htpasswd] 错误 1
    make[2]: 离开目录“/root/httpd-2.4.39/support”
    make[1]: *** [all-recursive] 错误 1
    make[1]: 离开目录“/root/httpd-2.4.39/support”
    make: *** [all-recursive] 错误 1
    

    解决办法:

    yum groupinstall "Development Tools" "Server Platform Development" -y
    yum install pcre-devel  expat-devel -y
      cp -r /root/apr-1.6.5  /root/httpd-2.4.39/srclib/apr
      cd /root/apr-1.6.5
      ./configure --prefix=/usr/local/apr
      make && make install
     
      cp -r /root/apr-util-1.6.1  /root/httpd-2.4.39/srclib/apr-util
      cd /root/apr-util-1.6.1
      ./configure --prefix=/usr/local/apr-util --with-apr=/usr/local/apr
      make && make install
     
      cd /root/httpd-2.4.39
      ./configure --with-included-apr --prefix=/application/httpd2.4.39 --with-apr=/usr/local/apr --with-apr-util=/usr/local/apr-util --enable-so --enable-mods-shared=most
    

    3.解决最终 无法连接

           检查网络连接是否正常

          Ping www.baidu.com

        检查防火墙和selinux是否关闭

    systemctl stop iptables
    systemctl stop firewall
    systemctl stop firewalld
    getenforce
    

    检查端口是否存在,或者是否开启

    netstat -nlt|grep "80"
    (如果没有,去开起服务root@localhost httpd-2.4.39]# ./apachectl)
    [root@localhost httpd-2.4.39]#  netstat -nlt|grep "80"
    tcp6       0      0 :::80                   :::*                    LISTEN

       检查进程是否存在

    [root@localhost httpd-2.4.39]# ps -ef|grep http
    root      29855      1  0 22:13 ?        00:00:00 /application/http/bin/httpd
    daemon    29856  29855  0 22:13 ?        00:00:00 /application/http/bin/httpd
    daemon    29857  29855  0 22:13 ?        00:00:00 /application/http/bin/httpd
    daemon    29858  29855  0 22:13 ?        00:00:00 /application/http/bin/httpd
    root      30135   2800  0 23:54 pts/0    00:00:00 grep --color=auto http
    

     在本地测试Wget是否成功

    [root@localhost httpd-2.4.39]# wget 192.168.170.133
    --2019-10-23 23:55:44--  http://192.168.170.133/
    正在连接 192.168.170.133:80... 已连接。
    已发出 HTTP 请求,正在等待回应... 200 OK
    长度:45 [text/html]
    正在保存至: “index.html”

      

    100%[===============>] 45          --.-K/s 用时 0s     

    2019-10-23 23:55:44 (5.88 MB/s) - 已保存 “index.html” [45/45])

  • 相关阅读:
    P1396 营救
    [BUUCTF]REVERSE——xor
    [BUUCTF]REVERSE——helloword
    [BUUCTF]REVERSE——[BJDCTF 2nd]guessgame
    [BUUCTF]REVERSE——新年快乐
    [BUUCTF]PWN——jarvisoj_level3
    [BUUCTF]PWN——[BJDCTF 2nd]test
    [BUUCTF]PWN——ciscn_2019_es_2
    [BUUCTF]PWN——[Black Watch 入群题]PWN
    [BUUCTF]PWN——others_shellcode
  • 原文地址:https://www.cnblogs.com/hanjiali/p/11726375.html
Copyright © 2011-2022 走看看