1. 先下载好httpd包(下载到/usr/local/src/目录中)
2 .解压httpd包
3. 按照安装三步骤开始安装
a : ./configure --prefix=安装路径 ----通过选项参数,指定启用特性,安装路径等
检查依赖性。
b : make ----根据makefile文件,构建应用程序
c : make install ----复制文件到相应路径
如示:
[root@host src]# ls
httpd-2.4.38.tar.gz
[root@host src]# tar -xzf httpd-2.4.38.tar.gz ---解压http包
[root@host src]# ls
httpd-2.4.38 httpd-2.4.38.tar.gz
[root@host src]# cd httpd-2.4.38 ---切换到httpd解压包中
[root@host httpd-2.4.38]# ls
ABOUT_APACHE CHANGES httpd.dsp LICENSE ROADMAP
acinclude.m4 CMakeLists.txt httpd.mak Makefile.in server
Apache-apr2.dsw config.layout httpd.spec Makefile.win srclib
Apache.dsw config.log include modules support
apache_probes.d config.nice INSTALL NOTICE test
ap.d configure InstallBin.dsp NWGNUmakefile VERSIONING
build configure.in LAYOUT os
BuildAll.dsp docs libhttpd.dep README
BuildBin.dsp emacs-style libhttpd.dsp README.cmake
buildconf httpd.dep libhttpd.mak README.platforms
[root@host httpd-2.4.38]# more INSTALL ---查看INSTALL安装要求
...(此处省略一部分内容)
For complete installation documentation, see [ht]docs/manual/install.html or
http://httpd.apache.org/docs/2.4/install.html
$ ./configure --prefix=PREFIX
$ make
$ make install
$ PREFIX/bin/apachectl start
[root@host httpd-2.4.38]# ./configure --prefix=/usr/local/apache ---指定httpd安装路径
checking for chosen layout... Apache
checking for working mkdir -p... yes
checking for grep that handles long lines and -e... /usr/bin/grep
checking for egrep... /usr/bin/grep -E
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
configure:
configure: Configuring Apache Portable Runtime library...
configure:
checking for APR... no
configure: error: APR not found. Please read the documentation. ---出现error提示,缺少
apr程序
[root@host httpd-2.4.38]# cd -
/usr/local/src
[root@host src]# ------------------ 下载apr 安装包 此处省略(可以用wget 下载地址 在linux系统中直接下载,注意下载在src目录下)
[root@host src]# ls
apr-1.6.5.tar.gz httpd-2.4.38 httpd-2.4.38.tar.gz
[root@host src]# tar -xzf apr-1.6.5.tar.gz --- 解压apr包
[root@host src]# ls
apr-1.6.5 apr-1.6.5.tar.gz httpd-2.4.38 httpd-2.4.38.tar.gz
[root@host src]# cd apr-1.6.5 ---切换在解压过的apr包内
[root@host apr-1.6.5]# ./configure --prefix=/usr/local/apr
...(此处省略)
rm: cannot remove 'libtoolT': No such file or directory ---本来要删除的文件没有找到不用管
config.status: executing default commands
[root@host apr-1.6.5]# make && make install ---此处直接执行了 make和make install
...(此处省略) (用&&连接)
/usr/bin/install -c -m 644 /usr/local/src/apr-1.6.5/build/find_apr.m4 /usr/local/apr/build-1
/usr/bin/install -c -m 755 apr-config.out /usr/local/apr/bin/apr-1-config
---------------------------------------------------------------------------apr程序安装完成
[root@host apr-1.6.5]# cd -
/usr/local/src
[root@host src]# cd httpd-2.4.38 ---切换目录继续执行
[root@host httpd-2.4.38]# ./configure --prefix=/usr/local/apache --with-apr=/usr/local/apr ------------因为上次执行提示apr包,所以这次执行时要关联apr安装路径
关联:--with-apr=安装路径
checking for chosen layout... Apache
checking for working mkdir -p... yes
checking for grep that handles long lines and -e... /usr/bin/grep
checking for egrep... /usr/bin/grep -E
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
configure:
configure: Configuring Apache Portable Runtime library...
configure:
checking for APR... yes
setting CC to "gcc"
setting CPP to "gcc -E"
setting CFLAGS to " -g -O2 -pthread"
setting CPPFLAGS to " -DLINUX -D_REENTRANT -D_GNU_SOURCE"
setting LDFLAGS to " "
configure:
configure: Configuring Apache Portable Runtime Utility library...
configure:
checking for APR-util... no
configure: error: APR-util not found. Please read the documentation. ---error提示没有
apr-util程序,需要下载安装
[root@host httpd-2.4.38]# cd -
[root@host src]# ------此处下载apr-util安装包(省略)
[root@host src]# ls
apr-1.6.5 apr-util-1.6.1.tar.gz httpd-2.4.38.tar.gz
apr-1.6.5.tar.gz httpd-2.4.38
[root@host src]# tar -xzf apr-util-1.6.1.tar.gz ---解压apr-util安装包
[root@host src]# cd apr-util-1.6.1 ---切换apr-util解压包内
[root@host apr-util-1.6.1]# ./configure --prefix=/usr/local/apr-util
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
APR-util Version: 1.6.1
checking for chosen layout... apr-util
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
Applying apr-util hints file rules for x86_64-pc-linux-gnu
checking for APR... no
configure: error: APR could not be located. Please use the --with-apr option.
----提示;error:apr没有找到,重新执行时关联apr安装路径即可(--with-apr)
[root@host apr-util-1.6.1]# ./configure --prefix=/usr/local/apr-util --with-apr=/usr/local/apr/
...(此处省略一部分内容)
config.status: creating test/Makefile
config.status: creating include/private/apu_config.h
config.status: executing default commands ---没有出现error提示,进行下一步
[root@host apr-util-1.6.1]# make && make install ---二三步同时执行
... (此处省略一部分内容)
/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
-------------------------------------------------------------------------apr-util安装完成
[root@host apr-util-1.6.1]# cd -
/usr/local/src
[root@host src]# cd httpd-2.4.38 ---继续安装httpd,关联apr和par-util安装路径
[root@host httpd-2.4.38]# ./configure --prefix=/usr/local/apache --with-apr=/usr/local/apr/ --with-apr-util=/usr/local/apr-util/
...(此处省略一部分内容)
checking for pcre-config... false
configure: error: pcre-config for libpcre not found. PCRE is required and available from http://pcre.org/ ---提示:error:pcre 没有找到
[root@host httpd-2.4.38]# cd -
/usr/local/src
[root@host src]# ------此处下载pcre包
[root@host src]# ls
apr-1.6.5 apr-util-1.6.1 httpd-2.4.38 pcre-8.42.tar.gz
apr-1.6.5.tar.gz apr-util-1.6.1.tar.gz httpd-2.4.38.tar.gz
[root@host src]# tar -xzf pcre-8.42.tar.gz ----解压pcre包
[root@host src]# cd pcre-8.42
[root@host pcre-8.42]# ./configure --prefix=/usr/local/pcre
...(此处省略一部分内容)
Link pcregrep with libbz2 ....... : no
Link pcretest with libedit ...... : no
Link pcretest with libreadline .. : no
Valgrind support ................ : no
Code coverage ................... : n ---没有出现error提示,继续执行下一步
[root@host pcre-8.42]# make && make install
...(此处省略一部分内容)
make[3]: 离开目录“/usr/local/src/pcre-8.42”
make[2]: 离开目录“/usr/local/src/pcre-8.42”
make[1]: 离开目录“/usr/local/src/pcre-8.42” ---没有出现error提示,继续执行下一步
[root@host pcre-8.42]# cd - ---继续安装httpd,并关联apr,apr-util和pcre安装路径
/usr/local/src
[root@host src]# cd httpd-2.4.38
[root@host httpd-2.4.38]# ./configure --prefix=/usr/local/apache --with-apr=/usr/local/apr/ --with-apr-util=/usr/local/apr-util/ --with-pcre=/usr/local/pcre/
...(此处省略一部分内容)
Server Version: 2.4.38
Install prefix: /usr/local/apache
C compiler: gcc -std=gnu99
CFLAGS: -g -O2 -pthread
CPPFLAGS: -DLINUX -D_REENTRANT -D_GNU_SOURCE
LDFLAGS:
LIBS:
C preprocessor: gcc -E ---没有报错,继续执行下一步
[root@host httpd-2.4.38]# make && make install
...(此处省略一部分内容)
Installing configuration files
mkdir /usr/local/apache/conf
mkdir /usr/local/apache/conf/extra
mkdir /usr/local/apache/conf/original
mkdir /usr/local/apache/conf/original/extra
Installing HTML documents
mkdir /usr/local/apache/htdocs
Installing error documents
mkdir /usr/local/apache/error
Installing icons
mkdir /usr/local/apache/icons
mkdir /usr/local/apache/logs
Installing CGIs
mkdir /usr/local/apache/cgi-bin
Installing header files
mkdir /usr/local/apache/include
Installing build system files
mkdir /usr/local/apache/build
Installing man pages and online manual
mkdir /usr/local/apache/man
mkdir /usr/local/apache/man/man1
mkdir /usr/local/apache/man/man8
mkdir /usr/local/apache/manual
make[1]: 离开目录“/usr/local/src/httpd-2.4.38”
----------------------------------------------------------------没有出现error报错,安装完成
检验,运行httpd
-----------------------------------------------------------------------------------------
[root@host src]# cd .. 切换到/usr/local/apache/bin目录下
[root@host local]# cd /usr/local/apache/bin/
[root@host bin]# ls
ab checkgid envvars-std htdbm httpd rotatelogs
apachectl dbmmanage fcgistarter htdigest httxt2dbm
apxs envvars htcacheclean htpasswd logresolve
[root@host bin]# ./apachectl start
httpd (pid 7429) already running
[root@host bin]# iptables -F
[root@host bin]# ps -ef | grep httpd
root 7429 1 0 08:53 ? 00:00:00 /usr/local/apache/bin/httpd
daemon 7430 7429 0 08:53 ? 00:00:00 /usr/local/apache/bin/httpd
daemon 7431 7429 0 08:53 ? 00:00:00 /usr/local/apache/bin/httpd
daemon 7434 7429 0 08:53 ? 00:00:00 /usr/local/apache/bin/httpd
root 7520 7408 0 08:56 pts/0 00:00:00 grep --color=auto httpd
[root@host bin]# curl 192.168.241.127
<html><body><h1>It works!</h1></body></html>