Httpd-2.4 source code compilation Installation

Source: Internet
Author: User
Tags install openssl http 2 keep alive

1. New Features of httpd-2.4

1) MPM supports loading at runtime;

-- Enable-MPMs-shared = all -- With-MPM = {prefork | worker | event}

2) event MPM supported

3) asynchronous read/write

4) use different log levels in each module and Directory

5) configuration of each request; <if>, <elseif>

6) Enhanced expression Analyzer

7) Keep Alive timeout in milliseconds

8) the FQDN-based VM no longer needs the namevirtualhost command;

9) supports User-Defined variables

10) added some modules: mod_proxy_fcgi, mode_ratelimit, mod_request, mod_remoteip

11) modified some configuration mechanisms. Order, allow, and deny are no longer supported to define IP-based Access Control. Change to require.

Ii. installation and configuration start

1. Resolve Dependencies
Install APR
[[Email protected] ~] # Cd apr-1.5.0
[[Email protected] apr-1.5.0] #./configure -- prefix =/usr/local/APR
[[Email protected] apr-1.5.0] # Make & make install

Install Apr-util
[[Email protected] ~] # Tar xf apr-util-1.5.3.tar.bz2
[[Email protected] ~] # Cd apr-util-1.5.3
[[Email protected] apr-util-1.5.3] #./configure -- prefix =/usr/local/APR-util -- With-Apr =/usr/local/APR/
[[Email protected] apr-util-1.5.3] # Make & make install

Install OpenSSL

Yum install OpenSSL-devel

2. Install HTTP 2.4.9
[[Email protected] ~] # Tar xf httpd-2.4.9.tar.bz2
[[Email protected] ~] # Cd httpd-2.4.9
[[Email protected] httpd-2.4.9] #. /configure -- prefix =/usr/local/apache24 -- sysconfdir =/etc/httpd24 -- enable-modules = most -- enable-so -- enable-Deflate -- enable-SSL -- enable-CGI -- enable-Rewrite -- With-Apr =/usr/local/APR/-- With-Apr-util =/usr/local/APR-util/-- With-MPM = event -- enable -MPMs-shared = all

[[Email protected] httpd-2.4.9] # Make & make install

3. Export binary files and help manual
Vim/etc/profile. d/Apache. Sh
Path =/usr/local/apache24/bin: $ path
./Etc/profile. d/Apache. Sh

Vim/etc/man. config
Manpath/usr/local/apache24/man

4. Provide Server Control Scripts:
[[Email protected] httpd24] # Cat/etc/init. d/httpd24
#! /Bin/bash
#
# Httpd24 STARTUP script for the Apache HTTP Server
#
# Chkconfig:-85 15

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

Httpd_lang =$ {httpd_lang-"C "}
Initlog_args = ""
Apachectl =/usr/local/apache24/bin/apachectl
Httpd =$ {httpd-/usr/local/apache24/bin/httpd}
Prog = httpd
Pidfile =$ {pidfile-/usr/local/apache24/logs/httpd. PID}
Lockfile =$ {lockfile-/var/lock/subsys/httpd}
Retval = 0
Stop_timeout =$ {STOP_TIMEOUT-10}

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 $ {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
}

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 [email protected]
Retval =$?
;;
*)
Echo $ "Usage: $ prog {START | stop | restart | condrestart | try-Restart | force-Reload | reload | status | fullstatus | graceful | help | configtest }"
Retval = 2
Esac

Exit $ retval

5. Implementation of Virtual Hosts and SSL
VM:
Vim/etc/http24/HTTP. conf

Note: DocumentRoot "/usr/local/apache24/htdocs"
Enable: Include "extra/httpd-vhosts.conf"

Vim/etc/http24/extra/httpd-vhosts.conf

<Virtualhost *: 80>
Serveradmin [email protected]
DocumentRoot "/web/vhosts/www1"
Servername www1.guoting.com
<Directory "/web/vhosts/www1">
Require all granted
</Directory>
Errorlog "logs/www1.guoting.com. error_log"
Customlog "logs/www1.guoting.com. access_log" common
</Virtualhost>

<Virtualhost *: 80>
Serveradmin [email protected]
DocumentRoot "/web/vhosts/www2"
Servername www2.guoting.com
<Directory "/web/vhosts/www2">
Require all granted
</Directory>
Errorlog "logs/www2.guoting.com. error_log"
Customlog "logs/www2.guoting.com. access_log" common
</Virtualhost>

##############################
Mkdir/web/vhosts/www1/-P
Mkdir/web/vhosts/www2/-P
Echo "Echo "

In the test client: Linux is used as an example:
Add Vim/etc/hosts:
172.16.10.9 www1.guoting.com www2.guoting.com

Start the service:
/Etc/init. d/httpd24 start

Start test:
Http://www1.guoting.com (Crul)

######################################## ##################################
Based on the previous step:
SSL:
######################################## #####################################
Vim/etc/http24/HTTP. conf

Enable: Include "extra/httpd-ssl.conf"
Loadmodule socache_shmcb_module modules/mod_socache_shmcb.so
Loadmodule ssl_module modules/mod_ssl.so

Of course, you can dynamically add MPM: (select Add)
Loadmodule mpm_event_module modules/mod_mpm_event.so

############ Create a certificate ########################## #####
On the server:
(Umask 077; OpenSSL genrsa-out/etc/pki/CA/private/cacert. Key 2048)
OpenSSL req-New-X509-key/etc/pki/CA/private/cakey. pem-out/etc/pki/CA/cacert. pem-days 1000
Touch index.txt
Echo "01"> serial

On the client:
(Umask 077; OpenSSL genrsa-out/etc/httpd24/httpd. Key 2048)
OpenSSL req-New-key/etc/httpd24/httpd. Key-out/etc/httpd24/httpd. CSR
Upload httpd. CSR to the server signature:

On the server:
OpenSSL ca-in/root/httpd. CSR-out/root/httpd. CRT-days 1000
Upload the signed certificate, httpd. CRT, to the client, and put it in the ETC/httpd24/directory.

######################################## ##########

Vim/etc/http24/extra/httpd-ssl.conf

# Add:
<Virtualhost *: 443>
DocumentRoot "/web/vhosts/www1"
<Directory "/web/vhosts/www1">
Options none
Require all granted
</Directory>
Servername www1.guoting.com: 443
Serveradmin [email protected]
Errorlog "/web/vhosts/www1/logs/error_log"
Transferlog "/web/vhosts/www1/logs/access_log"
Sslengine on
Sslcertificatefile "/etc/httpd24/httpd. CRT"
Sslcertificatekeyfile "/etc/httpd24/httpd. Key"
</Virtualhost>

<Virtualhost *: 443>
DocumentRoot "/web/vhosts/www2"
<Directory "/web/vhosts/www2">
Options none
Require all granted
</Directory>
Servername www2.guoting.com: 443
Serveradmin [email protected]
Errorlog "/web/vhosts/www2/logs/error_log"
Transferlog "/web/vhosts/www2/logs/access_log"
Sslengine on
Sslcertificatefile "/etc/httpd24/httpd. CRT"
Sslcertificatekeyfile "/etc/httpd24/httpd. Key"
</Virtualhost>

#######################
Mkdir/web/vhosts/www1/logs-P
Mkdir/web/vhosts/www2/logs-P

###################

Enter a test in the browser. Take Linux as an example:

Enter: https://www1.guoting.com, import certificate to access.

This article from the "cold" blog, please be sure to keep this source http://guoting.blog.51cto.com/8886857/1538388

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.