编译安装http2.4,实现可以正常访问,并将编译步骤和结果提交 Linux0402
个人知识概括:
1)rpm: 基本下载安装,但因各种依赖包的关系 安装卸载不便,生产环境使用不多
2)yum install xxx : 底层封装了rpm,依赖关系使用更好,类似于window一键安装
3)源码编译安装: 类似于window自定义安装,可以更符合生产需求
编译安装过程:
①运行configure,生成makefile (一些小的服务 直接含有makefile文件)
②make
③make install
安装可能问题点:
①安装包,可通过 install info httpd 获得网站路径,复制下载链接 wget url
②第一次安装时,由于各种依赖关系的嵌套,要详细看报错信息,将需要依赖的包一一安装
③安装服务启动后,查看下 启动服务的用户名 组 权限等,是否需要修改(比如服务运用的改为nologin,groupadd、 useradd )
编译安装http2.4过程:
1 [root@centos8 ding]# yum info httpd 2 Repository baseos is listed more than once in the configuration 3 Last metadata expiration check: 1:36:09 ago on Sun 14 Nov 2021 10:51:26 PM CST. 4 Available Packages 5 Name : httpd 6 Version : 2.4.37 7 Release : 39.module_el8.4.0+950+0577e6ac.1 8 Architecture : x86_64 9 Size : 1.4 M 10 Source : httpd-2.4.37-39.module_el8.4.0+950+0577e6ac.1.src.rpm 11 Repository : appstream 12 Summary : Apache HTTP Server 13 URL : https://httpd.apache.org/ 14 License : ASL 2.0 15 Description : The Apache HTTP Server is a powerful, efficient, and extensible 16 : web server.
[root@centos8 ding]# wget https://dlcdn.apache.org//httpd/httpd-2.4.51.tar.bz2
--2021-11-15 00:41:28-- https://dlcdn.apache.org//httpd/httpd-2.4.51.tar.bz2
Resolving dlcdn.apache.org (dlcdn.apache.org)... 151.101.2.132, 2a04:4e42::644
Connecting to dlcdn.apache.org (dlcdn.apache.org)|151.101.2.132|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 7653609 (7.3M) [application/x-bzip2]
Saving to: ‘httpd-2.4.51.tar.bz2’
httpd-2.4.51.tar.bz2 100%[========================================>] 7.30M 97.8KB/s in 1m 44s
2021-11-15 00:43:12 (72.0 KB/s) - ‘httpd-2.4.51.tar.bz2’ saved [7653609/7653609]
[root@centos8 ding]# cp httpd-2.4.51.tar.bz2 /usr/local/src
[root@centos8 ding]# cd /usr/local/src
[root@centos8 src]# ls
httpd-2.4.51.tar.bz2
[root@centos8 src]# tar xvf httpd-2.4.51.tar.bz2
[root@centos8 src]# ls
httpd-2.4.51 httpd-2.4.51.tar.bz2
[root@centos8 src]# cd httpd-2.4.51/
[root@centos8 httpd-2.4.51]# ./configure --prefix=/app/httpd --sysconfdir=/etc/httpd --enable--ssl
configure:
checking for APR... no
configure: error: APR not found. Please read the documentation.
[root@centos8 httpd-2.4.51]# yum install apr-devel
checking for APR-util... no
configure: error: APR-util not found. Please read the documentation.
[root@centos8 httpd-2.4.51]# yum -y install apr-util-devel
checking for APR-util... yes
checking for gcc... gcc
checking whether the C compiler works... yes
checking for C compiler default output file name... a.out
checking for suffix of executables...
checking whether we are cross compiling... no
checking for suffix of object files... o
checking whether we are using the GNU C compiler... yes
checking whether gcc accepts -g... yes
checking for gcc option to accept ISO C89... none needed
checking how to run the C preprocessor... gcc -E
checking for gcc option to accept ISO C99... none needed
checking for pcre-config... false
configure: error: pcre-config for libpcre not found. PCRE is required and available from http://pcre.org/
[root@centos8 httpd-2.4.51]# yum -y install gcc
checking for gcc option to accept ISO C99... none needed
checking for pcre-config... false
configure: error: pcre-config for libpcre not found. PCRE is required and available from http://pcre.org/
[root@centos8 httpd-2.4.51]# yum -y install pcre-devel
[root@centos8 httpd-2.4.51]# yum install openssl-devel
[root@centos8 httpd-2.4.51]# make -j 2
gcc: error: /usr/lib/rpm/redhat/redhat-hardened-ld: No such file or directory
....
Filename : /usr/lib/rpm/redhat/redhat-hardened-ld
[root@centos8 httpd-2.4.51]# yum -y install /usr/lib/rpm/redhat/redhat-hardened-ld
make[4]: Leaving directory '/usr/local/src/httpd-2.4.51/modules/mappers'
make[3]: Leaving directory '/usr/local/src/httpd-2.4.51/modules/mappers'
make[2]: Leaving directory '/usr/local/src/httpd-2.4.51/modules'
make[2]: Entering directory '/usr/local/src/httpd-2.4.51/support'
make[2]: Leaving directory '/usr/local/src/httpd-2.4.51/support'
make[1]: Leaving directory '/usr/local/src/httpd-2.4.51'
[root@centos8 httpd-2.4.51]# make install
Installing build system files
mkdir /app/httpd/build
Installing man pages and online manual
mkdir /app/httpd/man
mkdir /app/httpd/man/man1
mkdir /app/httpd/man/man8
mkdir /app/httpd/manual
make[1]: Leaving directory '/usr/local/src/httpd-2.4.51'
安装后确认启动
[root@centos8 httpd-2.4.51]# tree /app/httpd/ -d /app/httpd/ ├── bin ├── build ├── cgi-bin ├── error │ └── include ├── htdocs ├── icons │ └── small ├── include ├── logs ├── man │ ├── man1 │ └── man8 ├── manual │ ├── developer │ ├── faq │ ├── howto │ ├── images │ ├── misc │ ├── mod │ ├── platform │ ├── programs │ ├── rewrite │ ├── ssl │ ├── style │ │ ├── css │ │ ├── lang │ │ ├── latex │ │ ├── scripts │ │ └── xsl │ │ └── util │ └── vhosts └── modules 33 directories [root@centos8 httpd-2.4.51]#
[root@centos8 httpd-2.4.51]# bash /app/httpd/bin/apachectl start
[root@centos8 bin]# curl 10.0.0.150
It works!
[root@centos8 bin]#
增加组 用户 用于此服务
[root@centos8 bin]# ps -aux | grep httpd root 34768 0.0 0.2 119008 5376 ? Ss 01:42 0:00 /app/httpd/bin/httpd -k start daemon 34769 0.0 0.3 1339632 7616 ? Sl 01:42 0:00 /app/httpd/bin/httpd -k start daemon 34770 0.0 0.4 1339632 9664 ? Sl 01:42 0:00 /app/httpd/bin/httpd -k start daemon 34771 0.0 0.3 1339632 7616 ? Sl 01:42 0:00 /app/httpd/bin/httpd -k start daemon 34862 0.0 0.6 1339632 12120 ? Sl 01:42 0:00 /app/httpd/bin/httpd -k start root 34937 0.0 0.0 12136 1100 pts/0 R+ 01:47 0:00 grep --color=auto httpd [root@centos8 bin]# groupadd -r -g 88 apache [root@centos8 bin]# useradd -r -g apache -s /sbin/nologin -d /var/www/ apache [root@centos8 bin]# cd /etc/httpd [root@centos8 httpd]# ls extra httpd.conf magic mime.types original [root@centos8 httpd]# vim httpd.conf [root@centos8 httpd]# bash /app/httpd/bin/apachectl stop [root@centos8 httpd]# bash /app/httpd/bin/apachectl -k start [root@centos8 httpd]# ps -aux | grep httpd root 35032 0.0 0.2 119008 5340 ? Ss 01:52 0:00 /app/httpd/bin/httpd -k start apache 35033 0.0 0.3 1339632 7684 ? Sl 01:52 0:00 /app/httpd/bin/httpd -k start apache 35034 0.0 0.3 1339632 7684 ? Sl 01:52 0:00 /app/httpd/bin/httpd -k start apache 35035 0.0 0.5 1339632 11764 ? Sl 01:52 0:00 /app/httpd/bin/httpd -k start root 35118 0.0 0.0 12136 1036 pts/0 R+ 01:52 0:00 grep --color=auto httpd [root@centos8 httpd]#