Jumat, 02 November 2018

How to install apache 2.4.37 from source on Centos 6.9

  Tidak ada komentar
Some day i need install apache 2.4 on centos with php 5.4, so i have install the apache 2.4 from source
[root@localhost ~]# yum install -y expat-devel pcre pcre-devel openssl-devel
Loaded plugins: fastestmirror, security
Setting up Install Process
Loading mirror speeds from cached hostfile
 * base: centos.biz.net.id
 * extras: centos.biz.net.id
 * updates: centos.biz.net.id
Package pcre-7.8-7.el6.x86_64 already installed and latest version
Package openssl-devel-1.0.1e-57.el6.x86_64 already installed and latest version
Resolving Dependencies
--> Running transaction check
---> Package expat-devel.x86_64 0:2.0.1-13.el6_8 will be installed
---> Package pcre-devel.x86_64 0:7.8-7.el6 will be installed
--> Finished Dependency Resolution

Dependencies Resolved

======================================================================================================================================
 Package                           Arch                         Version                              Repository                  Size
======================================================================================================================================
Installing:
 expat-devel                       x86_64                       2.0.1-13.el6_8                       base                       119 k
 pcre-devel                        x86_64                       7.8-7.el6                            base                       320 k

Transaction Summary
======================================================================================================================================
Install       2 Package(s)

Total download size: 439 k
Installed size: 1.4 M
Downloading Packages:
(1/2): expat-devel-2.0.1-13.el6_8.x86_64.rpm                                                                   | 119 kB     00:00
(2/2): pcre-devel-7.8-7.el6.x86_64.rpm                                                                         | 320 kB     00:00
--------------------------------------------------------------------------------------------------------------------------------------
Total                                                                                                 353 kB/s | 439 kB     00:01
Running rpm_check_debug
Running Transaction Test
Transaction Test Succeeded
Running Transaction
  Installing : pcre-devel-7.8-7.el6.x86_64                                                                                        1/2
  Installing : expat-devel-2.0.1-13.el6_8.x86_64                                                                                  2/2
  Verifying  : expat-devel-2.0.1-13.el6_8.x86_64                                                                                  1/2
  Verifying  : pcre-devel-7.8-7.el6.x86_64                                                                                        2/2

Installed:
  expat-devel.x86_64 0:2.0.1-13.el6_8                                  pcre-devel.x86_64 0:7.8-7.el6

Complete!
[root@localhost ~]#

Download apache source package from github repositories
[root@localhost ~]# wget https://github.com/apache/httpd/archive/2.4.37.tar.gz -O httpd-2.4.37.tar.gz
--2018-11-02 16:13:14--  https://github.com/apache/httpd/archive/2.4.37.tar.gz
Connecting to 192.168.73.65:6969... connected.
Proxy request sent, awaiting response... 302 Found
Location: https://codeload.github.com/apache/httpd/tar.gz/2.4.37 [following]
--2018-11-02 16:13:16--  https://codeload.github.com/apache/httpd/tar.gz/2.4.37
Connecting to 192.168.73.65:6969... connected.
Proxy request sent, awaiting response... 200 OK
Length: unspecified [application/x-gzip]
Saving to: “httpd-2.4.37.tar.gz”

    [        <=>                                                                                  ] 11,812,549  7.42M/s   in 1.5s

2018-11-02 16:13:20 (7.42 MB/s) - “httpd-2.4.37.tar.gz” saved [11812549]

[root@localhost ~]#

[root@localhost ~]# wget https://github.com/apache/apr/archive/1.6.5.tar.gz -O apr-1.6.5.tar.gz
--2018-11-02 16:17:29--  https://github.com/apache/apr/archive/1.6.5.tar.gz
Connecting to 192.168.71.17:9898... connected.
Proxy request sent, awaiting response... 302 Found
Location: https://codeload.github.com/apache/apr/tar.gz/1.6.5 [following]
--2018-11-02 16:17:32--  https://codeload.github.com/apache/apr/tar.gz/1.6.5
Connecting to 192.168.73.65:6969... connected.
Proxy request sent, awaiting response... 200 OK
Length: unspecified [application/x-gzip]
Saving to: “apr-1.6.5.tar.gz”

    [      <=>                                                                                    ] 733,069      605K/s   in 1.2s

2018-11-02 16:17:34 (605 KB/s) - “apr-1.6.5.tar.gz” saved [733069]

