Linux Apache Web Server (continued) _ Server

Source: Internet
Author: User
Before we go into specifics, we have to tell you that Apache has already used a series of defaults at the time of installation and has already run the WWW server. All you need to do is connect the Linux+apache host to the Internet, and then store the home page in the "/home/httpd" directory.

Here are some of the most important configuration options that you can use to prepare your servers with minimal effort and minimal configuration.

4.1 httpd.conf

Httpd.conf is the primary configuration file. It tells the server how it will run.

First, the most important configuration options ServerType Standalone | inetd

This configuration option specifies how to run the Web server. Apache can use two methods to transport

Row servers: Standalone (standalone) and inetd (run by inetd).

The standalone parameter indicates that the Web service process listens in the background with a separate waiting process to see if there is a client's request, and if so, generates a child process to serve it.

The inetd parameter indicates that the Web service is not supported in the form of a separate waiting process. Instead, it is done by inetd, the super server waiting process, when it receives a client's Web service request, and then starts a Web service process to serve it.

From a functional point of view, the two approaches are almost identical. But there is a real difference between them, and the difference is in the performance of the server. A server process run by inted exits immediately at the end of the request service. In standalone mode, the sub-WWW server process hangs up for a period of time before exiting, giving them the opportunity to reuse the service for new requests.

In standalone mode, there is no overhead for starting a new process on each request, so it is more efficient, and inetd mode is considered more secure than standalone mode.


Standalone mode:

In this mode, the WWW server listens for connection requests for a specific port. When the client sends a special



When a connection request for a port address is made, the primary server process initiates the child WWW service process to service the request. As shown in the following illustration:



Figure 2 Standalone servers


You also need to tell the main server process to listen for a specific port address, using the command:

Port [number] (default value is 80)


inetd mode



inetd is an Internet daemon (a server process) that listens for port connection requests that are less than 1024. Unlike the previous approach, when a client system issues a connection request to the WWW server, inetd initiates a WWW server process that services the request and exits after the service completes. As shown in the following illustration:



Figure 3 Server started by inetd


If you choose to run Apache through the inetd server, you need to edit the/etc/inetd.conf file to add a new record for Apache:

httpd Stream TCP nowait httpd/etc/httpd/bin/httpd–f/etc/httpd/conf/httpd.conf

After you modify the/etc/inetd.conf file, you need to modify the add row in the/etc/services

httpd 80/tcp httpd

After you have done this, you will need to restart the inetd process. First, use the following command to obtain the inetd process ID:

PS Auxw |grep inetd

And then execute the command: kill–hup

In Redhat Linux, the default is to use the inetd server to run Apache, so as long as you choose the installation of httpd, the above work in the installation has been done for you.

Second, other configuration options


The Server Admin command, which is used to set the Web administrator's e-mail address. This address can occur when a system connection error occurs so that visitors can inform the Web Administrator of the situation in a timely manner.


Command format: Server Admin [e-mail address]

Example: Server Admin admin@xxx.com






errorlog command to specify the name and path of the error log file.

Command format: ErrorLog [log filename]

Example: Errorlog/var/httpd/error.log





Timeout command, as long as the client exceeds the number of seconds set here has not completed a request, the server will terminate this request service. If the network is slow, it is recommended that you set a larger number here. To give the client more opportunity.

Command format: Timeout [Second]

Example: Timeout 120





ServerRoot command, which specifies where to save the server's configuration, 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




4.2 srm.conf

Srm.conf is a resource configuration file that tells the server what resources you want to provide on the WWW site and where and how to provide them.


DocumentRoot command to specify the address of the main document.

Command format: documentroot [Path]

Example: documentroot/home/httpd/html





Userdir command to specify the location of the personal home page. If you have a user test, then its home directory is "/home/test", when the client input "Http://yourdomain/~test", the system will go to the corresponding directory "/home/test/userdir/" to find. where "Userdir" is the specified directory set in the Userdir command.

Command format: userdir [Path]

Example: Userdir public_html





DirectoryIndex command, used to declare the first file name. Generally, we use "index.html" or "index.htm" as the file name for the first page. If this is the case, then when the client issues a Web service request, the home page that is first transferred is the file "index.html" or "index.htm" in the specified directory.

Command format: direcotryindex [filename]

Example: Direcotryindex index.html index.htm





The Scriptalias command, which is an individual name for the script directory, shows 4.7 bars.

Command format: scriptalias [/alias/] [fullly qualified path for script directory]

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




Configuration of 4.3 access.conf

The access.conf file is used to set access permissions on the WWW site, such as files, directories, and script items. The first part of the document is not annotated as follows:



Option Indexes Includes execcgi followsymlink

AllowOverride None

Order Allow, deny

Allow from all




It should be noted that this part is to begin with to the end. This means that the portions between them are for the specified directory "/home/httpd/html".

1. The option command has a number of parameters, and the meanings of each parameter are as follows:

All of the following functions are permitted (except multiviews);

MultiViews permit the multiviews of content negotiation;

Indexes If there is no index file in the directory, it is allowed to display

The files in the directory are available for selection;

IncludesNOEXEC allows SSI (Server-side Includes), but not

Use #exec and #include functions;

Includes permit SSI;

FollowSymLinks permit 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 permission that is set in the "access.conf" file can be overwritten by the permissions set in file ". htaccess". It has two parameters:

All permission to cover;

None is not allowed to overwrite.




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

Allow can gain control;

Deny is prohibited from gaining control.




Now let's take a look at the meaning of the directory "/home/httpd/html" setting: It makes this directory, if there is no index.htm file, listing directory information for selection, allowing SSI, allowing the execution of CGI programs, and opening the dynamic connection. It does not allow you to override the permissions set here by using the set in file ". htaccess". So that all people can get control.

The second part of the document, which is not annotated, reads as follows:



Option execcgi

AllowOverride None






This indicates that the directory "/home/httpd/cgi" is set to the current directory where CGI programs can be executed. You are not allowed to override the permissions set here by using the settings in the file ". htaccess".

It should be noted that different Linux systems, you can see in this file is not exactly the same information, but according to the information given here, you can refer to the interpretation of the command to understand the file settings, and according to their own needs to make corresponding changes.

4.4 Make the new configuration effective

In the above, we may have changed the corresponding configuration options according to the new requirements, if we want to

Make this new configuration take effect immediately. We will have to restart the Web service process. In Linux, we can easily use the command line to restart the Web service process.

/ETC/RC.D/INIT.D/HTTPD restart
Related Article

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.