Apache(httpd) source installation

pache is the name of a foundation. httpd is the package we want to install. In the early days it was called apache. Apache's official website www.apache.org

Because the Apr libraries used by httpd2.2 and httpd2.4 are different, and the Apr that comes with centos7 does not match them, you need to install the Apr library files using yum.

[root@dl-001 src]#  WGet http://mirrors.cnnic.cn/apache/httpd/httpd-2.4.29.tar.gz //2.4 source package

[root@dl-001 src]#  WGet http://mirrors.cnnic.cn/apache/apr/apr-1.6.3.tar.gz //apr-1.6.3r package

[root@dl-001 src]#  WGet http://mirrors.cnnic.cn/apache/apr/apr-util-1.6.1.tar.gz //apr-util-1.6.1 package

Description: Download and unzip, the following operations need to enter.

1, Install the apr package

[root@dl-001 src]# cd apr-1.6.3
 To configure:
[root@dl-001 apr-1.6.3]# ./configure --prefix=/usr/local/apr

Report errors:
configure: error: in `/usr/local/src/apr-1.6.3':
configure: error: no acceptable C compiler found in $PATH
See `config.log' for more details
 //Description: A C-language-specific compiler is missing.  

[root@dl-001 apr-1.6.3]# Yum install-y gcc* //install GCC compiler.  

[root@dl-001 apr-1.6.3]# ./configure --prefix=/usr/local/apr
 //Configuration succeeded!

Compile and install:
[root@dl-001 apr-1.6.3]# make 

Report errors:  
xml/apr_xml.c:35:19: Fatal error: expat.h: No file or directory
 #include <expat.h>
Compilation interrupted.
make[1]: *** [xml/apr_xml.lo] Error 1
 make[1]: leave directory'/usr/local/src/apr-util-1.6.0'
make: *** [all-recursive] Error 1

[root@dl-001 apr-1.6.3]# yum -y install expat-devel

[root@dl-001 apr-1.6.3]# make && make install
[root@dl-001 apr-1.6.3]# echo $?

Note: APR version 1.6.2 has changed, encryption settings have been made, and the following commands are required for compilation (otherwise the library file cannot be invoked when Apache is installed):

[root@dl-001 httpd-2.4.29]# CC="gcc -m64" ./configure --prefix=/usr/local/apr

2, Install the Apr-util package

[root@dl-001 src]# cd apr-util-1.6.1
[root@dl-001 apr-util-1.6.1]# ./configure --prefix=/usr/local/apr-util --with-apr=/usr/local/apr
[root@dl-001 apr-util-1.6.1]# echo $?

//Compile and install:
[root@dl-001 apr-util-1.6.1]# make && make install

3, Install httpd

[root@dl-001 src]# cd httpd-2.4.29 
[root@dl-001 httpd-2.4.29]# ./configure --prefix=/usr/local/apache2.4 --with-apr=/usr/local/apr --with-apr-util=/usr/local/apr-util --enable-so --enable-mods-shared=most

//Report errors:
configure: error: pcre-config for libpcre not found. PCRE is required and available from http://pcre.org/  
//Note: The library file pcre needs to be installed


[root@dl-001 httpd-2.4.29]# yum list |grep pcre //View related packages

//Install the following packages based on the results of your search:
[root@dl-001 httpd-2.4.29]# yum install -y pcre-devel

[root@dl-001 httpd--2.4.29]# ./configure --prefix=/usr/local/apache2.4 --with-apr=/usr/local/apr --with-apr-util=/usr/local/apr-util --enable-so --enable-mods-shared=most
[root@dl-001 httpd-2.4.29]# echo $?

//Compile and Install

[root@dl-001 httpd-2.4.29]# make

[root@dl-001 httpd-2.4.29]# make install
[root@dl-001 httpd-2.4.29]# echo $?

Troubleshooting errors

When source compilation installs httpd,. /configure executes without errors and errors occur when make

The errors are as follows:

/usr/local/apr-util/lib/libaprutil-1.so: undefined reference to `XML_StopParser'
/usr/local/apr-util/lib/libaprutil-1.so: undefined reference to `XML_Parse'
/usr/local/apr-util/lib/libaprutil-1.so: undefined reference to `XML_ErrorString'
/usr/local/apr-util/lib/libaprutil-1.so: undefined reference to `XML_SetElementHandler'
collect2: error: ld returned 1 exit status
make[2]: *** [htpasswd] Error 1
make[2]: Leave Directory/usr/local/src/httpd-2.4.28/support"
make[1]: *** [all-recursive] Error 1
make[1]: Leave Directory/usr/local/src/httpd-2.4.28/support"
make: *** [all-recursive] Error 1