[root@localhost ~]#
[root@cloud ~]# [root@localhost ~]# wget https://github.com/apache/apr-util/archive/1.6.1.tar.gz -O apr-util-1.6.1.tar.gz
--2018-11-02 16:18:31--  https://github.com/apache/apr-util/archive/1.6.1.tar.gz
Connecting to 192.168.73.65:6969... connected.
Proxy request sent, awaiting response... 302 Found
Location: https://codeload.github.com/apache/apr-util/tar.gz/1.6.1 [following]
--2018-11-02 16:18:32--  https://codeload.github.com/apache/apr-util/tar.gz/1.6.1
Connecting to 192.168.73.65:6969... connected.
Proxy request sent, awaiting response... 200 OK
Length: unspecified [application/x-gzip]
Saving to: “apr-util-1.6.1.tar.gz”

    [ <=>                                                                                         ] 432,752     --.-K/s   in 0.07s

2018-11-02 16:18:33 (5.89 MB/s) - “apr-util-1.6.1.tar.gz” saved [432752]

[root@localhost ~]#
Check the downloaded files
[root@localhost ~]# ls
anaconda-ks.cfg  apr-1.6.5.tar.gz  apr-util-1.6.1.tar.gz  httpd-2.4.37.tar.gz  install.log  install.log.syslog
[root@localhost ~]#
Extract the files
[root@localhost ~]# tar xzf httpd-2.4.37.tar.gz
[root@localhost ~]# tar xzf apr-1.6.5.tar.gz
[root@localhost ~]# tar xzf apr-util-1.6.1.tar.gz
[root@localhost ~]# ls
anaconda-ks.cfg  apr-1.6.5.tar.gz  apr-util-1.6.1.tar.gz  httpd-2.4.37.tar.gz  install.log.syslog
apr-1.6.5        apr-util-1.6.1    httpd-2.4.37           install.log
[root@localhost ~]#
Move the apr and apr util folder into httpd folder
[root@localhost ~]# mv apr-util-1.6.1 httpd-2.4.37/srclib/apr-util
[root@localhost ~]# mv apr-1.6.5 httpd-2.4.37/srclib/apr
[root@localhost ~]# ls
anaconda-ks.cfg  apr-1.6.5.tar.gz  apr-util-1.6.1.tar.gz  httpd-2.4.37  httpd-2.4.37.tar.gz  install.log  install.log.syslog
[root@localhost ~]#
Change working directory to httpd folder
[root@localhost ~]# cd httpd-2.4.37
[root@localhost httpd-2.4.37]# ls
ABOUT_APACHE     ap.d          CHANGES         emacs-style  INSTALL         libhttpd.mak  NOTICE         README.platforms  support
acinclude.m4     build         CMakeLists.txt  httpd.dep    InstallBin.dsp  LICENSE       NWGNUmakefile  ROADMAP           test
Apache-apr2.dsw  BuildAll.dsp  config.layout   httpd.dsp    LAYOUT          Makefile.in   os             server            VERSIONING
Apache.dsw       BuildBin.dsp  configure.in    httpd.mak    libhttpd.dep    Makefile.win  README         srclib
apache_probes.d  buildconf     docs            include      libhttpd.dsp    modules       README.cmake   STATUS
[root@localhost httpd-2.4.37]#
Built the configuration

[root@localhost httpd-2.4.37]# ./buildconf
found apr source: srclib/apr
found apr-util source: srclib/apr-util
rebuilding srclib/apr/configure
buildconf: checking installation...
buildconf: python version 2.6.6 (ok)
buildconf: autoconf version 2.63 (ok)
buildconf: libtool version 2.2.6b (ok)
buildconf: copying libtool helper files using /usr/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.37/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
[root@localhost httpd-2.4.37]#

Configure the installation options, you can find more details information of configure option on this page : https://httpd.apache.org/docs/current/programs/configure.html
[root@localhost httpd-2.4.37]# ./configure --prefix=/usr/local/apache2 --enable-so --enable-ssl  --with-included-apr
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:
configuring package in srclib/apr now
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.6.5
checking for chosen layout... apr
..
..
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
configure: summary of build options:

    Server Version: 2.4.37
    Install prefix: /usr/local/apache2
    C compiler:     gcc -std=gnu99
    CFLAGS:          -g -O2 -pthread
    CPPFLAGS:        -DLINUX -D_REENTRANT -D_GNU_SOURCE
    LDFLAGS:
    LIBS:
    C preprocessor: gcc -E

