源码安装apache
作者:互联网
目录
基础环境准备
[root@YL ~]# dnf -y install gcc gcc-c++ make wget
Last metadata expiration check: 5:03:03 ago on Tue 12 Jul 2022 02:56:21 PM CST.
Package make-1:4.2.1-10.el8.x86_64 is already installed.
Package wget-1.19.5-10.el8.x86_64 is already installed.
Dependencies resolved.
==================================================================
Package Arch Version Repository Size
==================================================================
Installing:
gcc x86_64 8.4.1-1.el8 AppStream 23 M
gcc-c++ x86_64 8.4.1-1.el8 AppStream 12 M
.........
kernel-headers-4.18.0-257.el8.x86_64
libmpc-1.1.0-9.1.el8.x86_64
libstdc++-devel-8.4.1-1.el8.x86_64
libxcrypt-devel-4.1.1-4.el8.x86_64
Complete!
下载源码包
[root@YL src]# wget https://mirrors.aliyun.com/apache/apr/apr-1.7.0.tar.gz
--2022-07-13 11:52:10-- https://mirrors.aliyun.com/apache/apr/apr-1.7.0.tar.gz
Resolving mirrors.aliyun.com (mirrors.aliyun.com)... 45.253.17.226, 45.253.17.214, 45.253.17.216, ...
Connecting to mirrors.aliyun.com (mirrors.aliyun.com)|45.253.17.226|:443... connected.
解压源码包,并进入相应目录
[root@YL src]# tar xf apr-1.7.0.tar.gz
[root@YL src]# cd apr-1.7.0
配置相关的选项,并生成Makefile
[root@YL apr-1.7.0]# ./configure --help|head
`configure' configures this package to adapt to many kinds of systems.
Usage: ./configure [OPTION]... [VAR=VALUE]...
To assign environment variables (e.g., CC, CFLAGS...), specify them as
VAR=VALUE. See below for descriptions of some of the useful variables.
Defaults for the options are specified in brackets.
Configuration:
编译一部曲 ./configure
指定编译参数
[root@YL apr-1.7.0]# ./configure --prefix=/usr/local/apr
checking build system type... x86_64-pc-linux-gnu
checking host system type... x86_64-pc-linux-gnu
checking target system type... x86_64-pc-linux-gnu
Configuring APR library
Platform: x86_64-pc-linux-gnu
........
config.status: executing default commands
config.status: include/apr.h is unchanged
config.status: include/arch/unix/apr_private.h is unchanged
[root@YL apr-1.7.0]#
验证这一步命令是否成功, 非0的都不算成功
[root@YL apr-1.7.0]# echo $?
0
编译二三步曲 make|makeinstal
编译并安装
[root@YL apr-1.7.0]# make |make install
sed 's,^\(location=\).*$,\1installed,' < apr-1-config > apr-config.out
sed -e 's,^\(apr_build.*=\).*$,\1/usr/local/apr/build-1,' -e 's,^\(top_build.*=\).*$,\1/usr/local/apr/build-1,' < build/apr_rules.mk > build/apr_rules.out
.........
/usr/bin/install -c -m 644 build/apr_rules.out /usr/local/apr/build-1/apr_rules.mk
/usr/bin/install -c -m 755 apr-config.out /usr/local/apr/bin/apr-1-config
[root@YL apr-1.7.0]#
库文件的配置
[root@YL apr-1.7.0]# cat /etc/ld.so.conf.d/apr.conf
/usr/local/apr/lib
头部文件的配置
[root@YL apr]# cd /usr/local/apr /usr/local/apr
下载apr-util的源码包
[root@YL apr]# cd /usr/src/
[root@YL src]# wget apr-util-1.6.1.tar.gz
进入相对应的目录
[root@YL src]# cd apr-util-1.6.1
配置相关的选项,并生成Makefile
[root@YL apr-util-1.6.1]# ./configure --help|head
`configure' configures this package to adapt to many kinds of systems.
Usage: ./configure [OPTION]... [VAR=VALUE]...
To assign environment variables (e.g., CC, CFLAGS...), specify them as
VAR=VALUE. See below for descriptions of some of the useful variables.
Defaults for the options are specified in brackets.
Configuration:
指定编译参数
[root@YL apr-util-1.6.1]# ./configure --prefix=/usr/local/apr-util/ --with-apr=/usr/local/apr
checking build system type... x86_64-pc-linux-gnu
checking host system type... x86_64-pc-linux-gnu
checking target system type... x86_64-pc-linux-gnu
checking for a BSD-compatible install... /usr/bin/install -c
checking for working mkdir -p... yes
..........
config.status: creating include/apu_want.h
config.status: creating test/Makefile
config.status: creating include/private/apu_config.h
config.status: executing default commands
验证这一步命令是否成功, 非0的都不算成功
[root@YL apr-util-1.6.1]# echo $?
0
编译并安装
[root@YL apr-util-1.6.1]# make |make install
sed 's,^\(location=\).*$,\1installed,' < apu-1-config > apu-config.out
make[1]: Entering directory '/usr/src/apr-util-1.6.1'
........
/usr/bin/install -c -m 644 aprutil.exp /usr/local/apr-util//lib
/usr/bin/install -c -m 755 apu-config.out /usr/local/apr-util//bin/apu-1-config
库文件的配置方法
[root@YL apr-util-1.6.1]# vi /etc/ld.so.conf.d/apr-util.conf
[root@YL apr-util-1.6.1]# cat /etc/ld.so.conf.d/apr-util.conf
/usr/local/apr-util/lib
头部文件的配置方法
[root@YL apr-util-1.6.1]# ln -s /usr/local/apr-util/include/ /usr/
include/apr-util/
下载源码包
[root@YL src]# wget https://mirrors.aliyun.com/apache/httpd/httpd-2.4.54.tar.gz |head
--2022-07-13 12:20:47-- https://mirrors.aliyun.com/apache/httpd/httpd-2.4.54.tar.gz
Resolving mirrors.aliyun.com (mirrors.aliyun.com)... 45.253.17.214, 45.253.17.212, 45.253.17.216, ...
Connecting to mirrors.aliyun.com (mirrors.aliyun.com)|45.253.17.214|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 9743277 (9.3M) [application/octet-stream]
Saving to: ‘httpd-2.4.54.tar.gz.1’
解压源码包,进入其目录中
[root@YL src]# tar xf httpd-2.4.54.tar.gz
[root@YL src]# cd httpd-2.4.54
配置相关的选项,并生成Makefile
[root@YL httpd-2.4.54]# ./configure --help|head
`configure' configures this package to adapt to many kinds of systems.
Usage: ./configure [OPTION]... [VAR=VALUE]...
To assign environment variables (e.g., CC, CFLAGS...), specify them as
VAR=VALUE. See below for descriptions of some of the useful variables.
Defaults for the options are specified in brackets.
Configuration:
指定编译参数
[root@YL httpd-2.4.54]# ./configure --prefix=/usr/local/httpd --with-apr=/usr/local/apr --with-apr-util=/usr/local/apr-util/
checking for chosen layout... Apache
checking for working mkdir -p... yes
验证这一步命令是否成功, 非0的都不算成功
[root@YL httpd-2.4.54]# echo $?
0
编译并安装
[root@YL httpd-2.4.54]# make |make install
Making install in srclib
make[1]: Entering directory '/usr/src/httpd-2.4.54/srclib'
make[2]: Entering directory '/usr/src/httpd-2.4.54/srclib'
make[2]: Leaving directory '/usr/src/httpd-2.4.54/srclib'
.......
Installing header files
Installing build system files
Installing man pages and online manual
make[1]: Leaving directory '/usr/src/httpd-2.4.54'
头部文件的配置
[root@YL httpd-2.4.54]# ln -s /usr/local/httpd/include/ /usr/include/httpd
httpd启动
[root@YL httpd-2.4.54]# /usr/local/httpd/bin/apachectl start
AH00558: httpd: Could not reliably determine the server's fully qualified domain name, using fe80::9fb7:6eb1:f172:7121%ens160. Set the 'ServerName' directive globally to suppress this message
httpd (pid 52245) already running
访问apache
[root@YL httpd-2.4.54]# curl YL
<html><body><h1>It works!</h1></body></html>
网页访问apache
enter link description here
三种风格init的程序特点以及区别
1.SysV 在系统开机时进程会一个一个的启动,开机后所有进程都已经完全启动了
2.UpStart 在系统开机时第一个进程开启时会告诉第二个进程我"我"已经开启了你可以开始启动了,开机后所有进程都已经启动且速度快于SysV
3.systemd 在系统开机时只启动systemd这一个进程,告诉主机我已经全部启动了,但是进程并没有启动,只是做了准备工作,在主机要使用时来再去开启这个进程。开机速度极快
区别:第一种虽然开机慢,但是他全部的进程都已经开启了,第二种进行了一个伪并行,速度快于第一种,开机时也会全部进程启动,第三种是告诉自己已经启动了,事实上除了systemd没有启动任何进程,但是开机速度快,当主机调用某一个进程时再去开启那一个进程
标签:...,YL,httpd,apr,root,源码,usr,apache,安装 来源: https://www.cnblogs.com/TQingS/p/16473466.html