Home > Backend Development > PHP Tutorial > APACHE2_PHP Tutorial

APACHE2_PHP Tutorial

WBOY
Release: 2016-07-13 17:29:17
Original
1000 people have browsed it

Chapter 2 Starting Apache 2.1 Starting Apache httpd This program can be started by the Internet service program inetd every time there is a connection to enter the HTTP service, or alternatively, it can also be used as a service The program (daemon) continues to execute and handle requests. No matter which method is chosen, the ServerType directive must be set to tell the server how it wants to perform. 2.2 Command line options The following options can be used on the httpd command line: -d serverroot sets the starting value of the ServerRoot parameter to serverroot. This can be changed via the ServerRoot command in the configuration file. The default is /usr/local/etc/httpd . -f config executes the instructions in the config file at startup. If config does not start with /, it will be treated as a path relative to the ServerRoot. The default value for this is conf/httpd.conf . -X executes in single-process mode and is only used for internal debugging; the service program will not leave the terminal operation or generate any subroutines. Do not use this mode to serve normal web pages. -v prints httpd's version and exits. -? Print a list of httpd options and exit. 2.3 Configuration files This server will read three configuration directive files. Any directive can appear in any of these files. The names of these files are relative to the server root; this is the root specified with the ServerRoot directive or the -d command-line flag. By convention these files are: conf/httpd.conf Contains instructions for controlling the operation of the server program. The file name can be changed with the -f command line flag. conf/srm.conf contains directives that control the file specifications that the server provides to clients. The file name can be changed with the ResourceConfig directive. conf/access.conf contains directives that control access to files. The file name can be changed with the AccessConfig directive. However, these conventions do not need to be followed. The server also reads a file containing MIME file types; the file name is set with the TypesConfig directive and has conf/mini.types as the default. 2.4 Log file 2.4.1 pid file When the service program starts, it saves the program code (process id) of the parent program httpd to the log/httpd.pid file. This file name can be changed with the PidFile command. This code is used by the administrator to restart or terminate the service; a HUP signal causes the service to reread its configuration file and a TERM signal causes it to terminate. If the program dies (or is killed) abnormally, the httpd subroutine must be killed. 2.4.2 Error logging The server will log error messages to a log file, the default is log/error_log. The file name can be set through the ErrorLog command; different error records can be set for different virtual hosts. 2.4.3 Transmission record The server will generally log each request to a transmission file, which is logs/access_log by default. The file name can be set through the TransferLog command; different transfer records can be set for different virtual hosts. Chapter 3 Apache Core Features These configuration parameters control core Apache features and are permanently available. 3.1 AccessConfig command Syntax: AccessConfig file name Default: AccessConfig conf/access.conf Used for: server config, virtual host Status: Core After this server reads the ResourceConfig file, it will continue to read this file to obtain more instructions. File names are relative to the ServerRoot path. This feature can be turned off using: AccessConfig /dev/null Originally this file only contained the section; in fact it can now contain any directive that can be used for server configuration. 3.2 AccessFileName command syntax: AccessFileName Default file name: AccessFileName .htaccess Used for: server config, virtual host Status: When the core returns the file to the client, if the access control file of the directory is enabled, the server will arrive at this file Search for access control files with this name in every directory in the path. For example: AccessFileName .acl Before returning the file /usr/local/web/index.html, the server will read /.acl, /usr/.acl, /usr/local/.acl and /usr/ local/web/.acl to get directives, unless they are turned off as follows: AllowOverride None 3.3 AllowOverride directive syntax: AllowOverride override override ... Default: AllowOverride All Used for: directory Status: Core Server When finding the file specified by AccessFileName, you need to know which commands declared by the file can change the earlier access information.Override can be set to None, in which case the server will not read the file, and set to All, the server will allow all commands, or one of the following: AuthConfig allows the use of authentication commands (AuthDBMGroupFile, AuthDBMUserFile, AuthGroupFile, AuthName, AuthType, AuthUserFile and require) FileInfo allows the use of directives that control file types (AddEncoding, AddLanguage, AddType, DefaultType and LanguagePriority) Indexes allows the use of directives that control directory indexing (AddDescription, AddIcon, AddIconByEncoding, AddIconByType, DefaultIcon , DirectoryIndex, FancyIndexing, HeaderName, IndexIgnore, IndexOptions and ReadmeName) Limit allows the use of commands that control access to the host (allow, deny and order) Options allows the use of commands that control the characteristics of specific directories (Options and XbitHack) 3.4 AuthName command syntax: AuthName Authentication field for: directory, .htaccess Requirements: AuthConfig Status: Core This command sets the name of the authentication field for a directory. This field is sent to the client so the user knows the username and password to send. It must be done through the AuthType and require directives, and must work in conjunction with directives like AuthUserFile and AuthGroupFile. 3.5 AuthType directive Syntax: AuthType type Used for: directory, .htaccess Requirements: AuthConfig Status: Core This directive selects the authentication type for a directory. Currently only Basic is implemented. It must be done through the AuthName and require directives, and must be combined with directives like AuthUserFile and AuthGroupFile. 3.6 BindAddress command syntax: BindAddress Server address default: BindAddress * Used for: server config Status: core A Unix http server can monitor the connection of each IP address of the service machine or only pay attention to one of the service machine address. The server address can be: . *. an IP address . A complete Internet domain name. If this value is *, then the server will listen for connections from every IP address, otherwise it will only listen to the specified IP address. This option can be used as an alternative to support virtual hosting in place of the section. 3.7 DefaultType command syntax: DefaultType mime-type default: DefaultType text/html Used for: server config, virtual host, directory, .htacess Requirements: FileInfo Status: Core Sometimes the server will be asked to provide a certain file, and this file cannot The type is determined by its MIME type mapping. The server must tell the client the type (content-type) the file contains, so it uses DefaultType when it does not know the type. For example: DefaultType image/gif is appropriate for a directory containing many gif graphics without a .gif extension. 3.8 command syntax: ... used for: server config, virtual host status: core and are used to wrap a set of commands, which will only apply to all on the specified directory and its subdirectories. Any directive that can be used with directory can be used. Directory is the full path to a directory, or a widecard string. In a substitution string, `? can match any single character, and `* can match a number of characters in any order. For example: Option Indexes FollowSymLinks If there are multiple directory sections that match the directory containing the file (or its parent directory), then the directives distributed in the .htaccess file are applied in the order of shortest first. For example: AllowOverride None AllowOverride FileInfo The steps to access /home/web/dir/doc.html this document are: . Use AllowOverride None directive (turn off .htaccess file). . Apply the AllowOverride FileInfo directive (directory /home/web ). . Apply any FileInfo directives in /home/web/.htaccess. This directory section is typically used in access.conf files, but they can appear in any configuration file. Commands cannot be nested and cannot appear in sections. 3.9 DocumentRoot command Syntax: DocumentRoot directory name Default: DocumentRoot /usr/local/etc/httpd/htdocs Used for: server config, virtual host Status: core This command configures httpd to provide file services from this directory. Unless directives like Alias ​​are met, the server appends the requested URL to the document root to assemble the path to the file. For example: DocumentRoot /usr/web In this way, access to the http://www.my.host.com/index.html file will refer to /usr/web/index.html. 3.10 ErrorDocument command syntax: ErrorDocument error code file is used for: server config, virtual host status: When there is a core problem or an error occurs, Apache can be configured to do four reactions 1. The same as the reaction of NCSA httpd 1.3 2. Output from 3. Redirect to a local URL to handle the problem/error 4. Redirect to an external URL to handle the problem/error 2-4 are configured using ErrorDocument, followed by HTTP response code and message or URL.ErrorDocument 500 /cgi-bin/tester ErrorDocument 404 /cgi-bin/bad_urls.pl ErrorDocument 401 http://www.foo.bar/subscription_info.html ErrorDocument 403 "Sorry can't allow you acess today See: Custom response files. 3.11 ErrorLog command syntax: ErrorLog file name default: ErrorLog logs/error_log used for: server config, virtual host status: core This error logging command sets the file name, and the server will log every error it encounters to this file . If the file name does not start with / then it is assumed to be a path relative to the ServerRoot. For example: ErrorLog /dev/null This will effectively turn off error logging. 3.12 Group command syntax: Group unix-group default. : Group #-1 for: server config status: core This Group command sets the group in which the server responds to requests. In order to use this command, a standalone Unix-group must be started as root. Can be one of these:

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/531696.htmlTechArticleChapter 2 Start Apache 2.1 Start Apache httpd This program can be used through the Internet service program inetd is started every time there is a connection to enter the HTTP service, or another...
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template