How to install Apache from source code on Ubuntu 17.04
To install Apache from source code on Ubuntu 17.04
Apache is a web server used to server web page content over HTTP and HTTPS protocol. For the easy installation of Apache web server, we normally use yum install command to install Apache in the system. In this tutorial, we will install Apache by compiling from its source code on Ubuntu 17.04.
Installing Apache
First, you need to download the Apache package by making use of the wget command in the following manner.
root@linuxhelp:~# wget http://redrockdigimark.com/apachemirror//httpd/httpd-2.2.34.tar.bz2
--2017-11-17 15:30:41-- http://redrockdigimark.com/apachemirror//httpd/httpd-2.2.34.tar.bz2
Resolving redrockdigimark.com (redrockdigimark.com)... 119.18.61.94
Connecting to redrockdigimark.com (redrockdigimark.com)|119.18.61.94|:80... connected.
HTTP request sent, awaiting response...
200 OK
Length: 5779739 (5.5M) [application/x-tar]
Saving to: ‘ httpd-2.2.34.tar.bz2’
httpd-2.2.34.tar.bz 100%[===================> ] 5.51M --.-KB/s in 0.1s
2017-11-17 15:30:58 (45.6 MB/s) - ‘ httpd-2.2.34.tar.bz2’ saved [5779739/5779739]
Next, extract the downloaded tar file.
root@linuxhelp:~# tar -xf httpd-2.2.34.tar.bz2
Then create a directory in which you want to install your Apache Web Server.
root@linuxhelp:~# cd /usr/local/
Create an Apache directory.
root@linuxhelp:/usr/local# mkdir apache
Now, Move inside the directory .
root@linuxhelp:~# cd httpd-2.2.34
Make sure your configure script has the location as its prefix.
root@linuxhelp:~/httpd-2.2.34# ./configure --prefix=/usr/local/apache --enable-shared=max
checking for chosen layout... Apache
checking for working mkdir -p... yes
checking build system type... x86_64-unknown-linux-gnu
checking host system type... x86_64-unknown-linux-gnu
checking target system type... x86_64-unknown-linux-gnu
checking for APR... reconfig
configuring package in srclib/apr now
checking build system type... x86_64-unknown-linux-gnu
.
.
.
.
config.status: creating support/split-logfile
config.status: creating build/rules.mk
config.status: creating build/pkg/pkginfo
config.status: creating build/config_vars.sh
config.status: creating include/ap_config_auto.h
config.status: executing default commands
Once it is done, you make sure you run the make and make install commands which kickstart and completes the installation of all the required apache packages in your directory.
root@linuxhelp:~/httpd-2.2.34# make
Making all in srclib
make[1]: Entering directory ' /root/httpd-2.2.34/srclib'
Making all in apr
make[2]: Entering directory ' /root/httpd-2.2.34/srclib/apr'
make[3]: Entering directory ' /root/httpd-2.2.34/srclib/apr'
/root/httpd-2.2.34/srclib/apr/build/mkdir.sh tools
/bin/bash /root/httpd-2.2.34/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.2.34/srclib/apr/include/arch/unix -I./include/arch/unix -I/root/httpd-2.2.34/srclib/apr/include/arch/unix -I/root/httpd-2.2.34/srclib/apr/include -I/root/httpd-2.2.34/srclib/apr/include/private -I/root/httpd-2.2.34/srclib/apr/include/private -o tools/gen_test_char.lo -c tools/gen_test_char.c & & touch tools/gen_test_char.lo
.
.
.
generators/libmod_status.la modules/generators/libmod_autoindex.la modules/generators/libmod_asis.la modules/generators/libmod_cgi.la modules/mappers/libmod_negotiation.la modules/mappers/libmod_dir.la modules/mappers/libmod_actions.la modules/mappers/libmod_userdir.la modules/mappers/libmod_alias.la modules/mappers/libmod_so.la server/mpm/prefork/libprefork.la os/unix/libos.la -lm /root/httpd-2.2.34/srclib/pcre/libpcre.la /root/httpd-2.2.34/srclib/apr-util/libaprutil-1.la /root/httpd-2.2.34/srclib/apr-util/xml/expat/libexpat.la /root/httpd-2.2.34/srclib/apr/libapr-1.la -lrt -lcrypt -lpthread -ldl
make[1]: Leaving directory ' /root/httpd-2.2.34'
root@linuxhelp:~/httpd-2.2.34# make install
Making install in srclib
make[1]: Entering directory ' /root/httpd-2.2.34/srclib'
Making install in apr
make[2]: Entering directory ' /root/httpd-2.2.34/srclib/apr'
make[3]: Entering directory ' /root/httpd-2.2.34/srclib/apr'
make[3]: Nothing to be done for ' local-all' .
make[3]: Leaving directory ' /root/httpd-2.2.34/srclib/apr'
/root/httpd-2.2.34/srclib/apr/build/mkdir.sh /usr/local/apache/lib /usr/local/apache/bin /usr/local/apache/build
/usr/local/apache/lib/pkgconfig /usr/local/apache/include
.
.
.
mkdir /usr/local/apache/cgi-bin
Installing header files
Installing build system files
Installing man pages and online manual
mkdir /usr/local/apache/man
mkdir /usr/local/apache/man/man1
mkdir /usr/local/apache/man/man8
mkdir /usr/local/apache/manual
make[1]: Leaving directory ' /root/httpd-2.2.34'
Now, go to the installed directory and list all the files.
root@linuxhelp:~/httpd-2.2.34# cd /usr/local/apache/
root@linuxhelp:/usr/local/apache# ls -l
total 60
drwxr-xr-x 2 root root 4096 Nov 17 15:43 bin
drwxr-xr-x 2 root root 4096 Nov 17 15:43 build
drwxr-xr-x 2 root root 4096 Nov 17 15:43 cgi-bin
drwxr-xr-x 4 root root 4096 Nov 17 15:43 conf
drwxr-xr-x 3 root root 4096 Nov 17 15:43 error
drwxr-xr-x 2 root root 4096 Jul 7 00:49 htdocs
drwxr-xr-x 3 root root 4096 Nov 17 15:43 icons
drwxr-xr-x 2 root root 4096 Nov 17 15:43 include
drwxr-xr-x 3 root root 4096 Nov 17 15:43 lib
drwxr-xr-x 2 root root 4096 Nov 17 15:43 logs
drwxr-xr-x 4 root root 4096 Nov 17 15:43 man
drwxr-xr-x 14 root root 12288 Jul 7 00:50 manual
drwxr-xr-x 2 root root 4096 Nov 17 15:43 modules
And view the configuration file by making use of the following commands.
root@linuxhelp:/usr/local/apache# vim conf/httpd.conf
root@linuxhelp:/usr/local/apache# /usr/local/apache/bin/apachectl start
Copy the service script towards /etc/init.d/ location. Make use of the following commands for the same purpose.
root@linuxhelp:/usr/local/apache# cp /usr/local/apache/bin/apachectl /etc/init.d/apachectl
root@linuxhelp:/usr/local/apache# chmod +x /etc/init.d/apachectl
Add the /etc/init.d/apachectl in /usr/sbin/update rc.d with the help of the following commands.
root@linuxhelp:/usr/local/apache# /usr/sbin/update-rc.d -f apachectl defaults
root@linuxhelp:/usr/local/apache# adduser --system apache
Adding system user `apache' (UID 123) ...
Adding new user `apache' (UID 123) with group `nogroup' ...
Creating home directory `/home/apache' ...
Make sure you also do the daemon configuration.
root@linuxhelp:/usr/local/apache# cd /etc/systemd/system
root@linuxhelp:/etc/systemd/system# nano apache2.service
[Unit]
Description=The Apache Webserver
After=network.target nss-lookup.target time-sync.target remote-fs.target
Before=getty@tty1.service plymouth-quit.service xdm.service
PartOf=apache2.target
[Service]
Type=notify
PrivateTmp=true
ExecStart=/usr/local/apache/bin/apachectl start
ExecReload=/usr/local/apache/bin/apachectl reload
ExecStop=/usr/local/apache/bin/apachectl stop
KillMode=mixed
TasksMax=infinity
NotifyAccess=all
[Install]
WantedBy=multi-user.target
Alias=httpd.service apache.service
Reload the daemon now.
root@linuxhelp:/etc/systemd/system# systemctl daemon-reload
After that, start and enable the service.
root@linuxhelp:/etc/systemd/system# systemctl start apache2.service
root@linuxhelp:/etc/systemd/system# systemctl enable apache2.service
Created symlink /etc/systemd/system/httpd.service &rarr /etc/systemd/system/apache2.service.
Created symlink /etc/systemd/system/apache.service &rarr /etc/systemd/system/apache2.service.
Created symlink /etc/systemd/system/multi-user.target.wants/apache2.service &rarr /etc/systemd/system/apache2.service.
Now, you need to Switch to your browser and type yourIP. It works.
With this, the method to install Apache from its source on Ubuntu 16.04 comes to an end.
Comments ( 0 )
No comments available