[root@localhost httpd-2.4.37]#
Compile the source by typing Make
[root@localhost httpd-2.4.37]# make
Making all in srclib
make[1]: Entering directory `/root/httpd-2.4.37/srclib'
Making all in apr
make[2]: Entering directory `/root/httpd-2.4.37/srclib/apr'
make[3]: Entering directory `/root/httpd-2.4.37/srclib/apr'
/root/httpd-2.4.37/srclib/apr/build/mkdir.sh tools
/bin/sh /root/httpd-2.4.37/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.37/srclib/apr/include/arch/unix -I./include/arch/unix -I/root/httpd-2.4.37/srclib/apr/include/arch/unix -I/root/httpd-2.4.37/srclib/apr/include -I/root/httpd-2.4.37/srclib/apr/include/private -I/root/httpd-2.4.37/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.37/srclib/apr/libtool --silent --mode=link gcc -g -O2 -pthread   -DHAVE_CONFIG_H  -DLINUX -D_REENTRANT -D_GNU_SOURCE   -I./include -I/root/httpd-2.4.37/srclib/apr/include/arch/unix -I./include/arch/unix -I/root/httpd-2.4.37/srclib/apr/include/arch/unix -I/root/httpd-2.4.37/srclib/apr/include -I/root/httpd-2.4.37/srclib/apr/include/private -I/root/httpd-2.4.37/srclib/apr/include/private   -no-install    -o tools/gen_test_char tools/gen_test_char.lo    -lrt -lcrypt  -lpthread
/root/httpd-2.4.37/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.37/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.37/srcl
..
..
/root/httpd-2.4.37/srclib/apr/libtool --silent --mode=link gcc -std=gnu99  -g -O2 -pthread           -o mod_rewrite.la -rpath /usr/local/apache2/modules -module -avoid-version  mod_rewrite.lo
make[4]: Leaving directory `/root/httpd-2.4.37/modules/mappers'
make[3]: Leaving directory `/root/httpd-2.4.37/modules/mappers'
make[2]: Leaving directory `/root/httpd-2.4.37/modules'
make[2]: Entering directory `/root/httpd-2.4.37/support'
make[2]: Leaving directory `/root/httpd-2.4.37/support'

make[1]: Leaving directory `/root/httpd-2.4.37'
[root@localhost httpd-2.4.37]#
Install the package by typing Make install
[root@localhost httpd-2.4.37]# make install
Making install in srclib
make[1]: Entering directory `/root/httpd-2.4.37/srclib'
Making install in apr
make[2]: Entering directory `/root/httpd-2.4.37/srclib/apr'
make[3]: Entering directory `/root/httpd-2.4.37/srclib/apr'
make[3]: Nothing to be done for `local-all'.
make[3]: Leaving directory `/root/httpd-2.4.37/srclib/apr'
/root/httpd-2.4.37/srclib/apr/build/mkdir.sh /usr/local/apache2/lib /usr/local/apache2/bin /usr/local/apache2/build \
                     /usr/local/apache2/lib/pkgconfig /usr/local/apache2/include
mkdir /usr/local/apache2
mkdir /usr/local/apache2/lib
mkdir /usr/local/apache2/bin
mkdir /usr/local/apache2/build
mkdir /usr/local/apache2/lib/pkgconfig
mkdir /usr/local/apache2/include
/usr/bin/install -c -m 644 /root/httpd-2.4.37/srclib/apr/include/apr.h /usr/local/apache2/include
for f in /root/httpd-2.4.37/srclib/apr/include/apr_*.h; do \
            /usr/bin/install -c -m 644 ${f} /usr/local/apache2/include; \
        done
