четверг, 24 декабря 2015 г.

Install Apache 2.4 on CentOS 6.7

yum install epel-release
yum install make gcc automake zlib-devel bison cmake libtool wget gcc-c++ unzip ncurses-devel openssl-devel pcre-devel libxml2-devel curl-devel gd-devel libxslt-devel apr-devel apr-util-devel libmcrypt libmcrypt-devel


cd /tmp
wget http://apache-mirror.rbc.ru/pub/apache//httpd/httpd-2.4.18.tar.gz
wget http://apache-mirror.rbc.ru/pub/apache//apr/apr-1.5.2.tar.gz
wget http://apache-mirror.rbc.ru/pub/apache//apr/apr-util-1.5.4.tar.gz

Extract all
tar -xzvf *

mv apr-1.5.2 apr
mv apr-util-1.5.4 apr-util
mv -R apr apr-util httpd-2.4.18/srclib

Configure link for information:
https://httpd.apache.org/docs/2.4/programs/configure.html

./configure \
"--prefix=/etc/httpd" \
"--exec-prefix=/etc/httpd" \
"--sysconfdir=/etc/httpd/conf" \
"--bindir=/usr/bin" \
"--sbindir=/usr/sbin" \
"--enable-so" \
"--with-included-apr" \
"--with-included-apr-util" \
"--with-mpm=prefork" \
"--datadir=/var/www" \
"--localstatedir=/var" \
"--enable-ssl" \
"--enable-rewrite" \
"--enable-expires" \
"--with-ssl=/usr" \
"--enable-headers"

#"--includedir=/usr/include/apache" \
#"--libexecdir=/usr/lib/apache" \
#"--enable-dav" \
#"--enable-dav-fs" \
#"--enable-dav-lock" \
#"--enable-suexec" \
#"--enable-deflate" \
#"--enable-unique-id" \
#"--enable-mods-static=most" \
#"--enable-reqtimeout" \
#"--enable-proxy" \
#"--with-suexec-caller=apache" \
#"--with-suexec-docroot=/" \
#"--with-suexec-gidmin=100" \
#"--with-suexec-logfile=/var/log/httpd/suexec_log" \
#"--with-suexec-uidmin=100" \
#"--with-suexec-userdir=public_html" \
#"--with-suexec-bin=/usr/sbin/suexec" \
#"--with-pcre=/usr" \
#"--enable-logio" \
make
make install


vi /etc/init.d/httpd

#!/bin/bash
#
# httpd        Startup script for the Apache HTTP Server
#
# chkconfig: - 85 15
# description: The Apache HTTP Server is an efficient and extensible  \
#           server implementing the current HTTP standards.
# processname: httpd
# config: /etc/httpd/conf/httpd.conf
# config: /etc/sysconfig/httpd
# pidfile: /var/run/httpd/httpd.pid
#
### BEGIN INIT INFO
# Provides: httpd
# Required-Start: $local_fs $remote_fs $network $named
# Required-Stop: $local_fs $remote_fs $network
# Should-Start: distcache
# Short-Description: start and stop Apache HTTP Server
# Description: The Apache HTTP Server is an extensible server
#  implementing the current HTTP standards.
### END INIT INFO

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

if [ -f /etc/sysconfig/httpd ]; then
        . /etc/sysconfig/httpd
fi

# Start httpd in the C locale by default.
HTTPD_LANG=${HTTPD_LANG-"C"}

# This will prevent initlog from swallowing up a pass-phrase prompt if
# mod_ssl needs a pass-phrase from the user.
INITLOG_ARGS=""

# Set HTTPD=/usr/sbin/httpd.worker in /etc/sysconfig/httpd to use a server
# with the thread-based "worker" MPM; BE WARNED that some modules may not
# work correctly with a thread-based MPM; notably PHP will refuse to start.

