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

1 系统环境

bash 复制代码
# 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

2下载源码文件

2.1 创建目录

bash 复制代码
# mkdir /data
# cd /data
# mkdir apache
# mkdir pcre
# mkdir apr-util
# mkdir apr

2.2 下载源码

bash 复制代码
# 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

各自解压到响应文件夹

2.3 编译 apr

bash 复制代码
# ./configure --prefix=/usr/local/apr
# make
# make install

2.4 编译apr-util

bash 复制代码
# ./configure --prefix=/usr/local/apr-util --with-apr=/usr/local/apr/bin/apr-1-config
# make 
# make install

2.5 编译 pcre

bash 复制代码
# ./configure --prefix=/usr/local/pcre
# make
# make install

2.6 编译httpd

bash 复制代码
# ./configure --prefix=/usr/local/httpd --with-apr=/usr/local/apr --with-apr-util=/usr/local/apr-util
# make
# make install

3 相关错误记录

3.1 报错libpcre.so.1不存在

bash 复制代码
# ./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

解决方法:

bash 复制代码
echo "/usr/local/lib" >> /etc/ld.so.conf
ldconfig

3.2 告警domain

bash 复制代码
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

修改配置文件:

bash 复制代码
# 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

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

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

bash 复制代码
...
checking for pcre-config... pcre-config
configure: error: Did not find working script at pcre-config

PCRE默认指定路径尝试,

bash 复制代码
# ./configure

完成后用如下命令监测:

bash 复制代码
# whereis pcre-config
pcre-config: /usr/local/bin/pcre-config
相关推荐
TIANE-Kimmy3 小时前
VS code定时任务设置(mac os)
linux·运维·服务器
panshiyangmaye3 小时前
RHCSA作业1
linux·运维·服务器
爱吃生蚝的于勒4 小时前
【Linux】零基础学会linux环境基础开发工具使用(yum,vim,makefile,gdb)
linux·服务器·数据结构·c++·蓝桥杯·编辑器·vim
本贾尼4 小时前
Linux系统下的终端,会话,shell,bash,进程组这几个概念的关系。
linux·服务器·网络·ubuntu·bash
文火冰糖的硅基工坊4 小时前
[嵌入式系统-115]:鸿蒙操作系统(HarmonyOS)与欧拉操作系统(openEuler)、Linux操作系统的关系、比较及异同如下:
linux·服务器·科技·华为·重构·架构·harmonyos
馨谙5 小时前
标题:Linux 系统中的“保险库管理员”:深入浅出理解 /etc/shadow 文件
linux·运维·服务器
wadesir6 小时前
云服务器与传统服务器租用的核心差异解析(云服务器与服务器租用之间的区别在哪里?)
运维·服务器
风吹落叶花飘荡6 小时前
启用服务器登录失败处理与超时自动退出功能
运维·服务器
嵌入式郑工12 小时前
LINUX驱动开发: 设备和驱动是怎么匹配的?
linux·运维·服务器
zhuyan10813 小时前
【远程桌面】在ubuntu中安装远程桌面
ubuntu