"I'm the master of my technology." Apache HTTPD Web server detailed

Source: Internet
Author: User
Tags http authentication md5 encryption

I. INTRODUCTION

Apache is the world's most used Web server software. It can run on almost all widely used computer platforms and is one of the most popular Web server-side software due to its widespread use across platforms and security. Apache HTTP Server is a modular server that originates from the NCSAHTTPD server. Apache is characterized by simple, fast, stable performance and can be used as a proxy server.

Apache Official website: http://apache.org/

Apache httpd Website: http://httpd.apache.org/

Apache httpd Web Server features

1. Create a process beforehand

2. Module diversification, the addition of various function modules

3. Can support SSL technology

4. Support Virtual host configuration in multiple ways

The common configuration of virtual host is mainly divided into:

IP-based virtual host

Port-based virtual host

Domain-based virtual host

5. Support HTTP authentication in multiple ways

6. Support URL rewriting, and many other features

Two. HTTPd installation method

The main installation methods are divided into two types: one for RPM package installation, the other for the source package installation

When you install the HTTPD package, you are now in permssive or disabled, or some services may not start

Modify the SELinux configuration file/etc/selinux/config, modify "Selinux=permssive"

650) this.width=650; "title=" capture. PNG "alt=" wkiol1xdzm6wuj-maafwdv_4afo800.jpg "src=" http://s3.51cto.com/wyfs02/M01/71/01/wKioL1XDZM6wuj-MAAFWDV_ 4afo800.jpg "/>

HTTPD Package Installation: Yum-y install httpd (yum build not much to say, you can see this blog, yum source build)

three. httpd port, Directory introduction

httpd default port is tcp/80 port, SSL protocol port is 443/TCP port

The default root directory for httpd work is/ETC/HTTPD

The configuration file directory for HTTP is/etc/httpd/conf

HTTPD Master profile to httpd.conf file

