Linux Apache compile and install;

Source: Internet
Author: User

Apache is a common Web service-side tool, called HTTPd on Linux, and the service name is httpd;

On CentOS 6 default comes with httpd2.2 version, 7 on the default is 2.4 version;

2.4 HTTP Support uses the event model (each thread corresponds to a client request);


Before compiling the installation, you need to determine the APR, and Apr-util is already installed, you need to set the APR installation path when compiling and installing Apr-util--with-apr=/some/path


# MKDIR/SRC//Create a directory to store source packages;

To the Apache official website download httpd2.4 src source package httpd-2.4.25.tar.bz2;

# TAR-XF HTTPD-2.4.25.TAR.BZ2//unzip the source package;

# CD httpd-2.4.25//Enter the extracted directory;

#./configure--help//query./configure's help documentation;

#./configure--prefix=/usr/local/httpd--sysconfdir=/etc/httpd--enabel-so--enable-ssl--enable-cgi--enable-rewrit --with-zlib--with-apr=/usr/local/apr--with-apr-util=/usr/local/apr-util--with-pcre--enable-modules=most-- Enable-mpms-shared=all--with-mpm=prefork


--prefix=//Indicates the location of the installation directory;

--sysconfdir=//configuration file installation location;


--ENABLE-SO//Open dynamic loading module function;

--ENABLE-SSL//enable SSL function;

--ENABLE-CGI//Allow execution of CGI scripts;

--enable-rewrite//Turn on rewrite function;

--enable-modules=[all | most]//all means to open all modules, most of which means to open most modules;

--enable-mpms-shared=all//Specifies the MPM module to be compiled;


--with-zlib//support zlib compression;

--WITH-APR//Specify the path strength of APR, do not specify the default self-lookup;

--with-apr-util//Specifies the path location of the Apr-util;

--with-pcre//designation Pcre;

--with-mpm=//Specify MPM mode to be used by default;


# Make && make install


# Ln-sv/usr/local/httpd/include/usr/include//The development of the available header files are made into a connection for subsequent development purposes;

# Vim/etc/man.config//Export the new man help document;

Manpath/usr/local/httpd/man


# vim/etc/profile.d/httpd.sh//export executable file;

echo Path=/usr/local/httpd/bin: $PATH


Last Add service script

Provides the SYSV service script/etc/rc.d/init.d/httpd, as follows:


#!/bin/bash

#

# httpd Startup script for the Apache HTTP Server

#

# Chkconfig:-85 15

# Description:apache is a world Wide Web server. It's used to serve \

# HTML files and CGI.

# PROCESSNAME:HTTPD

# config:/etc/httpd/conf/httpd.conf

# config:/etc/sysconfig/httpd

# Pidfile:/var/run/httpd.pid


# 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 would 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 this some modules may not

# work correctly with a thread-based MPM; Notably PHP would refuse to start.


# Path to the Apachectl script, server binary, and short-form for messages.

Apachectl=/usr/local/apache/bin/apachectl

HTTPD=${HTTPD-/USR/LOCAL/APACHE/BIN/HTTPD}

Prog=httpd

Pidfile=${pidfile-/var/run/httpd.pid}

LOCKFILE=${LOCKFILE-/VAR/LOCK/SUBSYS/HTTPD}

Retval=0


Start () {

Echo-n $ "Starting $prog:"

lang= $HTTPD _lang Daemon--pidfile=${pidfile} $httpd $OPTIONS

Retval=$?

Echo

[$RETVAL = 0] && Touch ${lockfile}

Return $RETVAL

}


Stop () {

Echo-n $ "Stopping $prog:"

Killproc-p ${pidfile}-D $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=$?

echo $ "not reloading due to configuration syntax error"

Failure $ "not reloading $HTTPD due to configuration syntax error"

Else

Killproc-p ${pidfile} $httpd-hup

Retval=$?

Fi

Echo

}


# See how we were called.

Case "$" in

Start

Start

;;

Stop

Stop

;;

Status

Status-p ${pidfile} $httpd

Retval=$?

;;

Restart

Stop

Start

;;

Condrestart)

If [-f ${pidfile}]; Then

Stop

Start

Fi

;;

Reload

Reload

;;

Graceful|help|configtest|fullstatus)

$apachectl [email protected]

Retval=$?

;;

*)

echo $ "Usage: $prog {start|stop|restart|condrestart|reload|status|fullstatus|graceful|help|configtest}"

Exit 1

Esac


Exit $RETVAL


Then give execute permission for this script:

# chmod +X/ETC/RC.D/INIT.D/HTTPD


Join the Service list:

# chkconfig--add httpd


Linux Apache compile and install;

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.