Note: The xml-related libraries are missing and the libxml2-devel package needs to be installed.Direct installation does not solve the problem because the apr-util called by httpd is already installed, but apr-util is not supported by the libxml2-devel package

1. Install the libxml2-devel package
[root@dl-001 ~]# yum install -y libxml2-devel

2. Remove the apr-util installation directory and recompile the installation

[root@dl-001 ~]# rm -rf /usr/local/apr-util
[root@dl-001 ~]# cd /usr/local/src/apr-util-1.6.1

# This is an important step and you must clear the cache from the previous configuration
[root@dl-001 apr-util-1.6.1]# make clean

# Source Installation Three Steps
[root@dl-001 apr-util-1.6.1]# ./configure --prefix=/usr/local/apr-util --with-apr=/usr/local/apr
[root@dl-001 apr-util-1.6.1]# make
[root@dl-001 apr-util-1.6.1]# make install

3. Recompile and install httpd

# It is also important to clean up the previous cache
[root@dl-001 src]# cd /usr/local/src/httpd-2.4.28
[root@dl-001 httpd-2.4.29]# make clean
[root@dl-001 httpd-2.4.29]# ./configure --prefix=/usr/local/apache2.4  --with-apr=/usr/local/apr --with-apr-util=/usr/local/apr-util --enable-so --enable-mods-shared=most
[root@dl-001 httpd-2.4.29]# make
# make did not report a mistake at this time

[root@dl-001 httpd-2.4.29]# make install

4. Start the service

[root@dl-001 httpd-2.4.29]# Cd/usr/local/apache 2.4//Switch to the Apache 2.4 directory
[root@dl-001 apache2.4]# ls
bin  build  cgi-bin  conf  error  htdocs  icons  include  logs  man  manual  modules
//Note: More common directories are bin (executable file storage directory), conf (configuration file location directory), htdocs (storage of an access page), logs (log file storage directory), modules (storage of extensions). 

//View the modules that Apache loads:
[root@dl-001 apache2.4]# /usr/local/apache2.4/bin/httpd -M 
[root@dl-001 apache2.4]# /usr/local/apache2.4/bin/apachectl -M 


[root@dl-001 apache2.4]# /usr/local/apache2.4/bin/apachectl start
AH00558: httpd: Could not reliably determine the server's fully qualified domain name, using fe80::65d2:adc:20d3:8c74. Set the 'ServerName' directive globally to suppress this message
#The error hints here have no effect.

//Detection status:
[root@dl-001 apache2.4]# ps aux |grep httpd
root      8090  0.0  0.2 144572  2720 ?        Ss   23:36   0:00 /usr/local/apache2.4/bin/httpd -k start
daemon    8091  0.0  0.1 144572  1996 ?        S    23:36   0:00 /usr/local/apache2.4/bin/httpd -k start
daemon    8092  0.0  0.1 144572  1996 ?        S    23:36   0:00 /usr/local/apache2.4/bin/httpd -k start
daemon    8093  0.0  0.1 144572  1996 ?        S    23:36   0:00 /usr/local/apache2.4/bin/httpd -k start
daemon    8094  0.0  0.1 144572  1996 ?        S    23:36   0:00 /usr/local/apache2.4/bin/httpd -k start
daemon    8095  0.0  0.1 144572  1996 ?        S    23:36   0:00 /usr/local/apache2.4/bin/httpd -k start
root      8116  0.0  0.0 112680   972 pts/4    S+   23:38   0:00 grep --color=auto httpd
[root@dl-001 apache2.4]# netstat -lntp
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address           Foreign Address         State       PID/Program name    
tcp        0      0    *               LISTEN      1181/sshd           
tcp        0      0  *               LISTEN      1790/master         
tcp6       0      0 :::80                   :::*                    LISTEN      8090/httpd          
tcp6       0      0 :::22                   :::*                    LISTEN      1181/sshd           
tcp6       0      0 ::1:25                  :::*                    LISTEN      1790/master         

Tags: Apache yum xml

Posted on Sun, 10 May 2020 12:26:31 -0400 by psymonic