zoukankan      html  css  js  c++  java
  • Apache源码编译安装

    安装相关依赖包

    yum -y install wget gcc make pcre-devel openssl-devel expat-devel
    

    编译安装

    方法1

    1. 安装apr
    tar xvf apr-1.7.0.tar.bz2
    cd apr-1.7.0/
    
    ./configure --prefix=/apps/apr
    # 这里可能会有如下所示报错,不影响。
    # rm: cannot remove `libtoolT': No such file or directory 
    
    make -j 2 && make install
    
    1. 安装apr-util
    tar xvf apr-util-1.6.1.tar.bz2
    cd apr-util-1.6.1/
    
    ./configure --prefix=/apps/apr-util --with-apr=/apps/apr
    
    make -j 2 && make install
    
    1. 安装aptche
    tar xvf httpd-2.4.46.tar.bz2
    cd httpd-2.4.46/
    
    ./configure 
    --prefix=/apps/httpd-2.4.46 
    --enable-so 
    --enable-ssl 
    --enable-cgi 
    --enable-rewrite 
    --with-zlib 
    --with-pcre 
    --with-apr=/apps/apr/ 
    --with-apr-util=/apps/apr-util/ 
    --enable-modules=most 
    --enable-mpms-shared=all 
    --with-mpm=prefork
    
    make -j 2 && make install
    

    方法2

    1. 将apr包和apr-util包解压后移动到httpd包下的srclib
    tar xvf apr-1.7.0.tar.bz2
    tar xvf apr-util-1.6.1.tar.bz2
    tar xvf httpd-2.4.46.tar.bz2
    
    mv apr-1.7.0 httpd-2.4.46/srclib/apr
    mv apr-util-1.6.1 httpd-2.4.46/srclib/apr-util
    
    1. 三者一起编译安装
    cd httpd-2.4.46/
    
    ./configure 
    --prefix=/apps/httpd24 
    --enable-so 
    --enable-ssl 
    --enable-cgi 
    --enable-rewrite 
    --with-zlib 
    --with-pcre 
    --with-included-apr 
    --enable-modules=most 
    --enable-mpms-shared=all 
    --with-mpm=prefork
    
    make -j 2 && make install
    
    

    配置httpd

    # 创建apache账户
    useradd -r -s /sbin/nologin apache
    
    # 修改配置文件
    [root@centos7 ~]#vim /apps/httpd24/conf/httpd.conf
    User apache
    Group apache
    
    # 准备PATH变量
    ## 方法1
    echo 'PATH=/apps/httpd24/bin:$PATH' >> /etc/profile.d/httpd24.sh
    . /etc/profile.d/httpd24.sh
    
    ## 方法2
    ln -s /apps/httpd24/bin/* /usr/sbin/
    
    # 配置man帮助
    echo "MANDATORY_MANPATH                       /apps/httpd24/man" >> /etc/man_db.conf
    
    # 创建service文件
    cat > /usr/lib/systemd/system/httpd24.service <<EOF
    [Unit]
    Description=The Apache HTTP Server
    After=network.target remote-fs.target nss-lookup.target
    Documentation=man:httpd(8)
    Documentation=man:apachectl(8)
    
    [Service]
    Type=forking
    ExecStart=/apps/httpd24/bin/apachectl start
    ExecReload=/apps/httpd24/bin/apachectl graceful
    ExecStop=/apps/httpd24/bin/apachectl stop
    KillSignal=SIGCONT
    PrivateTmp=true
    
    [Install]
    WantedBy=multi-user.target
    EOF
    

    启动httpd

    systemctl enable --now httpd24.service
    
  • 相关阅读:
    python基础练习题(题目 矩阵对角线之和)
    python基础练习题(题目 对10个数进行排序)
    python基础练习题(题目 文本颜色设置)
    windows批处理执行图片爬取脚本
    Linux 设置网卡最大传输单位MTU
    Linux 查看开机 log
    Linux实现脚本开机自启动
    查看 linux flash 分区大小查看 linux flash 分区大小
    kernel 编译提示 mkimage command not found – U-Boot images will not be built
    linux内核编译中No rule to make ... ipt_ecn.c 的处理
  • 原文地址:https://www.cnblogs.com/wuvikr/p/13918170.html
Copyright © 2011-2022 走看看