..
..
Installing configuration files
mkdir /usr/local/apache2/conf
mkdir /usr/local/apache2/conf/extra
mkdir /usr/local/apache2/conf/original
mkdir /usr/local/apache2/conf/original/extra
Installing HTML documents
mkdir /usr/local/apache2/htdocs
Installing error documents
mkdir /usr/local/apache2/error
Installing icons
mkdir /usr/local/apache2/icons
mkdir /usr/local/apache2/logs
Installing CGIs
mkdir /usr/local/apache2/cgi-bin
Installing header files
Installing build system files
Installing man pages and online manual
mkdir /usr/local/apache2/man
mkdir /usr/local/apache2/man/man1
mkdir /usr/local/apache2/man/man8
mkdir /usr/local/apache2/manual
make[1]: Leaving directory `/root/httpd-2.4.37'
[root@localhost httpd-2.4.37]#
Symlink httpd binary to /sbin folder and check the httpd version
[root@localhost httpd-2.4.37]# cd /usr/local/apache2/bin/
[root@localhost bin]#
[root@localhost bin]# ls
ab         apr-1-config  apxs      dbmmanage  envvars-std  htcacheclean  htdigest  httpd      logresolve
apachectl  apu-1-config  checkgid  envvars    fcgistarter  htdbm         htpasswd  httxt2dbm  rotatelogs
[root@localhost bin]# ln -n httpd /sbin/httpd
[root@localhost bin]# ls -l /sbin/httpd
-rwxr-xr-x. 2 root root 2157194 Nov  2 16:54 /sbin/httpd
[root@localhost bin]# unlink /sbin/httpd
[root@localhost bin]# ls -l /sbin/httpd
ls: cannot access /sbin/httpd: No such file or directory
[root@localhost bin]#
[root@localhost bin]# ln -n httpd /sbin/httpd
[root@localhost bin]# ls -l /sbin/httpd
-rwxr-xr-x. 2 root root 2157194 Nov  2 16:54 /sbin/httpd
[root@localhost bin]#
[root@localhost bin]# httpd -v
Server version: Apache/2.4.37 (Unix)
Server built:   Nov  2 2018 16:46:24
[root@localhost bin]#
[root@localhost bin]# cd ~
[root@localhost ~]#
[root@localhost ~]# httpd -v
Server version: Apache/2.4.37 (Unix)
Server built:   Nov  2 2018 16:46:24
[root@localhost ~]#
[root@localhost ~]# httpd -V
Server version: Apache/2.4.37 (Unix)
Server built:   Nov  2 2018 16:46:24
Server's Module Magic Number: 20120211:83
Server loaded:  APR 1.6.5, APR-UTIL 1.6.1
Compiled using: APR 1.6.5, APR-UTIL 1.6.1
Architecture:   64-bit
Server MPM:     event
  threaded:     yes (fixed thread count)
    forked:     yes (variable process count)
Server compiled with....
 -D APR_HAS_SENDFILE
 -D APR_HAS_MMAP
 -D APR_HAVE_IPV6 (IPv4-mapped addresses enabled)
 -D APR_USE_SYSVSEM_SERIALIZE
 -D APR_USE_PTHREAD_SERIALIZE
 -D SINGLE_LISTEN_UNSERIALIZED_ACCEPT
 -D APR_HAS_OTHER_CHILD
 -D AP_HAVE_RELIABLE_PIPED_LOGS
 -D DYNAMIC_MODULE_LIMIT=256
 -D HTTPD_ROOT="/usr/local/apache2"
 -D SUEXEC_BIN="/usr/local/apache2/bin/suexec"
 -D DEFAULT_PIDLOG="logs/httpd.pid"
 -D DEFAULT_SCOREBOARD="logs/apache_runtime_status"
 -D DEFAULT_ERRORLOG="logs/error_log"
 -D AP_TYPES_CONFIG_FILE="conf/mime.types"
 -D SERVER_CONFIG_FILE="conf/httpd.conf"
[root@localhost ~]#
You can also use apachectl to check version and start apache service
[root@localhost ~]# cd /usr/local/apache2/bin/
[root@localhost bin]# ls
ab         apr-1-config  apxs      dbmmanage  envvars-std  htcacheclean  htdigest  httpd      logresolve
apachectl  apu-1-config  checkgid  envvars    fcgistarter  htdbm         htpasswd  httxt2dbm  rotatelogs
[root@localhost bin]# apachectl -v
-bash: apachectl: command not found
[root@localhost bin]# ln -n apachectl /sbin/apachectl
[root@localhost bin]# ls -l /sbin/apachectl
-rwxr-xr-x. 2 root root 3438 Nov  2 16:44 /sbin/apachectl
[root@localhost bin]# apachectl -v
Server version: Apache/2.4.37 (Unix)
Server built:   Nov  2 2018 16:46:24
[root@localhost bin]# cd ~
[root@localhost ~]# apachectl -v
Server version: Apache/2.4.37 (Unix)
Server built:   Nov  2 2018 16:46:24
[root@localhost ~]# apachectl -V
Server version: Apache/2.4.37 (Unix)
Server built:   Nov  2 2018 16:46:24
Server's Module Magic Number: 20120211:83
Server loaded:  APR 1.6.5, APR-UTIL 1.6.1
Compiled using: APR 1.6.5, APR-UTIL 1.6.1
Architecture:   64-bit
Server MPM:     event
  threaded:     yes (fixed thread count)
    forked:     yes (variable process count)
Server compiled with....
 -D APR_HAS_SENDFILE
 -D APR_HAS_MMAP
 -D APR_HAVE_IPV6 (IPv4-mapped addresses enabled)
 -D APR_USE_SYSVSEM_SERIALIZE
 -D APR_USE_PTHREAD_SERIALIZE
 -D SINGLE_LISTEN_UNSERIALIZED_ACCEPT
 -D APR_HAS_OTHER_CHILD
 -D AP_HAVE_RELIABLE_PIPED_LOGS
 -D DYNAMIC_MODULE_LIMIT=256
 -D HTTPD_ROOT="/usr/local/apache2"
 -D SUEXEC_BIN="/usr/local/apache2/bin/suexec"
 -D DEFAULT_PIDLOG="logs/httpd.pid"
 -D DEFAULT_SCOREBOARD="logs/apache_runtime_status"
 -D DEFAULT_ERRORLOG="logs/error_log"
 -D AP_TYPES_CONFIG_FILE="conf/mime.types"
 -D SERVER_CONFIG_FILE="conf/httpd.conf"
[root@localhost ~]#
Starting apache service using apache controller script, you can test the apache by perform curl on localhost, if its ok, it will reply text "it works!" as shown bellow 
[root@localhost ~]# apachectl status
ELinks: Connection refused
[root@localhost ~]# apachectl start
AH00558: httpd: Could not reliably determine the server's fully qualified domain name, using localhost.localdomain. Set the 'ServerName' directive globally to suppress this message
[root@localhost ~]#
[root@localhost ~]# curl localhost
<html><body><h1>It works!</h1></body></html>
[root@localhost ~]#
Create script to enable service start status restart via service command
[root@localhost ~]# vi /etc/init.d/httpd
[root@localhost ~]# chmod +x /etc/init.d/httpd
[root@localhost ~]# ls -l /etc/init.d/httpd
-rwxr-xr-x. 1 root root 787 Nov  2 17:22 /etc/init.d/httpd
[root@localhost ~]# cat /etc/init.d/httpd
#!/bin/sh
#
# Startup script for the Apache Web Server
#
# chkconfig: 345 85 15
# description: Apache is a World Wide Web server.  It is used to serve
#          HTML files and CGI.
# processname: httpd
# pidfile: /var/run/httpd.pid
# config: /etc/httpd/conf/httpd.conf

# Source function library.
. /etc/rc.d/init.d/functions

# See how we were called.
case "$1" in
start)
echo -n "Starting httpd: "
daemon /usr/local/apache2/bin/httpd -DSSL
echo
touch /var/lock/subsys/httpd
;;
stop)
echo -n "Shutting down httpd: "
killproc httpd
echo
rm -f /var/lock/subsys/httpd
rm -f /var/run/httpd.pid
;;
status)
status httpd
;;
restart)
$0 stop
$0 start
;;
reload)
echo -n "Reloading httpd: "
killproc httpd -HUP
echo
;;
*)
echo "Usage: $0 {start|stop|restart|reload|status}"
exit 1
esac

exit 0
[root@localhost ~]#
Check httpd service status and restart the service
[root@localhost ~]# service httpd status
httpd (pid 5966 5965 5964 5963) is running...
[root@localhost ~]#
[root@localhost ~]# service httpd stop
Shutting down httpd:                                       [  OK  ]
[root@localhost ~]# service httpd status
httpd is stopped
[root@localhost ~]#
[root@localhost ~]# service httpd start
Starting httpd: AH00558: httpd: Could not reliably determine the server's fully qualified domain name, using localhost.localdomain. Set the 'ServerName' directive globally to suppress this message
                                                           [  OK  ]
[root@localhost ~]# service httpd status
httpd (pid 6141 6140 6139 6137) is running...
[root@localhost ~]#
Curl the localhost to test the apache server
[root@localhost ~]# curl localhost
<html><body><h1>It works!</h1></body></html>
[root@localhost ~]#

Tidak ada komentar :

Posting Komentar