How To Install Apache from source on freeBSD 11.1
To Install Apache from Source on FreeBSD 11.1
Apache is a web server used to serve web page content over HTTP and HTTPS protocol. In this tutorial, we will install Apache by compiling from its source code. For compiling Apache from its source it will require for APR and APR-UTIL, which means Apache Portable Runtime (APR)
Installation
First, we need to Install few dependencies for the installation.
root@linuxhelp11:~ # pkg install pcre libiconv libtool python pcre openssl-devel
Updating FreeBSD repository catalogue...
Fetching meta.txz: 100% 944 B 0.9kB/s 00:01
Fetching packagesite.txz: 100% 6 MiB 6.4MB/s 00:01
Processing entries: 100%
FreeBSD repository update completed. 31146 packages processed.
All repositories are up to date.
The following 5 package(s) will be affected (of 0 checked):
New packages to be INSTALLED:
libtool: 2.4.6
python: 2.7_3,2
openssl-devel: 1.1.0h_1
m4: 1.4.18,1
python2: 2_3
.
.
.
[4/5] Installing python-2.7_3,2...
[4/5] Extracting python-2.7_3,2: 100%
[5/5] Installing openssl-devel-1.1.0h_1...
[5/5] Extracting openssl-devel-1.1.0h_1: 100%
Next, download the apache source code and apr and apr-util, using the following commands.
root@linuxhelp11:~ # wget http://www-us.apache.org/dist//httpd/httpd-2.4.33.tar.gz --2018-04-22 06:18:47-- http://www-us.apache.org/dist//httpd/httpd-2.4.33.tar.gz Resolving www-us.apache.org (www-us.apache.org)... 140.211.11.105 Connecting to www-us.apache.org (www-us.apache.org)|140.211.11.105|:80... connected. HTTP request sent, awaiting response... 200 OK Length: 9076901 (8.7M) [application/x-gzip] Saving to: ' httpd-2.4.33.tar.gz' httpd-2.4.33.tar.gz 100%[=====================================================> ] 8.66M 24.0MB/s in 0.4s 2018-04-22 06:19:07 (24.0 MB/s) - ' httpd-2.4.33.tar.gz' saved [9076901/9076901] root@linuxhelp11:~ # wget https://github.com/apache/apr/archive/1.6.2.tar.gz -O apr-1.6.2.tar.gz --2018-04-22 06:20:40-- https://github.com/apache/apr/archive/1.6.2.tar.gz Resolving github.com (github.com)... 192.30.253.112, 192.30.253.113 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/apr/tar.gz/1.6.2 [following] --2018-04-22 06:20:45-- https://codeload.github.com/apache/apr/tar.gz/1.6.2 Resolving codeload.github.com (codeload.github.com)... 192.30.253.120, 192.30.253.121 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: ' apr-1.6.2.tar.gz' apr-1.6.2.tar.gz [ < => ] 713.68K 276KB/s in 2.6s 2018-04-22 06:20:49 (276 KB/s) - ' apr-1.6.2.tar.gz' saved [730808] root@linuxhelp11:~ # wget https://github.com/apache/apr-util/archive/1.6.0.tar.gz -O apr-util-1.6.0.tar.gz --2018-04-22 06:20:50-- https://github.com/apache/apr-util/archive/1.6.0.tar.gz Resolving github.com (github.com)... 192.30.253.113, 192.30.253.112 Connecting to github.com (github.com)|192.30.253.113|:443... connected. HTTP request sent, awaiting response... 302 Found Location: https://codeload.github.com/apache/apr-util/tar.gz/1.6.0 [following] --2018-04-22 06:20:52-- https://codeload.github.com/apache/apr-util/tar.gz/1.6.0 Resolving codeload.github.com (codeload.github.com)... 192.30.253.120, 192.30.253.121 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: ' apr-util-1.6.0.tar.gz' apr-util-1.6.0.tar.gz [ < => ] 424.25K 229KB/s in 1.8s 2018-04-22 06:20:55 (229 KB/s) - ' apr-util-1.6.0.tar.gz' saved [434431]
Now, extract downloaded files.
root@linuxhelp11:~ # tar -xf httpd-2.4.33.tar.gz
root@linuxhelp11:~ # tar -xf apr-1.6.2.tar.gz
root@linuxhelp11:~ # tar -xf apr-util-1.6.0.tar.gz
Move the apr and apr-util to httpd-2.4.33/srclib/ location.
root@linuxhelp11:~ # mv apr-1.6.2 httpd-2.4.33/srclib/apr
root@linuxhelp11:~ # mv apr-util-1.6.0 httpd-2.4.33/srclib/apr-util
And then enter into httpd directory.
root@linuxhelp11:~ # cd httpd-2.4.33
To build configuration script, execute the following buildconf script file as follows.
root@linuxhelp11:~/httpd-2.4.33 # ./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.14 (ok)
buildconf: autoconf version 2.69 (ok)
buildconf: libtool version 2.4.6 (ok)
buildconf: copying libtool helper files using /usr/local/bin/libtoolize
buildconf: creating include/arch/unix/apr_private.h.in ...
buildconf: creating configure ...
buildconf: generating ' make' outputs ...
buildconf: rebuilding rpm spec file
rebuilding srclib/apr-util/configure
Looking for apr source in /root/httpd-2.4.33/srclib/apr
Creating include/private/apu_config.h ...
Creating configure ...
Generating ' make' outputs ...
rebuilding rpm spec file
copying build files
rebuilding include/ap_config_auto.h.in
rebuilding configure
rebuilding rpm spec file
fixing timestamps for ap_expr sources
Configure apache using the following command. You can change the default Apache installation directory path, here I have mentioned /usr/apache directory path.
root@linuxhelp11:~/httpd-2.4.33 # ./configure --enable-ssl --enable-so --with-mpm=event --with-included-apr-liconv --prefix=/usr/apache
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-unknown-freebsd11.1
checking host system type... x86_64-unknown-freebsd11.1
checking target system type... x86_64-unknown-freebsd11.1
configure:
configure: Configuring Apache Portable Runtime library...
configure:
checking for APR... reconfig
configuring package in srclib/apr now
checking build system type... x86_64-unknown-freebsd11.1
checking host system type... x86_64-unknown-freebsd11.1
.
.
.
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
configure: summary of build options:
Server Version: 2.4.33
Install prefix: /usr/apache
C compiler: cc
CFLAGS: -g -O2
CPPFLAGS:
LDFLAGS: -L/usr/local/lib
LIBS:
C preprocessor: cc &ndash E
Compile the configured file using the following command
root@linuxhelp11:~/httpd-2.4.33 # make
Making all in srclib
Making all in apr
/root/httpd-2.4.33/srclib/apr/build/mkdir.sh tools
/bin/sh /root/httpd-2.4.33/srclib/apr/libtool --silent --mode=compile cc -g -O2 -DHAVE_CONFIG_H -I./include -I/root/httpd-2.4.33/srclib/apr/include/arch/unix -I./include/arch/unix -I/root/httpd-2.4.33/srclib/apr/include/arch/unix -I/root/httpd-2.4.33/srclib/apr/include -I/root/httpd-2.4.33/srclib/apr/include/private -I/root/httpd-2.4.33/srclib/apr/include/private -o tools/gen_test_char.lo -c tools/gen_test_char.c & & touch tools/gen_test_char.lo
/bin/sh /root/httpd-2.4.33/srclib/apr/libtool --silent --mode=link cc -g -O2 -DHAVE_CONFIG_H -I./include -I/root/httpd-2.4.33/srclib/apr/include/arch/unix -I./include/arch/unix -I/root/httpd-2.4.33/srclib/apr/include/arch/unix -I/root/httpd-2.4.33/srclib/apr/include -I/root/httpd-2.4.33/srclib/apr/include/private -I/root/httpd-2.4.33/srclib/apr/include/private -no-install -o tools/gen_test_char tools/gen_test_char.lo -lcrypt -lpthread
/root/httpd-2.4.33/srclib/apr/build/mkdir.sh include/private
mkdir include/private
tools/gen_test_char > include/private/apr_escape_test_char.h
/bin/sh /root/httpd-2.4.33/srclib/apr/libtool --silent --mode=compile cc -g -O2 -DHAVE_CONFIG_H -I./include -I/root/httpd-2.4.33/srclib/apr/include/arch/unix -I./include/arch/unix -I/root/httpd-2.4.33/srclib/apr/include/arch/unix -I/root/httpd-2.4.33/srclib/apr/include -I/root/httpd-2.4.33/srclib/apr/include/private -I/root/httpd-2.4.33/srclib/apr/include/private -o encoding/apr_escape.lo -c encoding/apr_escape.c & & touch encoding/apr_escape.lo
.
.
.
cc: warning: -liconv: ' linker' input unused [-Wunused-command-line-argument]
/root/httpd-2.4.33/srclib/apr/libtool --silent --mode=link cc -g -O2 -liconv -L/usr/local/lib -o mod_rewrite.la -rpath /usr/apache/modules -module -avoid-version mod_rewrite.lo
After compiling, install Apache using the following command.
root@linuxhelp11:~/httpd-2.4.33 # make install
Making install in srclib
Making install in apr
/root/httpd-2.4.33/srclib/apr/build/mkdir.sh /usr/apache/lib /usr/apache/bin /usr/apache/build /usr/apache/lib/pkgconfig /usr/apache/include
mkdir /usr/apache
mkdir /usr/apache/lib
mkdir /usr/apache/bin
mkdir /usr/apache/build
mkdir /usr/apache/lib/pkgconfig
mkdir /usr/apache/include
/usr/bin/install -c -m 644 /root/httpd-2.4.33/srclib/apr/include/apr.h /usr/apache/include
for f in /root/httpd-2.4.33/srclib/apr/include/apr_*.h do /usr/bin/install -c -m 644 ${f} /usr/apache/include done
/bin/sh /root/httpd-2.4.33/srclib/apr/libtool --mode=install /usr/bin/install -c -m 755 libapr-1.la /usr/apache/lib
libtool: install: /usr/bin/install -c -m 755 .libs/libapr-1.so.0.6.2 /usr/apache/lib/libapr-1.so.0.6.2
libtool: install: (cd /usr/apache/lib & & { ln -s -f libapr-1.so.0.6.2 libapr-1.so.0 || { rm -f libapr-1.so.0 & & ln -s libapr-1.so.0.6.2 libapr-1.so.0 } })
libtool: install: (cd /usr/apache/lib & & { ln -s -f libapr-1.so.0.6.2 libapr-1.so || { rm -f libapr-1.so & & ln -s libapr-1.so.0.6.2 libapr-1.so } })
libtool: install: /usr/bin/install -c -m 755 .libs/libapr-1.lai /usr/apache/lib/libapr-1.la
.
.
.
Installing build system files
Installing man pages and online manual
mkdir /usr/apache/man
mkdir /usr/apache/man/man1
mkdir /usr/apache/man/man8
mkdir /usr/apache/manual
Installation is complete. Now, go to the installed location and list it.
root@linuxhelp11:~/httpd-2.4.33 # cd /usr/apache/
root@linuxhelp11:/usr/apache # ll
total 56
drwxr-xr-x 2 root wheel 512 Apr 22 05:17 bin/
drwxr-xr-x 2 root wheel 512 Apr 22 05:17 build/
drwxr-xr-x 2 root wheel 512 Apr 22 05:17 cgi-bin/
drwxr-xr-x 4 root wheel 512 Apr 22 05:17 conf/
drwxr-xr-x 3 root wheel 1024 Apr 22 05:17 error/
drwxr-xr-x 2 root wheel 512 Apr 22 05:17 htdocs/
drwxr-xr-x 3 root wheel 4096 Apr 22 05:17 icons/
drwxr-xr-x 2 root wheel 3584 Apr 22 05:17 include/
drwxr-xr-x 3 root wheel 512 Apr 22 05:17 lib/
drwxr-xr-x 2 root wheel 512 Apr 22 05:17 logs/
drwxr-xr-x 4 root wheel 512 Apr 22 05:17 man/
drwxr-xr-x 14 root wheel 6144 Apr 22 05:17 manual/
drwxr-xr-x 2 root wheel 2560 Apr 22 05:17 modules/
If you want to check for version, give the following command.
root@linuxhelp11: # /usr/apache/bin/apachectl -v
Server version: Apache/2.4.33 (Unix)
Server built: Apr 22 2018 05:15:25
Now, we are going to create daemon for apache. in order to do that we need to create a new file in rc.d location and add the following lines.
root@linuxhelp11:/bin # vim /usr/local/etc/rc.d/apache24
. /etc/rc.subr
name=" apache24"
rcvar=" apache24_enable"
command=" /usr/apache/bin/apachectl"
_pidprefix=" /usr/apache/logs/httpd"
pidfile=" ${_pidprefix}.pid"
required_files=/usr/apache/conf/httpd.conf
start_cmd=" test_start"
stop_cmd=" test_stop"
status_cmd=" test_status"
test_start() {
${command}
}
test_status() {
if [ -e ${pidfile} ] then
echo ${name} is running...
else
echo ${name} is not running.
fi
}
test_stop() {
if [ -e ${pidfile} ] then
kill `cat ${pidfile}`
else
echo ${name} is not running?
fi
}
load_rc_config $name
run_rc_command " $1"
And then give executable permission for the newly created file using the following command.
root@linuxhelp11: # chmod +x /usr/local/etc/rc.d/apache24
Enable Apache using the following command.
root@linuxhelp11:/bin # echo ' apache24_enable=" YES" ' > > /etc/rc.conf
And then ou can start apache using the following command.
root@linuxhelp11:/bin # service apache24 start
Check status for Apache.
root@linuxhelp11:/bin # service apache24 status
apache24 is running...
Now, open a browser, and give the URL as machine IP or localhost.
With this, the method to Install Apache from source on FreeBSD 11.1 comes to an end.
Comments ( 0 )
No comments available