1.HTTPD Introduction
Today's mainstream open source Web server software has httpd (Apache), lighttpd,nginx,thttpd, and so on, and httpd is so far the use of a lot of Web servers, according to statistics, the current HTTPD global share is about 47%, Although there is a decrease but the use of two is still the most, statistics Web server usage rate of the website is: http://news.netcraft.com/
httpd work principle: HTTPD is the Apache Hypertext Transfer Protocol (HTTP) server main program, is designed as a stand-alone running background process, it will establish a processing request of the child process or thread pool.
Typically httpd should not be called directly, but should be called by Apachectl in a Unix-like system and run as a service in Windows.
Version of 2.HTTPD
httpd-1.3httpd-2.0httpd-2.2httpd-2.4目前为止最新的版本是httpd-2.4.6,但是这里我用的是系统自带的RPM包安装的httpd-2.2.15版本的,最新版本配置可能会有所不同 本文主要介绍httpd的两大版本,httpd-2.2和httpd-2.4。 CentOS6系统的版本默认提供的是httpd-2.2版本的rpm包 CentOS7系统的版本默认提供的是httpd-2.4版本的rpm包
3.HTTPD Working Model
高度模块化:DSOMPM:Multipath Processing Module #多处理模块prefork:一次一个进程响应一个请求worker:一个进程生成多个线程,一个线程响应一个请求event:基于事件驱动,一个进程响应多个请求
4.HTTPD Self-brought tool program
Tools |
function |
htpasswd |
Basic Authentication in the file implementation, the use of the Account password generation tool |
Apachectl |
HTTPD comes with a service control script that supports Start,stop,restart |
Apxs |
Tools provided by the Httpd-devel package that extend the httpd use of third-party modules |
Rotatelogs |
Log Scrolling Tool |
suEXEC |
Temporarily switch to a user-run tool when accessing certain resources with special permissions configuration |
Ab |
The Apache BENCHMARK,HTTPD Stress test Tool |
HTTPD program Environment for 5.RPM package installation
Files/Directories |
the corresponding function |
/var/log/httpd/access.log |
Access log |
/var/log/httpd/error_log |
Error log |
/var/www/html/ |
Site Documentation Directory |
/usr/lib64/httpd/modules/ |
Module file path |
/etc/httpd/conf/httpd.conf |
Master configuration file |
/etc/httpd/conf.modules.d/*.conf |
Module configuration file |
/etc/httpd/conf.d/*.conf |
Secondary configuration files |
6.HTTPD Common Configuration
#切换使用MPM (edit/etc/httpd/conf.modules.d/00-mpm.conf file)
LoadModule Mpm_name_module modules/mod_mpm_name.so
There are three types of name, namely:
Prefork
Event
Worker
Access control rules:
Law |
function |
Require all granted |
Allow all hosts to access |
Require all Deny |
Deny all host access |
Require IP ipaddr |
Authorize host access to the specified source address |
Require not IP ipaddr |
Deny host access to the specified source address |
Require Host HOSTNAME |
Authorize host access for the specified source host name |
Require not host HOSTNAME |
T denies host access to the specified source host name |
Note: The httpd-2.4 version defaults to deny access to all hosts, so the installation must be done to display authorized access later
Example:
<RequireAll>
Require not IP 192.168.1.20
Require all granted
</RequireAll>
There are three types of virtual hosts:
1. Different ports of the same IP
2. Same port with different IP
3. Same IP same port different domain name
7. Compile and install httpd-2.4 (the following instance is a compiled installation, same IP same port different domain name)
httpd dependent on Apr-1.4+,apr-util-1.4+,[apr-icon]
Install the development environment [[email protected] ~]# yum groups mark Install "Development Tools" [[email protected] ~]# groupadd-r Apache [[email protected] ~]# useradd-m-s/sbin/nologin-g apache Apache [[email protected] ~]# Yum-y Inst All Openssl-devel pcre-devel expat-devel libt ool//download and install apr-1.4+ and apr-util-1.4+ [[email protected] ~]# CD/USR/SR c/[[email protected] ~]# wget http://mirrors.shu.edu.cn/apache//apr/apr-1.6.3.tar.bz2 [[email protected] ~]# wget http://mirrors.shu.edu.cn/apache//apr/apr-util-1.6.1.tar.bz2 [[email protected] ~]# Tar XF apr-1.6.3.tar.bz2 [[email protected] ~]# tar xf apr-util-1.6.1.tar.bz2 [[email protected] ~]# CD apr-1.6.3 [[E Mail protected] ~]# vim Configure # $RM "$cfgfile"//Add this line with a comment, or delete this line [[Email protecte D] ~]#./configure--PREFIX=/USR/LOCAL/APR configuration process skipped ... [[email protected] ~]# make && make install compile installation process slightly ... [[email protected] ~]# cd/usr/src/apr-util-1.6.1 [[email protected] ~]#./configure--prefix=/usr/local/apr-util--with-apr=/usr/local/ Apr [[email protected] ~]# make && make install//compile installation httpd [[email protected] ~]# CD [[EMAIL&NBSP;PR Otected] ~]# wget http://mirror.bit.edu.cn/apache//httpd/httpd-2.4.34.tar.bz2 [[email protected] ~]# Tar XF httpd-2.4.34.tar.bz2 [[email protected] ~]# CD httpd-2.4.34 [[email protected] ~]#./configure--prefix=/u Sr/local/apache--sysconfdir=/etc/httpd24--enable-so--enable-ssl--enable-cgi--enable-rewrite--with-zlib--with -pcre--with-apr=/usr/local/apr--with-apr-util=/usr/local/apr-util/--enable-modules=most--enable-mpms-shared= All--with-mpm=worker [[email protected] ~]# making && make install installation process slightly ...//set hostname [[email& Nbsp;protected] ~]# vim/etc/httpd24/httpd.conf #ServerName www.example.com:80//Cancel #//In the last line add a bit of content, the following is the same IP to configure the same port different domain name , direct access to the domain name [[email protected] ~]# vim/etc/httpd24/httpd.conf <virtualhost 192.168.209.12:80> ServerName www.wangqing.com documentroot "/usr/local/apac He/htdocs/lan "errorlog" Logs/lan/error_log "Customlog" Logs/lan/access_log "combined <directory"/usr/local/apac He/htdocs/lan "> <RequireAll> Require All granted </RequireAll> </Directory> < /virtualhost> <virtualhost 192.168.209.12:80> ServerName www.lanzhiyong.com documentroot "/usr/local/a Pache/htdocs/yong "errorlog" Logs/yong/error_log "Customlog" Logs/yong/access_log "combined <directory"/usr /local/apache/htdocs/yong "> <RequireAll> Require all granted </RequireAll> </direc Tory> </VirtualHost>//Create a log directory for the corresponding page [[email protected] ~]# Mkdir/usr/local/apache/logs/{lan,yon g} [[[email protected] ~]# chown-r apache.apache/usr/local/apache/logs//Create a Web directory and modify the genus group [[Email protec Ted] ~]# cd/usr/local/apache/htdocs/[[email protected] htdocs]# mkdir LAN Yong [[email protected] htdocs]# chown-r Apache.apach e LAN [[email protected] htdocs]# chown-r Apache.apache Yong//Create Web page [[email protected] htdocs]# pwd /usr/local/apache/htdocs [[email protected] htdocs]# echo ' Hello Welcome to visit LAN ' > lan/index.html [[email protected] htdocs]# echo ' Hello Welcome to visit Yong ' > yong/index.html//Start httpd Service 80 port [[E Mail protected]]# cd/usr/local/apache/bin [[email protected] bin]#./apachectl Start//See if Port 80 is started [[email protected] bin]# ss-antl//verify ****** input www.wangqing.com********* on the browser
*******输入www.lanzhiyong.com********
Linux Detailed construction httpd website construction Service (Apache)