How to Install Apache from Source Code on CentOS 7.6
- 00:52 yum groupinstall "Development Tools" -y
- 01:09 yum install expat-devel pcre pcre-devel openssl-devel -y
- 01:24 wget https://github.com/apache/httpd/archive/2.4.39.tar.gz
- 01:36 wget https://github.com/apache/apr/archive/1.7.0.tar.gz
- 01:47 wget https://github.com/apache/apr-util/archive/1.6.1.tar.gz
- 02:41 mv /root/apr-1.7.0 ./apr
- 02:48 mv /root/apr-util-1.6.1 ./apr-util
- 03:20 ./buildconf
- 03:35 ./configure --enable-ssl --enable-so --with-mpm=event --with-included-apr --prefix=/opt
- 03:40 make
- 03:50 make install
- 04:07 vim /etc/profile.d/httpd.sh
- 04:34 vim /etc/systemd/system/httpd.service
- 04:52 systemctl daemon-reload
- 04:55 systemctl enable httpd
- 04:59 systemctl start httpd
- 05:04 systemctl status httpd
Installation of Apache from Source Code on CentOS 7.6
Installation procedure:
First, install the development tools by executing the following command
[root@linuxhelp ~]# yum groupinstall "Development Tools" -y
Loaded plugins: fastestmirror, langpacks
There is no installed groups file.
Maybe run: yum groups mark convert (see man yum)
Loading mirror speeds from cached hostfile
* base: mirror.xeonbd.com
* epel: repos.del.extreme-ix.org
* extras: mirror.xeonbd.com
* remi-php72: mirror.reconn.ru
* remi-safe: mirror.reconn.ru
* updates: mirror.xeonbd.com
Resolving Dependencies
--> Running transaction check
---> Package autoconf.noarch 0:2.69-11.el7 will be installed
---> Package automake.noarch 0:1.13.4-3.el7 will be installed
--> Processing Dependency: perl(Thread::Queue) for package: automake-1.13.4-3.el7.noarch
.
.
.
.
.
Installed:
autoconf.noarch 0:2.69-11.el7 automake.noarch 0:1.13.4-3.el7 bison.x86_64 0:3.0.4-2.el7 byacc.x86_64 0:1.9.20130304-3.el7 cscope.x86_64 0:15.8-10.el7
ctags.x86_64 0:5.8-13.el7 diffstat.x86_64 0:1.57-4.el7 doxygen.x86_64 1:1.8.5-3.el7 flex.x86_64 0:2.5.37-6.el7 gcc.x86_64 0:4.8.5-36.el7_6.2
gcc-c++.x86_64 0:4.8.5-36.el7_6.2 gcc-gfortran.x86_64 0:4.8.5-36.el7_6.2 git.x86_64 0:1.8.3.1-20.el7 indent.x86_64 0:2.2.11-13.el7 intltool.noarch 0:0.50.2-7.el7
libtool.x86_64 0:2.4.2-22.el7_3 patchutils.x86_64 0:0.3.3-4.el7 rcs.x86_64 0:5.9.0-5.el7 redhat-rpm-config.noarch 0:9.1.0-87.el7.centos rpm-build.x86_64 0:4.11.3-35.el7
rpm-sign.x86_64 0:4.11.3-35.el7 subversion.x86_64 0:1.7.14-14.el7 swig.x86_64 0:2.0.10-5.el7 systemtap.x86_64 0:3.3-3.el7
Dependency Installed:
cpp.x86_64 0:4.8.5-36.el7_6.2 dwz.x86_64 0:0.11-3.el7 gettext-common-devel.noarch 0:0.19.8.1-2.el7 gettext-devel.x86_64 0:0.19.8.1-2.el7
kernel-debug-devel.x86_64 0:3.10.0-957.12.1.el7 libgfortran.x86_64 0:4.8.5-36.el7_6.2 libquadmath.x86_64 0:4.8.5-36.el7_6.2 libquadmath-devel.x86_64 0:4.8.5-36.el7_6.2
libstdc++-devel.x86_64 0:4.8.5-36.el7_6.2 perl-Error.noarch 1:0.17020-2.el7 perl-Git.noarch 0:1.8.3.1-20.el7 perl-TermReadKey.x86_64 0:2.30-20.el7
perl-Thread-Queue.noarch 0:3.02-2.el7 perl-XML-Parser.x86_64 0:2.41-10.el7 perl-srpm-macros.noarch 0:1-8.el7 subversion-libs.x86_64 0:1.7.14-14.el7
systemtap-client.x86_64 0:3.3-3.el7 systemtap-devel.x86_64 0:3.3-3.el7
Dependency Updated:
libgcc.x86_64 0:4.8.5-36.el7_6.2 libgomp.x86_64 0:4.8.5-36.el7_6.2 libstdc++.x86_64 0:4.8.5-36.el7_6.2
Complete!
And then, install apr apr-util, pcre pcre-devel packages which are required packages for the installation.
[root@linuxhelp ~]# yum install expat-devel pcre pcre-devel openssl-devel -y
Loaded plugins: fastestmirror, langpacks
Loading mirror speeds from cached hostfile
* base: mirror.xeonbd.com
* epel: repos.del.extreme-ix.org
* extras: mirror.xeonbd.com
* remi-php72: mirror.reconn.ru
* remi-safe: mirror.reconn.ru
* updates: mirror.xeonbd.com
.
.
.
.
.
Installed:
expat-devel.x86_64 0:2.1.0-10.el7_3 openssl-devel.x86_64 1:1.0.2k-16.el7_6.1 pcre-devel.x86_64 0:8.32-17.el7
Dependency Installed:
keyutils-libs-devel.x86_64 0:1.5.8-3.el7 krb5-devel.x86_64 0:1.15.1-37.el7_6 libcom_err-devel.x86_64 0:1.42.9-13.el7 libselinux-devel.x86_64 0:2.5-14.1.el7 libsepol-devel.x86_64 0:2.5-10.el7
libverto-devel.x86_64 0:0.2.5-4.el7 zlib-devel.x86_64 0:1.2.7-18.el7
Dependency Updated:
openssl.x86_64 1:1.0.2k-16.el7_6.1 openssl-libs.x86_64 1:1.0.2k-16.el7_6.1
Complete!
Download the source code of Apache using the below-given link.
[root@linuxhelp ~]# wget https://github.com/apache/httpd/archive/2.4.39.tar.gz
--2019-05-09 07:52:07-- https://github.com/apache/httpd/archive/2.4.39.tar.gz
Resolving github.com (github.com)... 192.30.253.112
Connecting to github.com (github.com)|192.30.253.112|:443... connected.
HTTP request sent, awaiting response... 302 Found
Location: https://codeload.github.com/apache/httpd/tar.gz/2.4.39 [following]
--2019-05-09 07:52:08-- https://codeload.github.com/apache/httpd/tar.gz/2.4.39
Resolving codeload.github.com (codeload.github.com)... 192.30.253.120
Connecting to codeload.github.com (codeload.github.com)|192.30.253.120|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: unspecified [application/x-gzip]
Saving to: ‘2.4.39.tar.gz’
[ <=> ] 11,829,840 222KB/s in 69s
2019-05-09 07:53:18 (168 KB/s) - ‘2.4.39.tar.gz’ saved [11829840]
Download the apr and apr-util package using the below-given links.
[root@linuxhelp ~]# wget https://github.com/apache/apr/archive/1.7.0.tar.gz
[root@linuxhelp ~]# wget https://github.com/apache/apr-util/archive/1.6.1.tar.gz
List the contents to check the downloaded tar files of apache apr and apr-util.
[root@linuxhelp ~]# ll
total 12744
-rw-r--r-- 1 root root 432752 May 9 07:58 1.6.1.tar.gz
-rw-r--r-- 1 root root 751416 May 9 07:58 1.7.0.tar.gz
-rw-r--r-- 1 root root 11829840 May 9 07:53 2.4.39.tar.gz
Extract the tar file of Apache
[root@linuxhelp ~]# tar xvzf 2.4.39.tar.gz
httpd-2.4.39/
httpd-2.4.39/.gdbinit
httpd-2.4.39/ABOUT_APACHE
httpd-2.4.39/Apache-apr2.dsw
httpd-2.4.39/Apache.dsw
httpd-2.4.39/BuildAll.dsp
httpd-2.4.39/BuildBin.dsp
httpd-2.4.39/CHANGES
httpd-2.4.39/CMakeLists.txt
httpd-2.4.39/INSTALL
httpd-2.4.39/InstallBin.dsp
httpd-2.4.39/LAYOUT
httpd-2.4.39/LICENSE
httpd-2.4.39/Makefile.in
httpd-2.4.39/Makefile.win
.
.
.
.
httpd-2.4.39/test/tcpdumpscii.txt
httpd-2.4.39/test/test-writev.c
httpd-2.4.39/test/test_find.c
httpd-2.4.39/test/test_limits.c
httpd-2.4.39/test/test_parser.c
httpd-2.4.39/test/test_select.c
httpd-2.4.39/test/time-sem.c
Extract the tar file of apr as follows
[root@linuxhelp ~]# tar xvzf 1.6.1.tar.gz
apr-util-1.6.1/
apr-util-1.6.1/CHANGES
apr-util-1.6.1/CMakeLists.txt
apr-util-1.6.1/LICENSE
apr-util-1.6.1/Makefile.in
apr-util-1.6.1/Makefile.win
apr-util-1.6.1/NOTICE
apr-util-1.6.1/NWGNUmakefile
apr-util-1.6.1/README
apr-util-1.6.1/README.FREETDS
apr-util-1.6.1/README.cmake
apr-util-1.6.1/STATUS
.
.
.
.
.
apr-util-1.6.1/xlate/
apr-util-1.6.1/xlate/xlate.c
apr-util-1.6.1/xml/
apr-util-1.6.1/xml/NWGNUmakefile
apr-util-1.6.1/xml/apr_xml.c
Extract the tar file of apr-util file
[root@linuxhelp ~]# tar xvzf 1.7.0.tar.gz
apr-1.7.0/
apr-1.7.0/CHANGES
apr-1.7.0/CMakeLists.txt
apr-1.7.0/LICENSE
apr-1.7.0/Makefile.in
apr-1.7.0/Makefile.win
apr-1.7.0/NOTICE
apr-1.7.0/NWGNUmakefile
apr-1.7.0/README
.
.
.
.
apr-1.7.0/user/unix/groupinfo.c
apr-1.7.0/user/unix/userinfo.c
apr-1.7.0/user/win32/
apr-1.7.0/user/win32/groupinfo.c
apr-1.7.0/user/win32/userinfo.c
And then change the directory to Apache
[root@linuxhelp ~]# cd httpd-2.4.39/
List the contents of apache directory that has created after extraction of apache from the source code.
[root@linuxhelp httpd-2.4.39]# ll
total 992
-rw-rw-r-- 1 root root 13496 Mar 27 20:35 ABOUT_APACHE
-rw-rw-r-- 1 root root 24803 Mar 27 20:35 acinclude.m4
-rw-rw-r-- 1 root root 66792 Mar 27 20:35 Apache-apr2.dsw
-rw-rw-r-- 1 root root 81919 Mar 27 20:35 Apache.dsw
-rw-rw-r-- 1 root root 9907 Mar 27 20:35 apache_probes.d
-rw-rw-r-- 1 root root 2512 Mar 27 20:35 ap.d
drwxrwxr-x 6 root root 4096 Mar 27 20:35 build
-rw-rw-r-- 1 root root 2644 Mar 27 20:35 BuildAll.dsp
-rw-rw-r-- 1 root root 2784 Mar 27 20:35 BuildBin.dsp
-rwxrwxr-x 1 root root 10679 Mar 27 20:35 buildconf
-rw-rw-r-- 1 root root 270249 Mar 27 20:35 CHANGES
-rw-rw-r-- 1 root root 45405 Mar 27 20:35 CMakeLists.txt
-rw-rw-r-- 1 root root 13381 Mar 27 20:35 config.layout
-rw-rw-r-- 1 root root 30549 Mar 27 20:35 configure.in
drwxrwxr-x 10 root root 145 Mar 27 20:35 docs
-rw-rw-r-- 1 root root 403 Mar 27 20:35 emacs-style
-rw-rw-r-- 1 root root 2218 Mar 27 20:35 httpd.dep
-rw-rw-r-- 1 root root 4124 Mar 27 20:35 httpd.dsp
-rw-rw-r-- 1 root root 8994 Mar 27 20:35 httpd.mak
drwxrwxr-x 2 root root 4096 Mar 27 20:35 include
-rw-rw-r-- 1 root root 3782 Mar 27 20:35 INSTALL
-rw-rw-r-- 1 root root 2909 Mar 27 20:35 InstallBin.dsp
-rw-rw-r-- 1 root root 4097 Mar 27 20:35 LAYOUT
-rw-rw-r-- 1 root root 79070 Mar 27 20:35 libhttpd.dep
-rw-rw-r-- 1 root root 21528 Mar 27 20:35 libhttpd.dsp
-rw-rw-r-- 1 root root 38913 Mar 27 20:35 libhttpd.mak
-rw-rw-r-- 1 root root 25478 Mar 27 20:35 LICENSE
-rw-rw-r-- 1 root root 11166 Mar 27 20:35 Makefile.in
-rw-rw-r-- 1 root root 53749 Mar 27 20:35 Makefile.win
drwxrwxr-x 28 root root 4096 Mar 27 20:35 modules
-rw-rw-r-- 1 root root 720 Mar 27 20:35 NOTICE
-rw-rw-r-- 1 root root 13884 Mar 27 20:35 NWGNUmakefile
drwxrwxr-x 7 root root 126 Mar 27 20:35 os
-rw-rw-r-- 1 root root 4642 Mar 27 20:35 README
-rw-rw-r-- 1 root root 13317 Mar 27 20:35 README.cmake
-rw-rw-r-- 1 root root 4418 Mar 27 20:35 README.platforms
-rw-rw-r-- 1 root root 10137 Mar 27 20:35 ROADMAP
drwxrwxr-x 3 root root 4096 Mar 27 20:35 server
drwxrwxr-x 2 root root 25 Mar 27 20:35 srclib
-rw-rw-r-- 1 root root 26611 Mar 27 20:35 STATUS
drwxrwxr-x 4 root root 4096 Mar 27 20:35 support
drwxrwxr-x 2 root root 255 Mar 27 20:35 test
-rw-rw-r-- 1 root root 8136 Mar 27 20:35 VERSIONING
Change the directory to sourcelib
[root@linuxhelp httpd-2.4.39]# cd srclib/
Move And rename the apr and apr-util directory that has created after the extraction of tar file under the srclib directory.
[root@linuxhelp srclib]# mv /root/apr-1.7.0 ./apr
[root@linuxhelp srclib]# mv /root/apr-util-1.6.1 ./apr-util
Change the directory to apache.
[root@linuxhelp ~]# cd httpd-2.4.39/
Run the buildconf to build the scripts that are essential for the compilation of Apache from source code
[root@linuxhelp httpd-2.4.39]# ./buildconf
found apr source: srclib/apr
found apr-util source: srclib/apr-util
rebuilding srclib/apr/configure
buildconf: checking installation...
buildconf: python version 2.7.5 (ok)
buildconf: autoconf version 2.69 (ok)
buildconf: libtool version 2.4.2 (ok)
.
.
.
.
copying build files
rebuilding include/ap_config_auto.h.in
rebuilding configure
rebuilding rpm spec file
fixing timestamps for ap_expr sources
Run the configuration command with the follwing extensions enabled and enter the location where it has to download in the prefix area.
[root@linuxhelp httpd-2.4.39]# ./configure --enable-ssl --enable-so --with-mpm=event --with-included-apr --prefix=/opt
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:
configuring package in srclib/apr now
.
.
.
.
Server Version: 2.4.39
Install prefix: /opt
C compiler: gcc -std=gnu99
CFLAGS: -g -O2 -pthread
CPPFLAGS: -DLINUX -D_REENTRANT -D_GNU_SOURCE
LDFLAGS:
LIBS:
C preprocessor: gcc –E
Run the make command to build the software that was set in the makefile
[root@linuxhelp httpd-2.4.39]# make
Making all in srclib
make[1]: Entering directory `/root/httpd-2.4.39/srclib'
Making all in apr
make[2]: Entering directory `/root/httpd-2.4.39/srclib/apr'
make[3]: Entering directory `/root/httpd-2.4.39/srclib/apr'
/bin/sh /root/httpd-2.4.39/srclib/apr/libtool --silent --mode=compile gcc -g -O2 -pthread -DHAVE_CONFIG_H -DLINUX -D_REENTRANT -D_GNU_SOURCE -I./include -I/root/httpd-2.4.39/srclib/apr/include/arch/unix -I./include/arch/unix -I/root/httpd-2.4.39/srclib/apr/include/arch/unix -I/root/httpd-2.4.39/srclib/apr/include -I/root/httpd-2.4.39/srclib/apr/include/private -I/root/httpd-2.4.39/srclib/apr/include/private -o encoding/apr_encode.lo -c encoding/apr_encode.c && touch encoding/apr_encode.lo
/root/httpd-2.4.39/srclib/apr/build/mkdir.sh tools
.
.
.
.
.
make[4]: Leaving directory `/root/httpd-2.4.39/modules/mappers'
make[3]: Leaving directory `/root/httpd-2.4.39/modules/mappers'
make[2]: Leaving directory `/root/httpd-2.4.39/modules'
make[2]: Entering directory `/root/httpd-2.4.39/support'
make[2]: Leaving directory `/root/httpd-2.4.39/support'
make[1]: Leaving directory `/root/httpd-2.4.39'
And then, run the make install to install the built software or programs.
[root@linuxhelp httpd-2.4.39]# make install
Making install in srclib
make[1]: Entering directory `/root/httpd-2.4.39/srclib'
Making install in apr
make[2]: Entering directory `/root/httpd-2.4.39/srclib/apr'
make[3]: Entering directory `/root/httpd-2.4.39/srclib/apr'
make[3]: Nothing to be done for `local-all'.
make[3]: Leaving directory `/root/httpd-2.4.39/srclib/apr'
/root/httpd-2.4.39/srclib/apr/build/mkdir.sh /opt/lib /opt/bin /opt/build \
/opt/lib/pkgconfig /opt/include
/usr/bin/install -c -m 644 /root/httpd-2.4.39/srclib/apr/include/apr.h /opt/include
for f in /root/httpd-2.4.39/srclib/apr/include/apr_*.h; do \
/usr/bin/install -c -m 644 ${f} /opt/include; \
done.
.
.
.
.
.
.
Installing configuration files
mkdir /opt/conf
mkdir /opt/conf/extra
mkdir /opt/conf/original
mkdir /opt/conf/original/extra
Installing HTML documents
mkdir /opt/htdocs
Installing error documents
mkdir /opt/error
Installing icons
.
.
.
mkdir /opt/man
mkdir /opt/man/man1
mkdir /opt/man/man8
mkdir /opt/manual
make[1]: Leaving directory `/root/httpd-2.4.39'
Once it is completed, you shall check the version of Apache.
[root@linuxhelp httpd-2.4.39]# httpd -v
bash: httpd: command not found...
After then create a script file to add a directories into the path as follows.
[root@linuxhelp httpd-2.4.39]# vim /etc/profile.d/httpd.sh
pathmunge /opt/bin
Logout from the terminal to reload the profile and then check the version of apache.
[root@linuxhelp ~]# httpd -v
Server version: Apache/2.4.39 (Unix)
Server built: May 9 2019 08:27:04
Manage the httpd service using the below given link.
[root@linuxhelp ~]# vim /etc/systemd/system/httpd.service
[Unit]
Description=The Apache HTTP Server
After=network.target
[Service]
Type=forking
ExecStart=/opt/bin/apachectl -k start
ExecReload=/opt/bin/apachectl -k graceful
ExecStop=/opt/bin/apachectl -k graceful-stop
PIDFile=/opt/logs/httpd.pid
PrivateTmp=true
[Install]
WantedBy=multi-user.target
And then reload the daemon.
[root@linuxhelp ~]# systemctl daemon-reload
Enable the Apache service
[root@linuxhelp ~]# systemctl enable httpd
Created symlink from /etc/systemd/system/multi-user.target.wants/httpd.service to /etc/systemd/system/httpd.service.
Trigger the Apache service by running the following.
[root@linuxhelp ~]# systemctl start httpd
Check the status of Apache.
[root@linuxhelp ~]# systemctl status httpd
● httpd.service - The Apache HTTP Server
Loaded: loaded (/etc/systemd/system/httpd.service; enabled; vendor preset: disabled)
Active: active (running) since Thu 2019-05-09 09:00:29 IST; 5s ago
Process: 18172 ExecStart=/opt/bin/apachectl -k start (code=exited, status=0/SUCCESS)
Open the browser and enter localhost in the URL With this, the installation of Apache from source code has been successfully compiled.
Comments ( 0 )
No comments available