Jumat, 12 Oktober 2018

How to install Apache 2.4 from source on centos 6

  Tidak ada komentar
Some day i need install apache 2.4 on centos with php 7.1, so i have install the apache 2.4 from source
[root@cloud ~]# yum install expat-devel pcre pcre-devel openssl-devel -y
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
There are unfinished transactions remaining. You might consider running yum-complete-transaction first to finish them.
--> 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                                                                                                 222 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@cloud ~]#
Download apache source package from github repositories
[root@cloud ~]# wget https://github.com/apache/httpd/archive/2.4.36.tar.gz -O httpd-2.4.28.tar.gz
[root@cloud ~]# wget https://github.com/apache/apr/archive/1.6.5.tar.gz -O apr-1.6.5.tar.gz
[root@cloud ~]# wget https://github.com/apache/apr-util/archive/1.6.1.tar.gz -O apr-util-1.6.1.tar.gz
Check the downloaded files

[root@cloud ~]# ls
anaconda-ks.cfg   apr-util-1.6.1.tar.gz  httpd-2.4.28.tar.gz  install.log.syslog
apr-1.6.5.tar.gz  db_bak                 install.log          mysql80-community-release-el6-1.noarch.rpm
[root@cloud ~]#
Extract the files
[root@cloud ~]# tar -xzf httpd-2.4.28.tar.gz
[root@cloud ~]# tar -xzf apr-1.6.5.tar.gz
[root@cloud ~]# tar -xzf apr-util-1.6.1.tar.gz
[root@cloud ~]#
[root@cloud ~]# ls
anaconda-ks.cfg   apr-util-1.6.1         httpd-2.4.28.tar.gz  install.log.syslog
apr-1.6.5         apr-util-1.6.1.tar.gz  httpd-2.4.36         mysql80-community-release-el6-1.noarch.rpm
apr-1.6.5.tar.gz  db_bak                 install.log
[root@cloud ~]#
Move the apr and apr util folder into httpd folder
[root@cloud ~]# mv apr-util-1.6.1 httpd-2.4.36/srclib/apr-util
[root@cloud ~]# mv apr-1.6.5 httpd-2.4.36/srclib/apr
[root@cloud ~]# ls
anaconda-ks.cfg   apr-util-1.6.1.tar.gz  httpd-2.4.28.tar.gz  install.log         mysql80-community-release-el6-1.noarch.rpm
apr-1.6.5.tar.gz  db_bak                 httpd-2.4.36         install.log.syslog
[root@cloud ~]#
Change working directory to httpd folder

[root@cloud ~]# cd httpd-2.4.36/
[root@cloud httpd-2.4.36]# 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@cloud httpd-2.4.36]#
Built the configuration

[root@cloud httpd-2.4.36]# ./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.36/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@cloud httpd-2.4.36]#

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@cloud httpd-2.4.36]# ./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
checking for gcc... gcc
checking for C compiler default output file name... a.out
checking whether the C compiler works... yes
checking whether we are cross compiling... no
checking for suffix of executables...
checking for suffix of object files... o
checking whether we are using the GNU C compiler... yes
checking whether gcc accepts -g... yes
checking for gcc option to accept ISO C89... none needed
..
..
config.status: creating support/logresolve.pl
config.status: creating support/phf_abuse_log.cgi
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.36
    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@cloud httpd-2.4.36]#