# Path to the apachectl script, server binary, and short-form for messages.
apachectl=/usr/bin/apachectl
httpd=${HTTPD-/usr/sbin/httpd}
prog=httpd
pidfile=${PIDFILE-/var/run/httpd.pid}
lockfile=${LOCKFILE-/var/lock/subsys/httpd}
RETVAL=0
STOP_TIMEOUT=${STOP_TIMEOUT-10}

# The semantics of these two functions differ from the way apachectl does
# things -- attempting to start while running is a failure, and shutdown
# when not running is also a failure.  So we just do it the way init scripts
# are expected to behave here.
start() {
        echo -n $"Starting $prog: "
        LANG=$HTTPD_LANG daemon --pidfile=${pidfile} $httpd $OPTIONS
        RETVAL=$?
        echo
        [ $RETVAL = 0 ] && touch ${lockfile}
        return $RETVAL
}

# When stopping httpd, a delay (of default 10 second) is required
# before SIGKILLing the httpd parent; this gives enough time for the
# httpd parent to SIGKILL any errant children.
stop() {
    echo -n $"Stopping $prog: "
    killproc -p ${pidfile} -d ${STOP_TIMEOUT} $httpd
    RETVAL=$?
    echo
    [ $RETVAL = 0 ] && rm -f ${lockfile} ${pidfile}
}
reload() {
    echo -n $"Reloading $prog: "
    if ! LANG=$HTTPD_LANG $httpd $OPTIONS -t >&/dev/null; then
        RETVAL=6
        echo $"not reloading due to configuration syntax error"
        failure $"not reloading $httpd due to configuration syntax error"
    else
        # Force LSB behaviour from killproc
        LSB=1 killproc -p ${pidfile} $httpd -HUP
        RETVAL=$?
        if [ $RETVAL -eq 7 ]; then
            failure $"httpd shutdown"
        fi
    fi
    echo
}

# See how we were called.
case "$1" in
  start)
    start
    ;;
  stop)
    stop
    ;;
  status)
        status -p ${pidfile} $httpd
    RETVAL=$?
    ;;
  restart)
    stop
    start
    ;;
  condrestart|try-restart)
    if status -p ${pidfile} $httpd >&/dev/null; then
        stop
        start
    fi
    ;;
  force-reload|reload)
        reload
    ;;
  graceful|help|configtest|fullstatus)
    $apachectl $@
    RETVAL=$?
    ;;
  *)
    echo $"Usage: $prog {start|stop|restart|condrestart|try-restart|force-reload|reload|status|fullstatus|graceful|help|configtest}"
    RETVAL=2
esac

exit $RETVAL



Install PHP 5.6

wget -O php-5.6.16.tar.gz http://nl1.php.net/get/php-5.6.16.tar.gz/from/this/mirror
tar -xzvf php-5.6.16.tar.gz && cd php-5.6.16

yum install libmcrypt libmcrypt-devel 

Configure link for information:
https://secure.php.net/manual/en/configure.about.php

./configure \
--with-apxs2=/usr/sbin/apxs \
--with-config-file-path=/etc
--with-curl=/usr \
--with-gd \
--with-gettext \
--with-jpeg-dir=/usr \
--with-freetype-dir=/usr \
--with-kerberos \
--with-openssl \
--with-mcrypt=/usr/local/lib \
--with-mhash \
--with-mysql=mysqlnd \
--with-mysqli=mysqlnd \
--with-pcre-regex \
--with-pear \
--with-png-dir=/usr \
--with-xsl \
--with-zlib \
--with-zlib-dir=/usr \
--with-iconv \
--enable-bcmath \
--enable-calendar \
--enable-exif \
--enable-ftp \
--enable-gd-native-ttf \
--enable-soap \
--enable-sockets \
--enable-mbstring \
--enable-zip \
--enable-wddx 


 make && make install

cp php.ini-production /etc/php.ini

vi  /etc/httpd/conf.d/php.conf 

#php dir conf if php.ini not loaded
# PHPIniDir "/etc"
AddHandler php5-script .php

AddType text/html .php
AddType application/x-httpd-php .php
AddType application/x-httpd-php-source .phps