• Ubuntu-server 22.04LTS源码编译apache服务器


    1 系统环境

    # cat /etc/os-release
    PRETTY_NAME="Ubuntu 22.04.3 LTS"
    NAME="Ubuntu"
    VERSION_ID="22.04"
    VERSION="22.04.3 LTS (Jammy Jellyfish)"
    VERSION_CODENAME=jammy
    ID=ubuntu
    ID_LIKE=debian
    HOME_URL="https://www.ubuntu.com/"
    SUPPORT_URL="https://help.ubuntu.com/"
    BUG_REPORT_URL="https://bugs.launchpad.net/ubuntu/"
    PRIVACY_POLICY_URL="https://www.ubuntu.com/legal/terms-and-policies/privacy-policy"
    UBUNTU_CODENAME=jammy
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13

    2下载源码文件

    2.1 创建目录

    # mkdir /data
    # cd /data
    # mkdir apache
    # mkdir pcre
    # mkdir apr-util
    # mkdir apr
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6

    2.2 下载源码

    # wget https://mirrors.aliyun.com/apache/apr/apr-1.7.4.tar.gz
    # wget https://mirrors.aliyun.com/apache/apr/apr-util-1.6.3.tar.gz
    # wget http://downloads.sourceforge.net/project/pcre/pcre/8.45/pcre-8.45.tar.gz
    # wget https://dlcdn.apache.org/httpd/httpd-2.4.57.tar.gz
    
    • 1
    • 2
    • 3
    • 4

    各自解压到响应文件夹

    2.3 编译 apr

    # ./configure --prefix=/usr/local/apr
    # make
    # make install
    
    • 1
    • 2
    • 3

    2.4 编译apr-util

    # ./configure --prefix=/usr/local/apr-util --with-apr=/usr/local/apr/bin/apr-1-config
    # make 
    # make install
    
    • 1
    • 2
    • 3

    2.5 编译 pcre

    # ./configure --prefix=/usr/local/pcre
    # make
    # make install
    
    • 1
    • 2
    • 3

    2.6 编译httpd

    # ./configure --prefix=/usr/local/httpd --with-apr=/usr/local/apr --with-apr-util=/usr/local/apr-util
    # make
    # make install
    
    • 1
    • 2
    • 3

    3 相关错误记录

    3.1 报错libpcre.so.1不存在

    # ./apachectl start
    /usr/local/httpd/bin/httpd: error while loading shared libraries: libpcre.so.1: cannot open shared object file: No such file or directory
    
    • 1
    • 2

    解决方法:

    echo "/usr/local/lib" >> /etc/ld.so.conf
    ldconfig
    
    • 1
    • 2

    3.2 告警domain

    AH00558: httpd: Could not reliably determine the server's fully qualified domain name, using 127.0.1.1. Set the 'ServerName' directive globally to suppress this message
    
    • 1

    修改配置文件

    # cd conf
    # vi httpd.conf
    ...
    # If your host doesn't have a registered DNS name, enter its IP address here.
    #
    ServerName 0.0.0.0:80
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6

    注意,这是本地测试环境,如果有公网注册域名,可以使用,例如:www.baidu.com:80

    3.3 因为版本原因,执行编译httpd报错 working script at pcre-config

    ...
    checking for pcre-config... pcre-config
    configure: error: Did not find working script at pcre-config
    
    • 1
    • 2
    • 3

    PCRE默认指定路径尝试,

    # ./configure
    
    • 1

    完成后用如下命令监测:

    # whereis pcre-config
    pcre-config: /usr/local/bin/pcre-config
    
    • 1
    • 2
  • 相关阅读:
    一文看懂推荐系统:Gate网络2:百度GemNN(Gating-Enhanced Multi-Task Neural Networks)
    [每周一更]-(第23期):Docker 逻辑图及常用命令汇总
    js 文字超过div宽度的时候,自动换行
    十五、异常(1)
    xgboost 中的二阶导数为什么收敛更快?
    「解析」YOLOv5 classify分类模板
    【番外篇】如何制作慕斯蛋糕
    jQuery-tmpl 模板引擎使用方法说明
    Lwip之TCP协议实现(二)
    学会二阶思维,你就能像巴菲特一样思考了
  • 原文地址:https://blog.csdn.net/zhangh571354026/article/details/132921213