[root@lnh xbz]# tar -xf httpd-2.4.54.tar.gz
[root@lnh xbz]# ls
apr-1.7.0 apr-util-1.6.1 httpd-2.4.54
apr-1.7.0.tar.gz apr-util-1.6.1.tar.gz httpd-2.4.54.tar.gz
//解压到当前目录
[root@lnh xbz]# cd httpd-2.4.54/
[root@lnh httpd-2.4.54]# ls
ABOUT_APACHE CMakeLists.txt InstallBin.dsp README
acinclude.m4 config.layout LAYOUT README.CHANGES
Apache-apr2.dsw configure libhttpd.dep README.cmake
Apache.dsw configure.in libhttpd.dsp README.platforms
apache_probes.d docs libhttpd.mak ROADMAP
ap.d emacs-style LICENSE server
build httpd.dep Makefile.in srclib
BuildAll.dsp httpd.dsp Makefile.win support
BuildBin.dsp httpd.mak modules test
buildconf httpd.spec NOTICE VERSIONING
CHANGES include NWGNUmakefile
changes-entries INSTALL os
//查看被解压出来的东西
[root@lnh httpd-2.4.54]# ./configure –prefix=/usr/local/src/httpd –with-apr=/usr/local/src/apr –with-apr-util=/usr/local/src/apr-util
…
config.status: creating build/config_vars.sh
config.status: creating include/ap_config_auto.h
config.status: executing default commands
configure: summary of build options:
Server Version: 2.4.54
Install prefix: /usr/local/src/httpd
C compiler: gcc
CFLAGS: -g -O2 -pthread
CPPFLAGS: -DLINUX -D_REENTRANT -D_GNU_SOURCE
LDFLAGS:
LIBS:
C preprocessor: gcc -E
//生成Makefile文件
[root@lnh httpd-2.4.54]# make
…
/usr/local/src/apr/build-1/libtool –silent –mode=link gcc -g -O2 -pthread -o mod_rewrite.la -rpath /usr/local/src/httpd/modules -module -avoid-version mod_rewrite.lo
make[4]: Leaving directory /root/xbz/httpd-2.4.54/modules/mappers
make[3]: Leaving directory /root/xbz/httpd-2.4.54/modules/mappers
make[2]: Leaving directory /root/xbz/httpd-2.4.54/modules
make[2]: Entering directory /root/xbz/httpd-2.4.54/support
make[2]: Leaving directory /root/xbz/httpd-2.4.54/support
make[1]: Leaving directory /root/xbz/httpd-2.4.54
//编译生成Makefile文件,出现的一些没有读取到的问题没有关系,继续进行下一步
[root@lnh httpd-2.4.54]# make install
…
Installing man pages and online manual
mkdir /usr/local/src/httpd/man
mkdir /usr/local/src/httpd/man/man1
mkdir /usr/local/src/httpd/man/man8
mkdir /usr/local/src/httpd/manual
make[1]: Leaving directory /root/xbz/httpd-2.4.54
//进行安装
[root@lnh httpd-2.4.54]# cd /usr/local/src/httpd/
[root@lnh httpd]# ls
bin cgi-bin error icons logs manual
build conf htdocs include man modules
//切换到httpd的安装目录进行查看,默认情况下,系统搜索库文件的路径只有/lib,/usr/lib
[root@lnh httpd]# ln -s /usr/local/src/httpd/include/ /usr/include/httpd
[root@lnh httpd]# ll /usr/include/httpd
lrwxrwxrwx. 1 root root 29 Jul 12 21:23 /usr/include/httpd -> /usr/local/src/httpd/include/
//将头文件软链接到/usr/include目录下
[root@lnh httpd]# echo “export PATH=$PATH:/usr/local/src/httpd/bin” > /etc/profile.d/httpd.sh
[root@lnh httpd]# source /etc/profile.d/httpd.sh
//配置httpd的全局环境变量,并生成效果
[root@lnh httpd]# which httpd
/usr/local/src/httpd/bin/httpd
[root@lnh httpd]# vim /etc/man_db.conf
MANDATORY_MANPATH /usr/man
MANDATORY_MANPATH /usr/share/man
MANDATORY_MANPATH /usr/local/share/man
MANDATORY_MANPATH /usr/local/src/httpd/man
//添加后面这一行
[root@lnh ~]# httpd
AH00558: httpd: Could not reliably determine the servers fully qualified domain name, using fe80::20c:29ff:fe57:f6f5%ens33. Set the ServerName directive globally to suppress this message
httpd (pid 35719) already running
//启动服务
[root@lnh ~]# ss -antl
State Recv-Q Send-Q Local Address:Port Peer Address:Port Process
LISTEN 0 128 0.0.0.0:22 0.0.0.0:*
LISTEN 0 128 *:80 *:*
LISTEN 0 128 [::]:22 [::]:*
//查看端口
[root@lnh ~]# systemctl stop firewalld.service
//关闭防火墙