Description of httpd. conf configuration options

Source: Internet
Author: User
Description of httpd. conf configuration options the following describes the meanings of some of the most important configuration options, so that you can use minimum energy and minimum configuration.
Prepare the server.

Httpd. conf

TPD. conf is the main configuration file. It tells the server how to run it.

1. servertype standalone | inetd

This configuration option specifies how to run the web server. Apache can run Server Load balancer in two ways.
Server: Standalone (independent) and inetd (run by inetd ). Standalone Parameter
The Web service process listens for client requests in the background in the form of a separate waiting process, such
If yes, a sub-process is generated to serve the sub-process. The inetd parameter indicates that the Web service is not a separate
Supported by the waiting process. Instead, the super server inetd waits for the process to do the necessary work.
When sending a web service request to a client, start another Web service process to serve the client. Slave
The two methods are almost the same. But there is a big difference between them.
Server performance. A server process running by inted ends the request service at the same time
Exit immediately. In standalone mode, when the sub-WWW server process is suspended for a period before exiting
This provides them with the opportunity to serve new requests again.

In standalone mode, there is no overhead for starting a new process for each request, so it is more efficient
High, while the inetd mode is considered to be more secure than the standalone mode.

Standalone mode:

In this mode, the WWW server listens for connection requests from specific ports. When the client sends data to a specific port location
The master server process starts the WWW Service process to serve the request. In addition
Tell the master server process the specific port address to listen to, use the command:

Port [number] (default value: 80)

Inetd Mode

Inetd is an Internet daemon that listens to connection requests from ports smaller than 1024.
). Different from the preceding method, when the client system sends a connection request to the WWW server, inetd
Start a WWW server process, and the process serves this request. After the service is completed, it exits. If you select
To run Apache through the inetd server, you need to edit the/etc/inetd. conf file to add
A new record:

Httpd stream tcp Nowait httpd/etc/httpd/bin/httpd-F
/Etc/httpd/CONF/httpd. conf

After modifying the/etc/inetd. conf file, you need to add a line in/etc/services.

Httpd 80/tcp httpd

After the preceding modification, You need to restart the inetd process. First, use the following command to obtain
Process ID:

PS auxw | grep inetd

Then run the command: kill-HUP <inetd process ID>

In RedHat Linux, the inetd server is used by default to run Apache.
When httpd is selected, the above work has been completed on your behalf during installation.

Ii. Other configuration options

The server admin command is used to set the e-mail address of the web administrator. This address will appear in
When a system connection error occurs, the visitor can promptly notify the web administrator of the problem.

Command Format: Server Admin [you e-mail address]

Example: Server Admin admin@xxx.com

The errorlog command is used to specify the name and path of the error record file.

Command Format: errorlog [log filename]

Example: errorlog/var/httpd/error. Log

Timeout command, as long as the number of seconds specified by the client has not completed a request, the Service
The client will terminate the request service. If the network speed is slow, we recommend that you set a large value here.
To give the client more opportunities.

Command Format: timeout [second]

Example: timeout 120

Serverroot command, which specifies where to save server configurations, errors, and log files.

Command Format: serverroot [fully qualified path name]

Example: serverroot/etc/httpd

Servername command, which configures the server's Internet host name

Command Format: servername [host name]

Example: servername www.xxx.com

SRM. conf

SRM. conf is the resource configuration file used to tell the server what resources you want to provide on the WWW site
And where and how to provide them.

The DocumentRoot command is used to specify the address of the main document.

Command Format: DocumentRoot [path]

Example: DocumentRoot/home/httpd/html

The userdir command is used to specify the location of the personal homepage. If you have a user named test
The directory is "/home/test". When the client inputs "http: // yourdomain /~ Test ";, the system
It will be searched in the corresponding directory "/home/test/userdir. "Userdir" is in
Specify the directory set in the userdir command.

Command Format: userdir [path]

Example: userdir public_html

The directoryindex command is used to declare the name of the home page file. Generally, we use
"Index.html" or "index.htm" as the homepage file name. If this is the case, the client
When a web service request is sent, will the first incoming home page be in the specified directory below? Quot1_index.html "or
"Index.htm ".

Command Format: direcotryindex [filename]

Example: direcotryindex index.html index.htm

The ScriptAlias command is used to create an alias for the script program directory. For details, see section 4.7.

Command Format: ScriptAlias [/alias/] [fullly qualified path for script
Directory]

Example: ScriptAlias/cgi-bin // home/httpd/cgi-bin

Access. conf configuration

The access. conf file is used to set access permissions for files, directories, and script projects on the WWW site.
The uncommented part of the First Section of the file is as follows:

<Directory/home/httpd/html>

Option indexes includes execcgi followsymlink

AllowOverride none

Order allow, deny

Allow from all

</Directory>

You should note that this part starts with <directory/home/httpd/html>
</Directory>. This indicates that the content in the center is for the specified directory
& #0; & #0; "/home/httpd/html.

1. The option command has many parameters. The meaning of each parameter is as follows:

All allow all of the following functions (except Multiviews );

Multiviews: Multiviews that allow content negotiation;

If no index file exists in the directory, indexes allows you to display the files in the directory for selection;

IncludesNOEXEC allows SSI (server-side supported des) but is not available # exec and
# Include function;

Supported des allows SSI;

Followsymlinks allows symbols to be linked to other directories;

Execcgi allows CGI to be used in this directory.

2. the AllowOverride command is used to determine whether to allow setting in the "access. conf" File
Whether the permission can be overwritten by the permissions set in the file ". htaccess. It has two parameters:

All is allowed;

None is not allowed to be overwritten.

3. Order command: Used to set who can get control from this server. It also has two parameters:

Allow can achieve control;

Deny prohibits access control.

Now let's take a look at the definition of the "/home/httpd/html" directory settings:
Directory. If no index.htm file exists, list the directory information for selection. ssi and
Run the CGI program and enable the dynamic connection. It cannot be set in the file ". htaccess ".
Overwrite the permissions set here. This allows everyone to gain control.

The second part of the file is not annotated as follows:

<Directory/home/httpd/cgi-bin>

Option execcgi

AllowOverride none

</Directory>

This indicates that the "/home/httpd/cgi" directory is set to run CGI programs in the current directory. No
Allow the permission set in the file ". htaccess" to overwrite the permission set here.

It should be noted that the information displayed in this file is incomplete in different Linux systems.
Same, but according to the information provided here, you can refer to the Command explanation to understand the settings in the file
And modify the settings as needed.

4.4 make the new configuration take effect

In the above section, we may have changed the corresponding configuration options based on new requirements. If we want
This new configuration takes effect immediately. We must restart the Web service process. In Linux, we
You can use the command line to restart the Web service process.

/Etc/rc. d/init. d/httpd restart

5. Open up personal homepage space for users

If we use the Linux system to set up a Web server, we can not only store
And provide a personal homepage space for every employee of the company.

First, open an account on Linux for employees who need personal homepage space. In this way, it has
A user's home directory "/home/user account name ".

Addusr User Account Name

Passwd User Account Name

Create a directory "public_html" in the user's home directory and set the corresponding permissions for it.

Cd ~ User Account Name

Mkdir public_html

Chmod 755 public_html

Make sure that the userdir command in the SRM. conf file sets the public_html directory. Allow employees
Upload your personal homepage to the public_html directory in your home directory.

Now you can use http://www.company.com /~ User Account Name "to access the employee's personal master
Page.

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.