Apache Download the relevant package:
1. First downloaded separately: 2.4.39 Source Package, apr-1.6.5, apr-util-1.6.1; last two are common function library;
Apache's introduction:
Apache is the name of a foundation, httpd is what we want to install the package, its name is called early apache.
Apache official website www.apache.org.
Download this experiment binary source packages are as follows:
2.4源码包: https://mirrors.tuna.tsinghua.edu.cn/apache/httpd/httpd-2.4.39.tar.gz
apr: http://mirrors.cnnic.cn/apache/apr/apr-1.6.5.tar.gz
apr-util: http://mirrors.cnnic.cn/apache/apr/apr-util-1.6.1.tar.gz
The last one is: http: //mirrors.cnnic.cn/apache/apr/apr-util-1.6.1.tar.bz2
apr and apr-util is a universal library, he let the httpd may not care about the underlying operating system platform that can be easily ported (moved from linux windows)
Install httpd: into / usr / local / src directory.
Installation apr-1.6.5:
Installation apr-1.6.1:
Followed by extracting archive:
tar zxvf httpd-2.4.39.tar.gz
tar zxvf apr-1.6.5.tar.gz
tar zxvf apr-util-1.6.1.tar.gz
Decompression mode (tar jxf apr-util-1.6.1.tar.bz2) of this packet is not the same and the above two packages. Otherwise it can not be normal.
Installation order:
1. Installation apr-1.6.5
Apr-1.6.5 to define the directory: the installation package: ./configure --prefix = / usr / local / apr an error:
This error is caused because there is no gcc installed. After you install the yum install gcc, the installation was successful.
执行 make && make install
2. Installation apr-util-1.6.1
Referring to the current path, go to the next directory apr-util-1.6.1:
After entering the apr-util-1.6.1 directory, initialize the directory:
./configure --prefix=/usr/local/apr-util --with-apr=/usr/local/apr
执行make&&make install ,此时发现错误,缺少expat.h包.
执行 yum install -y expat*
再则执行make&&make install
3. 安装apache 2.4
先定义到http-2.4.33/目录下面
首先要先安装 yum install -y pcre-devel
初始化,执行安装: ./configure --prefix=/usr/local/apache2.4 --with-apr=/usr/local/apr --with-apr-until=/usr/local/apr-util --enable-so --enable-mods-shared=most
执行make
一般在执行后会报错,如下所示:
问题!!make报错
collect2: error: ld returned 1 exit status
make[2]: [htpasswd] 错误 1
make[2]: 离开目录“/usr/local/src/httpd-2.4.27/support”
make[1]: [all-recursive] 错误 1
make[1]: 离开目录“/usr/local/src/httpd-2.4.27/support”
make: *** [all-recursive] 错误 1
解决的办法:
1.cp -r apr-1.6.5 /usr/local/src/httpd-2.4.27/srclib/apr
cp -r apr-util-1.6.0 /usr/local/src/httpd-2.4.27/srclib/apr-util
2. 在初始化文件后加上 --with-included-apr 再次初始化编译。
/configure --with-included-apr --prefix=/usr/local/apache2.4 --with-apr=/usr/local/apr --with-apr-util=/usr/local/apr-util --enable-so --enable-mods-shared=most
再运行make 通过:
再执行make install
查询相关的参数资料如下面这些图:
4. 启动 httpd 程序:/usr/local/apache2.4/bin/apachectl start
查看有关httpd的进程
ps aux | grep httpd
configure的命令格式也可以这样书写; \是转义字符,后面可以换行添加多行命令;
[root@ying01 httpd-2.4.33]# ./configure \
> --prefix=/usr/local/apache2.4 \> --with-apr=/usr/local/apr \> --with-apr-util=/usr/local/apr-util \> --enable-so \> --enable-mods-shared=most
产看端口号: