[alicloud image] install and compile the Apache environment

1, Reference link 🎨

Alibaba open source mirror - OPSX mirror - Alibaba cloud developer community (aliyun.com)

apache image - apache download address - apache installation tutorial - Alibaba open source image station (aliyun.com)

Apache (Web server software) Baidu Encyclopedia (baidu.com)

Compile and install_ Apache Chinese documentation (apachehttpd.com)

2, Introduction to Apache

Apache is the world's No. 1 Web server software. It can run on almost all widely used computer platforms. It is one of the most popular Web server-side software because of its cross platform and security. It is fast and reliable, and can compile interpreters such as Perl/Python into the server through simple API expansion.

Download address: https://mirrors.aliyun.com/apache/

3, Apache compilation and installation (based on CentOS system)

1. Log in to CentOS system

2. Install dependent packages

Compile and install Apache HTTP Server. The latest version is 2.4 52. Compile and install apr, apr util, pcre and other dependent packages.

If all the above installation packages have been installed, you can directly install Apache.

🔴 apr installation

Download link: https://mirrors.aliyun.com/apache/apr/apr-1.7.0.tar.gz

# Test whether the YUM source works normally
[root@centos apache]# yum clean all
[root@centos apache]# yum repolist
# Download compressed package
[root@centos apache]# wget https://mirrors.aliyun.com/apache/apr/apr-1.7.0.tar.gz
# View apr-1.7 0.tar. gz
[root@centos apache]# ll
total 1072
-rw-r--r-- 1 root root 1093896 Jul  6  2020 apr-1.7.0.tar.gz
#Unzip the package
[root@centos apache]# tar -zxvf apr-1.7.0.tar.gz
[root@centos apache]# ll
total 1076
drwxr-xr-x 27 1001 1001    4096 Apr  2  2019 apr-1.7.0
-rw-r--r--  1 root root 1093896 Jul  6  2020 apr-1.7.0.tar.gz
# Enter the extracted folder
[root@centos apache]# cd apr-1.7.0
# Create apr installation directory folder
[root@centos apr-1.7.0]# mkdir -p /usr/local/apr/apr
# Installation configuration
[root@centos apr-1.7.0]# ./configure --prefix=/usr/local/apr/apr/
# compile
[root@centos apr-1.7.0]# make
#install
[root@centos apr-1.7.0]# make install

Some screenshots of the installation process are as follows:

🟡 APR util installation

Download link: https://mirrors.aliyun.com/apache/apr/apr-util-1.6.1.tar.gz

[root@centos apache]# wget https://mirrors.aliyun.com/apache/apr/apr-util-1.6.1.tar.gz
[root@centos apache]# ll
total 1624
drwxr-xr-x 28 1001 1001    4096 Dec 22 18:19 apr-1.7.0
-rw-r--r--  1 root root 1093896 Jul  6  2020 apr-1.7.0.tar.gz
drwxr-xr-x 20 1001 1001    4096 Oct 18  2017 apr-util-1.6.1
-rw-r--r--  1 root root  554301 Jul  6  2020 apr-util-1.6.1.tar.gz
[root@centos apache]#
[root@centos apache]# cd apr-util-1.6.1
[root@centos apr-util-1.6.1]#
[root@centos apr-util-1.6.1]# mkdir /usr/local/apr/util
# --The with APRU command means to specify the installation location of the custom apr
[root@centos apr-util-1.6.1]# ./configure --prefix=/usr/local/apr/util --with-apr=/usr/local/apr/apr
# compile
[root@centos apr-util-1.6.1]# make
#install
[root@centos apr-util-1.6.1]# make install

Some screenshots of the installation process are as follows:

🟢 pcre installation

Download link: https://sourceforge.net/projects/pcre/files/pcre/8.45/pcre-8.45.tar.gz/download

[root@centos apache]# ll
total 3672
drwxr-xr-x 28 1001 1001    4096 Dec 22 18:19 apr-1.7.0
-rw-r--r--  1 root root 1093896 Jul  6  2020 apr-1.7.0.tar.gz
drwxr-xr-x 21 1001 1001    4096 Dec 22 18:32 apr-util-1.6.1
-rw-r--r--  1 root root  554301 Jul  6  2020 apr-util-1.6.1.tar.gz
-rw-r--r--  1 root root 2096552 Dec 22 18:39 pcre-8.45.tar.gz
[root@centos apache]#
[root@centos apache]# tar -zxvf pcre-8.45.tar.gz
[root@centos apache]# cd pcre-8.45/
[root@centos pcre-8.45]#mkdir /usr/local/pcre
[root@centos pcre-8.45]# ./configure --prefix=/usr/local/pcre/
[root@centos pcre-8.45]# make
[root@centos pcre-8.45]# make install

Some screenshots of the installation process are as follows:

3. Apache installation

Download link: Alicloud open source mirror resource directory (aliyun.com)

[root@centos ~]# wget https://mirrors.aliyun.com/apache/httpd/httpd-2.4.52.tar.gz
[root@centos apache]# ll
total 13188
drwxr-xr-x 28 1001  1001    4096 Dec 22 18:19 apr-1.7.0
-rw-r--r--  1 root root  1093896 Jul  6  2020 apr-1.7.0.tar.gz
drwxr-xr-x 21 1001  1001    4096 Dec 22 18:32 apr-util-1.6.1
-rw-r--r--  1 root root   554301 Jul  6  2020 apr-util-1.6.1.tar.gz
drwxr-xr-x 12  504 games    4096 Dec 16 21:49 httpd-2.4.52
-rw-r--r--  1 root root  9719976 Dec 20 17:36 httpd-2.4.52.tar.gz
drwxr-xr-x  9 1169  1169   12288 Dec 22 18:45 pcre-8.45
-rw-r--r--  1 root root  2096552 Dec 22 18:39 pcre-8.45.tar.gz
[root@centos apache]# cd httpd-2.4.52
[root@centos httpd-2.4.52]#
[root@centos httpd-2.4.52]# mkdir /usr/local/httpd
[root@centos httpd-2.4.52]# ./configure --prefix=/usr/local/httpd/
checking for chosen layout... Apache
checking for working mkdir -p... yes
checking for grep that handles long lines and -e... /bin/grep
checking for egrep... /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.
# Because the default installation location of apr is modified, the prompt indicates that apr cannot be found. Use the help command to view it.
[root@centos httpd-2.4.52]# ./configure --help
[root@centos httpd-2.4.52]# ./configure --help | grep -i apr
  --enable-hook-probes    Enable APR hook probes
  --with-included-apr     Use bundled copies of APR/APR-Util
  --with-apr=PATH      prefix for installed APR or the full path to
                             apr-config
  --with-apr-util=PATH prefix for installed APU or the full path to
# Specify a custom directory
[root@centos httpd-2.4.52]# ./configure --prefix=/usr/local/httpd/ --with-apr=/usr/local/apr/apr/ --with-apr-util=/usr/
local/apr/util/ --with-pcre=/usr/local/pcre/  --with-included-apr
local/apr/util/ --with-pcre=/usr/local/pcre/
# compile
[root@centos httpd-2.4.52]# make
# install
[root@centos httpd-2.4.52]# make install
# Modify configuration information
[root@centos httpd-2.4.52]# vim /usr/local/httpd/conf/httpd.conf
 ServerName localhost:80
 Save exit

# Start Apache service
[root@centos ~]# /usr/local/httpd/bin/apachectl -k start

[root@localhost ~]# /usr/local/httpd/bin/apachectl -T
httpd (pid 66510) already running
[root@localhost ~]#
[root@localhost ~]# cd /usr/local/httpd/
[root@localhost httpd]# ll
total 44
drwxr-xr-x  2 root root  302 Dec 22 19:35 bin
drwxr-xr-x  2 root root  253 Dec 22 19:35 build
drwxr-xr-x  2 root root   78 Dec 22 19:10 cgi-bin
drwxr-xr-x  4 root root   84 Dec 22 19:47 conf
drwxr-xr-x  3 root root 4096 Dec 22 19:10 error
drwxr-xr-x  2 root root   24 Dec 22 19:10 htdocs
drwxr-xr-x  3 root root 8192 Dec 22 19:10 icons
drwxr-xr-x  2 root root 8192 Dec 22 19:35 include
drwxr-xr-x  3 root root  281 Dec 22 19:35 lib
drwxr-xr-x  2 root root   58 Dec 22 19:55 logs
drwxr-xr-x  4 root root   30 Dec 22 19:10 man
drwxr-xr-x 14 root root 8192 Dec 22 19:10 manual
drwxr-xr-x  2 root root 4096 Dec 22 19:35 modules
[root@localhost httpd]# cd htdocs/
[root@localhost htdocs]# ll
total 4
-rw-r--r-- 1 504 games 45 Jun 12  2007 index.html
[root@localhost htdocs]# cat index.html
<html><body><h1>It works!</h1></body></html>
[root@localhost htdocs]#

Some screenshots of the installation process are as follows:



4, Summary and feedback

The above is the main operation steps for compiling and installing Apache. It should be noted that before installing Apache, the corresponding dependent packages need to be installed, otherwise errors will be reported during the installation process and further troubleshooting is required.

In the process of installing the corresponding dependent packages, some errors will also occur, and the corresponding components also need to be installed. You can copy and paste the error information to the Internet, search and view the corresponding solutions.

Here are some information about errors reported during installation for your reference.

Error message 1

# Error message
[root@centos apr-1.7.0]# ./configure --prefix=/usr/local/apr/apr/
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
Configuring APR library
Platform: x86_64-pc-linux-gnu
checking for working mkdir -p... yes
APR Version: 1.7.0
checking for chosen layout... apr
checking for gcc... no
checking for cc... no
checking for cl.exe... no
configure: error: in `/root/apache/apr-1.7.0':
configure: error: no acceptable C compiler found in $PATH
See `config.log' for more details
[root@centos apr-1.7.0]#

[root@centos apr-1.7.0]# yum -y install gcc
 Reference link: https://blog.csdn.net/weixin_33858249/article/details/91574176

Error message 2

# Error message 2
[root@centos apr-util-1.6.1]# make
make[1]: Entering directory `/root/apache/apr-util-1.6.1'
/bin/sh /usr/local/apr/apr//build-1/libtool --silent --mode=compile gcc -g -O2 -pthread   -DHAVE_CONFIG_H  -DLINUX -D_REENTRANT -D_GNU_SOURCE   -I/root/apache/apr-util-1.6.1/include -I/root/apache/apr-util-1.6.1/include/private  -I/usr/local/apr/apr//include/apr-1    -o xml/apr_xml.lo -c xml/apr_xml.c && touch xml/apr_xml.lo
xml/apr_xml.c:35:19: fatal error: expat.h: No such file or directory
 #include <expat.h>
                   ^
compilation terminated.
make[1]: *** [xml/apr_xml.lo] Error 1
make[1]: Leaving directory `/root/apache/apr-util-1.6.1'
make: *** [all-recursive] Error 1

# terms of settlement
[root@centos apr-util-1.6.1]# yum install -y expat-devel
 Reference link: https://blog.csdn.net/weixin_43930641/article/details/105269092

Error message 3

checking for windows.h... no
configure: error: Invalid C++ compiler or C++ compiler flags

# yum install -y gcc-c++
Reference link: https://blog.csdn.net/weixin_43930641/article/details/105313937

Error message 3

checking for windows.h... no
configure: error: Invalid C++ compiler or C++ compiler flags

# yum install -y gcc-c++
Reference link: https://blog.csdn.net/weixin_43930641/article/details/105313937

Keywords: Apache CentOS Alibaba Cloud

Added by neoson on Thu, 23 Dec 2021 06:56:36 +0200