Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Httpd.conf--2.2

2025-02-25 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/02 Report--

Httpd version 2.2

[root@www conf] # grep "Section" httpd.conf

# Section 1: Global Environment

# Section 2: 'Main' server configuration

# Section 3: Virtual Hosts

1.Global Environment

ServerTokens

Purpose: this directive controls whether the response header field returned by server to the client includes a description of the common OS type of the server and information about the compilation module.

Available value: Major | Minor | minimum | ProdName [uctOnly] | OS | Full

Default value: ServerTokens OS

Test: ServerTokens Prod

ServerRoot "/ etc/httpd"

Function: the root directory of httpd, which contains configuration, error and and log files

PidFile run/httpd.pid

Function: the server records the files of the daemon pid, the relative path, relative to the root directory specified by ServerRoot

Timeout 60

Function: wait a specific amount of time before the request fails

KeepAlive Off

Function: whether long links are allowed. Default is no.

MaxKeepAliveRequests 100

Function: the maximum number of requests allowed for persistent connections

KeepAliveTimeout 15

Function: the amount of time that the server waits for subsequent requests on the persistent connection

MPM settings:

Three working models:

Prefork A request is responded by a process

Worker responds to a request with a single thread, starting multiple processes, each generating multiple threads. Tested on linux, worker is not ideal.

Event a process to handle multiple requests, version 2.2 is not recommended, testing. 2.4 can be used.

# if the mode is prefork.c, handle the following instructions

StartServers 8 # number of service processes to start

MinSpareServers 5 # minimum idle processes

MaxSpareServers 20 # maximum idle processes

Maximum MaxClients during the lifetime of the ServerLimit 256 # server

MaxClients 256 # maximum number of server processes allowed to be started

MaxRequestsPerChild 4000 # maximum number of requests served by a server process

Listen 80 listening port

Function: IP address and port on which the server listens

LoadModule loading module

Role: a link in an object file or library and added to the list of active modules

Include conf.d/*.conf

Role: include other profiles in the server profile

User apache

Role: the user who answered the request

Group apache

Role: the user group that answered the request

2.The Main'server configuration

ServerAdmin root@localhost

Purpose: the e-mail address that the server contains in the error message sent to the client

ServerName www.example.com:80

Function: identify the server by hostname [port]

UseCanonicalName Off

Purpose: configure how the server determines its own domain name

When set to "off", Apache uses the hostname and port provided by the client. When set to "on", Apache uses the value of the servername instruction.

DocumentRoot "/ var/www/html"

Purpose: make up the directory of the main document tree visible from the Web

Note: the path in URL is relative to the path specified by DocumentRoot.

Directory: access control mechanism for directories

Options FollowSymLinks

AllowOverride AuthConfig

Order allow,deny # here deny is the default. As long as it is not rejected, you can access the file under this / var/www/html.

# Note: order is used to define host-based access functions, which can be IP/ network address / hostname

Allow from all

AuthType Basic

AuthName "so..."

AuthUserFile "/ etc/httpd/conf/htpasswd"

Require user root

Where:

# options: configure the functions in a specific directory, which can be set to: ALL all functions | ExecCGI executable CGI | FollowSymLinks traceable symbolic link corresponding file | indexes returns the directory list list if the URL mapped to the directory has no DirectoryIndexes instruction specified Index.html or other |.

# AllowOverride allows files ending in .htaccess to override the following settings (Order, allow). Values: ALL can be overridden by .htaccess. | invalid NONE .htaccess setting | directive-type has AuthConfig control authorization specified | FileInfo controls document type | Indexes controls index type.

When AllowOverride AuthConfig, the available instructions AuthDBMGroupFile, AuthDBMUserFile, AuthGroupFile, AuthName, AuthType,AuthUserFile,Require user/group..

AuthType user authentication type, there are two types: Basic/Digest

AuthName Authorization realm for HTTP authentication

AuthUserFile sets the name of a text file that contains a list of users and passwords for authentication

Require which can be authenticated to access resources, available user + user name, group+ group name, valid-user all valid users

Testing process:

Actual code:

Options none AllowOverride AuthConfig Order allow,deny Allow from all AuthType Basic AuthName "test" AuthUserFile "/ etc/httpd/conf/htpasswd" Require user ding

Use htpasswd-c-m / etc/httpd/conf/htpasswd ding to create a file and set the access password for ding users

DirectoryIndex index.html index.html.var a.html

Function: when the client requests the directory, the resources found by default, set the default access page, when the set files exist, from left to right.

The name of the AccessFileName .htaccess distributed configuration file. If this directive is not set in the directory, the .htaccess file will be found in the directory and subdirectories.

# instructions for matching file names

Order allow,deny

Deny from all

Satisfy All

Location of TypesConfig / etc/mime.types # mime.types

Purpose: set the location of the mime type configuration file

If DefaultType text/plain # does not confirm what type it is, the default type value will be sent

HostnameLookups Off # enables DNS lookup on the client IP address, off is recommended

ErrorLog logs/error_log # error log path and file name

LogFormat "% h% l% u% t\"% r\ "% > s% b\"% {Referer} I\ "\"% {User-Agent} I\ "" combined # access log format and name % h client address% l login name of remote host% u time generated by user name% t log event on login website% r first line (method, resource, version number)% s status code > s last requested status code% b how many bytes was requested by referer from which page to here% user-agent browser type

CustomLog logs/access_log combined # access Log

ServerSignature On # configure footers on server-generated documents

Alias / error/ "/ var/www/error/" # maps URL to a file system location, using http:ip/error/ to access / var/www/error/index.html resources

ScriptAlias / cgi-bin/ "/ var/www/cgi-bin/" # maps URL to a file system location and specifies the target as a CGI script

Various configuration settings for IndexOptions FancyIndexing VersionSort NameWidth=* HTMLTable Charset=UTF-8 # directory indexes

DefaultIcon / icons/unknown.gif # icons displayed for files when no specific icons are configured

AddDefaultCharset On | Off | charset # default character set parameter to be added if the content type is text/plain or text/html, such as AddDefaultCharset UTF-8

AddType application/x-compress .Z # maps the given file extension to the specified content type

AddHandler type-map var # maps the file extension to the specified handler

AddOutputFilter INCLUDES .shtml # maps the file extension to the filter that will process the server response

3.Virtual Hosts

Why is there a virtual host? To realize a web site, you need a real-time online server on the operating system and resources. For small websites, you only need to be online, and a physical host is a waste of resources.

Apache serves different sites through the same physical host.

Virtual host: based on IP, based on port, based on domain name.

NameVirtualHost *: 80 specify the IP address of the virtual host

NameVirtualHost *: 80 ServerAdmin www@1.com DocumentRoot / data/www/ ServerName www.1.com ErrorLog logs/www-error_log CustomLog logs/www-access_log combined DirectoryIndex index.html Options FollowSymLinks AllowOverride none Order allow Deny Allow from all ServerAdmin www@1.com DocumentRoot / data/ftp/ ServerName ftp.2.com ErrorLog logs/ftp-error_log CustomLog logs/ftp-access_log combined Options indexes AllowOverride AuthConfig AuthType Basic AuthName "1" AuthUserFile "/ data/Auth/ps" Require valid-user

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report