Compile the source by typing Make
[root@cloud httpd-2.4.36]# make
Making all in srclib
make[1]: Entering directory `/root/httpd-2.4.36/srclib'
Making all in apr
make[2]: Entering directory `/root/httpd-2.4.36/srclib/apr'
make[3]: Entering directory `/root/httpd-2.4.36/srclib/apr'
sed 's,^\(location=\).*$,\1installed,' < apr-1-config > apr-config.out
sed -e 's,^\(apr_build.*=\).*$,\1/usr/local/apache2/build,' -e 's,^\(top_build.*=\).*$,\1/usr/local/apache2/build,' < build/apr_rules.mk > build/apr_rules.out
make[3]: Leaving directory `/root/httpd-2.4.36/srclib/apr'
make[2]: Leaving directory `/root/httpd-2.4.36/srclib/apr'
Making all in apr-util
make[2]: Entering directory `/root/httpd-2.4.36/srclib/apr-util'
make[3]: Entering directory `/root/httpd-2.4.36/srclib/apr-util'
sed 's,^\(location=\).*$,\1installed,' < apu-1-config > apu-config.out
make[3]: Leaving directory `/root/httpd-2.4.36/srclib/apr-util'
make[2]: Leaving directory `/root/httpd-2.4.36/srclib/apr-util'
make[1]: Leaving directory `/root/httpd-2.4.36/srclib'
Making all in os
make[1]: Entering directory `/root/httpd-2.4.36/os'
Making all in unix
make[2]: Entering directory `/root/httpd-2.4.36/os/unix'
make[3]: Entering directory `/root/httpd-2.4.36/os/unix'
make[3]: Nothing to be done for `local-all'.
make[3]: Leaving directory `/root/httpd-2.4.36/os/unix'
make[2]: Leaving directory `/root/httpd-2.4.36/os/unix'
make[1]: Leaving directory `/root/httpd-2.4.36/os'
Making all in server
make[1]: Entering directory `/root/httpd-2.4.36/server'
Making all in mpm
make[2]: Entering directory `/root/httpd-2.4.36/server/mpm'
Making all in event
make[3]: Entering directory `/root/httpd-2.4.36/server/mpm/event'
make[3]: Leaving directory `/root/httpd-2.4.36/server/mpm/event'
Making all in prefork
make[3]: Entering directory `/root/httpd-2.4.36/server/mpm/prefork'
make[3]: Leaving directory `/root/httpd-2.4.36/server/mpm/prefork'
Making all in worker
make[3]: Entering directory `/root/httpd-2.4.36/server/mpm/worker'
make[3]: Leaving directory `/root/httpd-2.4.36/server/mpm/worker'
make[2]: Leaving directory `/root/httpd-2.4.36/server/mpm'
make[2]: Entering directory `/root/httpd-2.4.36/server'
Found newer headers. Will rebuild exports.c.
rm -f exports.c export_files
( for dir in /root/httpd-2.4.36/include /root/httpd-2.4.36/os/unix; do \
              ls $dir/*.h ; \
          done; \
          echo "/root/httpd-2.4.36/server/mpm_fdqueue.h"; \
          for dir in /root/httpd-2.4.36/srclib/apr/include /root/httpd-2.4.36/srclib/apr-util/include; do \
              ls $dir/ap[ru].h $dir/ap[ru]_*.h 2>/dev/null; \
          done; \
        ) | sed -e s,//,/,g | sort -u > export_files
gawk -f /root/httpd-2.4.36/build/make_exports.awk `cat export_files` > exports.c
/root/httpd-2.4.36/srclib/apr/libtool --silent --mode=compile gcc -std=gnu99  -g -O2 -pthread      -DLINUX -D_REENTRANT -D_GNU_SOURCE     -I. -I/root/httpd-2.4.36/os/unix -I/root/httpd-2.4.36/include -I/root/httpd-2.4.36/srclib/apr/include -I/root/httpd-2.4.36/srclib/apr-util/include -I/root/httpd-2.4.36/modules/aaa -I/root/httpd-2.4.36/modules/cache -I/root/httpd-2.4.36/modules/core -I/root/httpd-2.4.36/modules/database -I/root/httpd-2.4.36/modules/filters -I/root/ht
..
..
apr-util/include -I/root/httpd-2.4.36/modules/aaa -I/root/httpd-2.4.36/modules/cache -I/root/httpd-2.4.36/modules/core -I/root/httpd-2.4.36/modules/database -I/root/httpd-2.4.36/modules/filters -I/root/httpd-2.4.36/modules/ldap -I/root/httpd-2.4.36/modules/loggers -I/root/httpd-2.4.36/modules/lua -I/root/httpd-2.4.36/modules/proxy -I/root/httpd-2.4.36/modules/http2 -I/root/httpd-2.4.36/modules/session -I/root/httpd-2.4.36/modules/ssl -I/root/httpd-2.4.36/modules/test -I/root/httpd-2.4.36/server -I/root/httpd-2.4.36/modules/md -I/root/httpd-2.4.36/modules/arch/unix -I/root/httpd-2.4.36/modules/dav/main -I/root/httpd-2.4.36/modules/generators -I/root/httpd-2.4.36/modules/mappers -prefer-pic -c mod_rewrite.c && touch mod_rewrite.slo
/root/httpd-2.4.36/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.36/modules/mappers'
make[3]: Leaving directory `/root/httpd-2.4.36/modules/mappers'
make[2]: Leaving directory `/root/httpd-2.4.36/modules'
make[2]: Entering directory `/root/httpd-2.4.36/support'
make[2]: Leaving directory `/root/httpd-2.4.36/support'

make[1]: Leaving directory `/root/httpd-2.4.36'
[root@cloud httpd-2.4.36]#
Install the package by typing Make install
[root@cloud httpd-2.4.36]# make install
Making install in srclib
make[1]: Entering directory `/root/httpd-2.4.36/srclib'
Making install in apr
make[2]: Entering directory `/root/httpd-2.4.36/srclib/apr'
make[3]: Entering directory `/root/httpd-2.4.36/srclib/apr'
make[3]: Nothing to be done for `local-all'.
make[3]: Leaving directory `/root/httpd-2.4.36/srclib/apr'
/root/httpd-2.4.36/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.36/srclib/apr/include/apr.h /usr/local/apache2/include
for f in /root/httpd-2.4.36/srclib/apr/include/apr_*.h; do \
..
..
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.36'
[root@cloud httpd-2.4.36]#
Symlink httpd binary to /sbin folder and check the httpd version
[root@cloud httpd-2.4.36]# cd /usr/local/apache2/bin/
[root@cloud 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@cloud bin]# ln -n httpd /sbin/httpd
[root@cloud bin]# ls /sbin/httpd
/sbin/httpd
[root@cloud bin]# ls -l /sbin/httpd
-rwxr-xr-x. 2 root root 2157194 Oct 27 12:31 /sbin/httpd
[root@cloud bin]#
[root@cloud bin]# httpd -v
Server version: Apache/2.4.36 (Unix)
Server built:   Oct 27 2018 12:28:10
[root@cloud bin]# cd ~
[root@cloud ~]#
[root@cloud ~]# httpd -v
Server version: Apache/2.4.36 (Unix)
Server built:   Oct 27 2018 12:28:10
[root@cloud ~]#
[root@cloud ~]# httpd -V
Server version: Apache/2.4.36 (Unix)
Server built:   Oct 27 2018 12:28:10
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@cloud ~]#
You can also use apachectl to check version and start apache service
[root@cloud httpd-2.4.36]# cd /usr/local/apache2/bin/
[root@cloud 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@cloud bin]# apachectl -v
-bash: apachectl: command not found
[root@cloud bin]#
[root@cloud bin]# ln -n apachectl /sbin/apachectl
[root@cloud bin]# apachectl -v
Server version: Apache/2.4.36 (Unix)
Server built:   Oct 27 2018 12:28:10
[root@cloud bin]#
[root@cloud bin]# cd ~
[root@cloud ~]#
[root@cloud ~]# apachectl -v
Server version: Apache/2.4.36 (Unix)
Server built:   Oct 27 2018 12:28:10
[root@cloud ~]#
[root@cloud ~]# apachectl -V
Server version: Apache/2.4.36 (Unix)
Server built:   Oct 27 2018 12:28:10
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@cloud ~]#
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@cloud ~]# apachectl status
ELinks: Connection refused
[root@cloud ~]# apachectl start
AH00558: httpd: Could not reliably determine the server's fully qualified domain name, using 127.0.0.1. Set the 'ServerName' directive globally to suppress this message
[root@cloud ~]#
[root@cloud ~]# curl localhost
<html><body><h1>It works!</h1></body></html>
[root@cloud ~]#
Create script to enable service start status restart via service command
[root@cloud ~]# vi /etc/init.d/httpd
[root@cloud ~]# chmod +x /etc/init.d/httpd
[root@cloud ~]# ls -l /etc/init.d/httpd
-rwxr-xr-x. 1 root root 787 Oct 27 12:59 /etc/init.d/httpd
[root@cloud ~]#
[root@cloud ~]# 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@cloud ~]#
Check httpd service status and restart the service
[root@cloud ~]# service httpd status
httpd (pid 127257 127252 127251 127250) is running...
[root@cloud ~]#
[root@cloud ~]# service httpd stop
Shutting down httpd:                                       [  OK  ]
[root@cloud ~]#
[root@cloud ~]# service httpd status
httpd is stopped
[root@cloud ~]#
[root@cloud ~]# service httpd start
Starting httpd: AH00558: httpd: Could not reliably determine the server's fully qualified domain name, using ::1. Set the 'ServerName' directive globally to suppress this message
                                                           [  OK  ]
[root@cloud ~]#
[root@cloud ~]# service httpd status
httpd (pid 127455 127454 127453 127451) is running...
[root@cloud ~]#
Curl the localhost to test the apache server
[root@cloud ~]#
[root@cloud ~]# curl localhost
<html><body><h1>It works!</h1></body></html>
[root@cloud ~]#

Tidak ada komentar :

Posting Komentar