zoukankan      html  css  js  c++  java
  • Linux9.3 Apache安装

    Apache是一个基金会的名字,httpd才是我们要安装的软件包,早期它的名字就叫apache
    Apache官网www.apache.org

    2.4源码包:wget http://mirrors.cnnic.cn/apache/httpd/httpd-2.4.33.tar.gz
    
    apr: wget http://mirrors.cnnic.cn/apache/apr/apr-1.6.3.tar.gz
    
    apr-util: wget http://mirrors.cnnic.cn/apache/apr/apr-util-1.6.1.tar.bz2 
    

    apr和apr-util是一个通用的函数库,它让httpd可以不关心底层的操作系统平台,可以很方便地移植(从linux移植到windows),2.4依赖apr。区别在于apr

    tar zxf httpd-2.4.33.tar.gz
    
    tar zxf apr-1.6.3.tar.gz
    
    #如果发现无法解压,报错,可能需要安装yum install -y bzip2
    tar jxf apr-util-1.6.1.tar.bz2
    

       编译安装apr

    cd /usr/local/src/apr-1.6.3
    ./configure --prefix=/usr/local/apr
    make && make install
    

      编译安装apr-util

    可以自定义模块安装
    
    cd /usr/local/src/apr-util-1.6.1
    
     ./configure --prefix=/usr/local/apache2.4  --with-apr=/usr/local/apr
    
    make && make install
    cd /usr/local/src/httpd-2.4.33
    ./configure  //这里的反斜杠是脱义字符,加上它我们可以把一行命令写成多行
    --prefix=/usr/local/apache2.4 
    --with-apr=/usr/local/apr 
    --with-apr-util=/usr/local/apr-util 
    --enable-so 
    --enable-mods-shared=most 
    --with-included-apr
    

      会报错

    configure: error: Bundled APR requested but not found at ./srclib/. Download and unpack the corresponding apr and apr-util packages to ./srclib/.
    
    错误为:apr,apr-util缺失,需要下载并解压到./srclib/目录下
    
    
    解决办法
    
    # cd /usr/local/src/
    # cp -r apr-16.3 /usr/local/src/httpd-2.4.33/srclib/apr
    # cp -r apr-util-1.6.1/usr/local/src/httpd-2.4.33/srclib/apr-util
    
     
    再次执行./configure就不会报错,make,make install也不会报错;
    

      

      httpd核心二进制启动文件

    [root@chy002 apache2.4]# du -sh ./bin/httpd
    2.2M	./bin/httpd
    

      配置文件

    [root@chy002 apache2.4]# ls -l ./conf/httpd.conf 
    -rw-r--r-- 1 root root 18236 3月   2 05:18 ./conf/httpd.conf
    

      默认网站页放到该文件夹下

    [root@chy002 apache2.4]# ls htdocs/
    index.html
    

      日志,错误日志访问日志

    [root@chy002 apache2.4]# ls logs

      httpd模块,查看所有模块

    [root@chy002 apache2.4]# ls modules/
    httpd.exp               mod_buffer.so               mod_log_config.so      mod_rewrite.so
    mod_access_compat.so    mod_cache_disk.so           mod_log_debug.so       mod_sed.so
    mod_actions.so          mod_cache.so                mod_logio.so           mod_session_cookie.so
    mod_alias.so            mod_cache_socache.so        mod_macro.so           mod_session_dbd.so
    ... ...
    [root@chy002 apache2.4]# /usr/local/apache2.4/bin/httpd -M
    AH00557: httpd: apr_sockaddr_info_get() failed for chy002
    AH00558: httpd: Could not reliably determine the server's fully qualified domain name, using 127.0.0.1. Set the 'ServerName' directive globally to suppress this message
    Loaded Modules:
     core_module (static)
     so_module (static)
     http_module (static)
     mpm_event_module (static)
     authn_file_module (shared)
     authn_core_module (shared)
     authz_host_module (shared)
     authz_groupfile_module (shared)
     authz_user_module (shared)
     authz_core_module (shared)
     access_compat_module (shared)
     auth_basic_module (shared)
     reqtimeout_module (shared)
     filter_module (shared)
     mime_module (shared)
     log_config_module (shared)
    ... ...
    

      其中,shared为扩展模块可在modules/中看到文件,static为固有模块

            /usr/local/apache2.4/bin/apachectl   该shell脚本调用了二进制文件httpd

      启动脚本,虽然有错误,但是修改配置文件就可以解决

    [root@chy002 apache2.4]# /usr/local/apache2.4/bin/apachectl start
    AH00557: httpd: apr_sockaddr_info_get() failed for chy002
    AH00558: httpd: Could not reliably determine the server's fully qualified domain name, using 127.0.0.1. Set the 'ServerName' directive globally to suppress this message
    httpd (pid 38293) already running
    [root@chy002 apache2.4]# ps aux |grep httpd
    root     38293  0.0  0.2  75520  2276 ?        Ss   05:32   0:00 /usr/local/apache2.4/bin/httpd
    daemon   38294  0.0  0.4 364484  4276 ?        Sl   05:32   0:00 /usr/local/apache2.4/bin/httpd
    daemon   38295  0.0  0.4 364484  4276 ?        Sl   05:32   0:00 /usr/local/apache2.4/bin/httpd
    daemon   38296  0.0  0.4 364484  4276 ?        Sl   05:32   0:00 /usr/local/apache2.4/bin/httpd
    root     38391  0.0  0.0 112676   980 pts/0    R+   05:43   0:00 grep --color=auto httpd
    [root@chy002 apache2.4]# netstat -lntp
    Active Internet connections (only servers)
    Proto Recv-Q Send-Q Local Address           Foreign Address         State       PID/Program name    
    tcp        0      0 127.0.0.1:25            0.0.0.0:*               LISTEN      1877/master         
    tcp        0      0 0.0.0.0:22              0.0.0.0:*               LISTEN      767/sshd            
    tcp6       0      0 ::1:25                  :::*                    LISTEN      1877/master         
    tcp6       0      0 :::3306                 :::*                    LISTEN      1772/mysqld         
    tcp6       0      0 :::80                   :::*                    LISTEN      38293/httpd         
    tcp6       0      0 :::22                   :::*                    LISTEN      767/sshd   
    

    想启动不出现这个错误,修改如下

    #
    # If your host doesn't have a registered DNS name, enter its IP address here.
    #
    ServerName localhost:80
    
    
    配置文件中的  ServerName localhost:80   前面注释去掉,把网站名称改为 localhost
    

    安装过程报错:

    1. ./configure报错

    Configuring Apache Portable Runtime library ...

    checking for APR... configure: error: the --with-apr parameter is incorrect. It must specify an install prefix, a build directory, or an apr-config file.
    解决办法:
    下载安装
    apr
    apr-utils

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

    解决办法:yum -y install pcre-devel

    可以通过 yum list |grep pcre去搜索,因为报错中提到 libpcre说明是一个库,那么该软件包应该带有devel或者Lib字样。

      

  • 相关阅读:
    (转)运维角度浅谈MySQL数据库优化
    关于MySQL的null值
    MySQL优化——or条件优化
    MySQL优化原理
    Xcode Archive打包失败问题
    ionic3 对android包进行签名
    ios 审核未通过 相机相册权限问题
    js计算两个日期相差天数
    截取URL链接中字段的方法
    ionic3 自定义组件 滑动选择器 ion-multi-picker
  • 原文地址:https://www.cnblogs.com/chyuanliu/p/8481477.html
Copyright © 2011-2022 走看看