Configuration files ending with/etc/httpd/conf.d/*.conf are part of the master configuration file for httpd.conf

Apache httpd Modular Directory for/etc/httpd/modules

Apache httpd log directory for/etc/httpd/logs-->/var/log/httpd point to/var/log/httpd directory file

Log file is divided into: Access log access_log, error log err_log two kinds

Apache httpd web directory for/var/www directory

The/var/www directory is divided into HTML directories and Cgi-bin directories: HTML directories are developed for static web directories such as HTML languages;

The Cgi-bin directory is a website program developed for dynamic web directories such as Asp,php,jsp,java.

Introduction to CGI:

Common Gateway Interface, referred to as CGI. Is physically a program that runs on the server and provides an interface to the client's HTML page. CGI is an interface between an external application (CGI program) and a Web server that allows the Web server to execute external programs and send their output to a Web browser, and CGI turns a simple set of static hypermedia documents from the Web into a complete new interactive media.

Four. httpd master configuration file/etc/httpd/conf/httpd.conf detailed

# # # section 1:global Environment global configuration
ServerRoot "/etc/httpd" httpd Server root directory

Pidfile run/httpd.pid httpd service process PID, saved in Httpd.pid file
KeepAlive off whether long links are enabled "On or off" can effectively improve performance by using long connections

Maxkeepaliverequests 100 The maximum number of resources a user requests after a long connection is enabled, 0 means unlimited requests

KeepAliveTimeout 15 long-connection disconnects often

# Prefork MPM multi-processing module

MPM_WINNT multithreading mechanism under windows;

Prefork Linux pre-generated process processing mechanism, a request with a process to respond;

Worker multiple threads processing, one request a thread to respond;

Event a process handles multiple requests

You can use the Httpd-l command to view the MPM processing modules currently supported by Linux
httpd server by default using the Worker processing module, if you change the other processing module can modify the HTTPd startup script to implement, httpd startup script configuration file for/etc/sysconfig/httpd, modify the configuration file #httpd=/usr/sbin/ Httpd.worker

<ifmodule prefork.c>
Startservers 8 Starting 8 idle processes at server startup
Minspareservers 5 Minimum Idle 5 processes accept user requests
Maxspareservers 20 Max Idle Process
Serverlimit 256 Specifies the maximum limit for maxclients, modified when the current server must shut down the server kill all processes in the restart
MaxClients 256 Maximum number of clients, up to 256 clients at a time, not exceeding the serverlimit limit
Maxrequestsperchild 40,001 processes to respond up to 4,000 user requests
</IfModule>
<ifmodule worker.c>
Startservers 4 Starting 4 processes on server startup
MaxClients 300 Maximum number of clients, allowing up to 300 clients to request at a time
Minsparethreads 25 min Idle thread
MAXSPARETHREADS 75 Max Idle thread
Threadsperchild 25 Each process generates 25 threads
Maxrequestsperchild 0 Do not make qualified user requests
</IfModule>

#Listen 12.34.56.78:80

Listen httpd Server default listener port 80, can listen to multiple ports at the same time
Listen 8080 or 127.0.0.1:8080

# # # 2: ' Main ' server configuration server Master

ServerAdmin [email protected] server administrator

ServerName www.example.com:80 Server Name

DocumentRoot "/var/www/html" Web site document root directory, you can directly modify the directory path

To modify the default WWW document root directory, you must define whether <directory/>apache services and features are allowed and accessed

You can also modify the directory in the corresponding configuration file <directory "/var/www/html" >.

Custom <directory/>, format as follows
<directory/>
Options FollowSymLinks
AllowOverride None
</Directory>

Options option Parameters

# Possible values for the Options directive is "None", "all",
# or any combination of:
# Indexes includes followsymlinks symlinksifownermatch execcgi multiviews
#
# Note that "MultiViews" must is named *explicitly*---"Options all"
# doesn ' t give it to you.
#
# The Options directive is both complicated and important. Please see
# http://httpd.apache.org/docs/2.2/mod/core.html#options
# for more information.
#
Options Indexes FollowSymLinks

Indexes Index Site Directory, Indexes not enabled in Web site security

None does not support any options

FollowSymLinks allows the source file to which the symbolic link points

Includes allows execution of server-side include SSI

ExecCGI allowed to run

MultiViews Multi-view mode, consuming resources

All supports all options

allowoverride parameters

# AllowOverride Controls What directives is placed in. htaccess files.
# It can be ' all ', ' None ', or any combination of the keywords:
# Options FileInfo authconfig Limit

AllowOverride None allows overriding server control access list

Authconfig user authentication, provide user account password to provide login

Order: An IP, network address, or host-defined access control that defines the host-based access function

Example: If a website does not want to be accessed by 192.168.100.1 and 192.168.100.4 two IP addresses how do I configure order?

AllowOverride None
Order Deny,allow
Deny from 192.168.100.1 192.168.100.4

httpd-t Detect configuration file syntax is correct

Plain Text Browser ELinks 127.0.0.1

Elinks-dump 127.0.0.1 Open the website and exit directly

Elinks-source 127.0.0.1 Display website source code

The following: Based on user authentication, local Baishouqijia, from scratch, zhang,3 users must enter the account password to access the site, otherwise inaccessible, how to do? The configuration file is as follows

650) this.width=650; "title=" QQ picture 20150808232932.jpg "alt=" wkiom1xgiwaa5awpaak6zy5a5os699.jpg "src="/http S3.51cto.com/wyfs02/m02/71/1e/wkiom1xgiwaa5awpaak6zy5a5os699.jpg "/>

Create a user account password in htpasswd

[Email protected] httpd]# htpasswd-c-m/etc/httpd/htpasswd Baishouqijia
[Email protected] httpd]# htpasswd-m/etc/httpd/htpasswd from scratch
[Email protected] httpd]# htpasswd- m /etc/httpd/htpasswd Zhang
[Email protected] httpd]# httpd-t
[Email protected] httpd]#/etc/init.d/httpd restart
[Email protected] httpd]#
-m option MD5 encryption method

-C option to create the htpasswd file, use when creating the first user, add-C to the second user, or recreate the htpasswd file and replace the file created the first time the user was added

Test:

Start Login Prompt Enter account password

650) this.width=650; "title=" 1.png "style=" Float:none; "alt=" wkiom1xgi7uzuhr8aag9p9yukhy116.jpg "src=" http:/ S3.51cto.com/wyfs02/m00/71/1e/wkiom1xgi7uzuhr8aag9p9yukhy116.jpg "/>

After entering your account password

650) this.width=650; "title=" 2.png "style=" Float:none; "alt=" wkiom1xgi7ysirlfaadkv3rguzw002.jpg "src=" http:/ S3.51cto.com/wyfs02/m00/71/1e/wkiom1xgi7ysirlfaadkv3rguzw002.jpg "/>


Delete User htpasswd-d

directoryindex index.html index.html.var Home index file, if a Web site program is included, start from left to right index

Errorlog logs/error_log Error Log directory
LogLevel warn log level

Logformat "%h%l%u%t \"%r\ "%>s%b \"%{referer}i\ "\"%{user-agent}i\ "" combined
Logformat "%h%l%u%t \"%r\ "%>s%b" common
Logformat "%{referer}i,%u" Referer
Logformat "%{user-agent}i" Agent
%H Client Address

%l Remote Host login name

%u login user name when you log in to the Web site

%t the time the log was generated

%r the first line of the request message

%>s status code for the last request

Size of the%B response message

%{referer}i website Source

%{user-agent}i Type of client browser

alias/icons/"/var/www/icons/" path alias

to create a index.html under/mnt/www/bbs and use an alias/bbs access

650) this.width=650; "title=" Qq20150809010310.png "alt=" wkiol1xgohgsncmaaalathaheza549.jpg "src="/HTTP/ S3.51cto.com/wyfs02/m02/71/1a/wkiol1xgohgsncmaaalathaheza549.jpg "/>

Test:

650) this.width=650; "title=" Qq20150809010310.png "alt=" wkiol1xgooyty7hsaadbpktryle704.jpg "src="/HTTP/ S3.51cto.com/wyfs02/m02/71/1a/wkiol1xgooyty7hsaadbpktryle704.jpg "/>


"51cto 10 Anniversary Blog Activity " is in progress, you also come to participate in it ~

Event Address :http://51ctoblog.blog.51cto.com/26414/1679643


This article is from a "self-made" blog, be sure to keep this source http://baishouqijia.blog.51cto.com/2580498/1683080

"I'm the master of my technology." Apache HTTPD Web server detailed

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.