Source code compilation and installation httpd-2.4.43
- abstract
- Installation environment
- Software download
-
Installation and testing
- 1) Download the source code of APR, APR util, PCRE and httpd
- 2) Unzip and install apr
- 3) Unzip and install APR util
- 4) Unzip and install pcre
- 5) Unzip and install httpd
- 6) Configuration files and corresponding directories
- 5) Generate startup script and start
- 6) Set the startup mode using systemctl (startup method 2)
- 7) Test start
- Problem summary
- One click Install httpd script
abstract
[Abstract] Apache HTTP Server(hpptd), referred to as Apache for short, is an open source Web server of the Apache Software Foundation. It can run in most computer operating systems. It is widely used because of its cross platform and security. It is one of the most popular Web server-side software.
Installation environment
centos7.6
Software download
Download address: https://mirrors.tuna.tsinghua.edu.cn/apache//httpd/httpd-2.4.43.tar.gz
Installation and testing
hpptd installation depends on Apr, APR util and PCRE, so you need to install APR, APR util and PCRE first. Taking apr-1.7.0, apr-util-1.6.1, pcre-8.44 and httpd-2.4.43 as examples, download the source code, compile and install:
1) Download the source code of APR, APR util, PCRE and httpd
wget https://mirrors.tuna.tsinghua.edu.cn/apache//httpd/httpd-2.4.43.tar.gz
wget https://mirrors.tuna.tsinghua.edu.cn/apache//apr/apr-1.7.0.tar.gz
wget https://mirrors.tuna.tsinghua.edu.cn/apache/apr/apr-util-1.6.1.tar.gz
[wget https://ftp.pcre.org/pub/pcre/pcre-8.44.tar.gz
2) Unzip and install apr
tar -xvf apr-1.7.0.tar.gz
cd apr-1.7.0
./configure
make
make install
3) Unzip and install APR util
tar -xvf apr-util-1.6.1.tar.gz
cd apr-util-1.6.1
./configure --prefix=/usr/local/apr-util --with-apr=/usr/local/apr
make
make install
4) Unzip and install pcre
tar -zxvf pcre-8.44.tar.gz
cd pcre-8.44
./configure --enable-utf8
make
make install
5) Unzip and install httpd
tar -zxvf httpd-2.4.43.tar.gz
cd httpd-2.4.43
./configure --prefix=/usr/local/httpd --with-pcre=/usr/local/pcre
make
make install
Verification test
Enter the installation directory and enter/ httpd -v view version
cd /usr/local/httpd/bin
./httpd -v
Execute the following command to start the httpd service
./apachectl start
The echo information is as follows:
AH00558: httpd: Could not reliably determine the server's fully qualified domain name, using localhost.localdomain. Set the 'ServerName' directive globally to suppress this message
Execute the following code to view the httpd process. When the following information appears, it indicates that the startup is successful.
ps -ef|grep httpd
Open the browser, enter the server IP test in the browser, and the page will display It works!
6) Configuration files and corresponding directories
Configuration file path: / usr / local / apache2 / conf / httpd conf
Website root directory: / usr/local/apache2/htdocs/
5) Generate startup script and start
cp /usr/local/apache2/bin/apachectl /etc/init.d/ chmod +x /etc/init.d/apachectl /etc/init.d/apachectl restart ## Start method 1 (simple and fast)
6) Set the startup mode using systemctl (startup method 2)
vim /usr/lib/systemd/system/apache.service [Unit] Description=apache After=network.target [Service] Type=forking ExecStart=/etc/init.d/apachectl start ExecReload=/etc/init.d/apachectl restart ExecStop=/etc/init.d/apachectl stop PrivateTmp=true [Install] WantedBy=multi-user.targe
systemctl start apache.service
7) Test start
systemctl start apache.service
Problem summary
1) When installing apr, use/ During the configure command, the following error is reported: rm: cannot remove 'libtool': No such file or directory
Solution:
Modify RM='RM' in the configure file to RM='RM' to RM='RM ', to RM='RM -f ', and then execute again
./configure
make
make install
As shown below:
2) When compiling APR util, the following error is reported and the expat library is missing.
Solution:
After installing expat deval library, recompile:
yum install expat-devel -y
One click Install httpd script
#!/bin/bash #auto install httpd #by MR.xu 2020-07 #Httpd define path variable H_FILES=httpd-2.4.43.tar.bz2 H_FILES_DIR=httpd-2.4.43 H_URL=https://mirrors.bfsu.edu.cn/apache//httpd/ H_PREFIX=/usr/local/apache2/ #auto install httpd if [ -z "$1" ];then echo -e "\033[36mplease select Install Menu follow:\033[0m" echo -e "\033[32m1)Compile and install Apache The server\033[1m" echo -e "\033[31mUsage: { /bin/sh $0 1|2|3|4|help}\033[0m" exit fi if [[ "$1" -eq "1" ]];then ##Installation tools yum -y install wget tar bzip2; ##Download and install apr and apr util ##Install dependent packages first yum -y install openssl-devel pcre-devel expat-devel libtool gcc gcc-c++ #Install apr basic Portable Library ##The latest version downloaded here is apr-1.7.0 tar. GZ package wget -c https://mirrors.tuna.tsinghua.edu.cn/apache//apr/apr-1.7.0.tar.gz; ##Compile and install apr tar -xvf apr-1.7.0.tar.gz&& cd apr-1.7.0;sed -i "/ RM='\$RM'/d" configure && sed -i "/\ ofile='\$ofile'/a\RM='\$RM \-f\'" configure;./configure --prefix=/usr/local/apr if [ $? -eq 0 ];then make&& make install echo -e "\033[32mThe apr-1.7.0 install successfully!\033[0m" else echo -e "\033[32mThe apr-1.7.0 install failed,please check...!\033[0m" exit fi #Install APR util wget -c https://mirrors.tuna.tsinghua.edu.cn/apache/apr/apr-util-1.6.1.tar.gz; ##Compile and install APR util tar -xvf apr-util-1.6.1.tar.gz&& cd apr-util-1.6.1;./configure --prefix=/usr/local/apr-util --with-apr=/usr/local/apr if [ $? -eq 0 ];then make&& make install echo -e "\033[32mThe apr-util-1.6.1 install successfully!\033[0m" else echo -e "\033[32mThe apr-util-1.6.1 install failed,please check...!\033[0m" exit fi #Install pcre wget -c https://ftp.pcre.org/pub/pcre/pcre-8.44.tar.gz; ##Compile and install pcre tar -xvf pcre-8.44.tar.gz&& cd pcre-8.44;./configure --enable-utf8 if [ $? -eq 0 ];then make&& make install echo -e "\033[32mThe pcre-8.44 install successfully!\033[0m" else echo -e "\033[32mThe pcre-8.44 install failed,please check...!\033[0m" exit fi #Install httpd wget -c $H_URL/$H_FILES; ##Compile and install httpd tar -jxvf $H_FILES &&cd $H_FILES_DIR ;./configure --prefix=$H_PREFIX --with-apr=/usr/local/apr --with-apr-util=/usr/local/apr-util --with-pcre=/usr/local/pcre if [ $? -eq 0 ];then make &&make install echo -e "\033[32mThe $H_FILES_DIR sever install successfully!\033[0m" echo -e "\033[32m View version,And start httpd server !\033[0m" cd $H_PREFIX/bin/;./httpd -v;./apachectl start; echo -e "\033[32m see httpd server!process\033[0m" ps -ef|grep httpd; else echo -e "\033[32mThe $H_FILES_DIR sever install failed,please check...!\033[0m" exit fi fi