LinuxApacheWeb server (Continued 1)

Source: Internet
Author: User
4. Configure Apache basics to run the WWW server. The configuration files of the Apache server software mainly include: "access. conf ": used to set the access mode and environment in the system;" httpd. conf ": used to set the basic environment for server startup;" srm. conf ": Mainly used for setting file resources;" mime. type ": Record Apac

4. Configure Apache basics to run the WWW server. The configuration files of the Apache server software mainly include: "access. conf ": used to set the access mode and environment in the system;" httpd. conf ": used to set the basic environment for server startup;" srm. conf ": Mainly used for setting file resources;" mime. type ": Record Apac

4. Configure Apache Basics ServerRun Apache ServerThe software configuration files mainly include: "access. conf": used to set the access mode and environment in the system; "httpd. conf": Used to set ServerStart the basic environment; "srm. conf": Mainly used for setting file resources; "mime. type": Record Apache ServerThe MIME format that can be recognized.

Before proceeding, we must tell you that Apache has adopted a series of default values during installation and ServerRun. You only need to connect the host installed with Linux + Apache to the Internet, and then store the home page under the "/home/httpd" directory.

The following describes the meanings of some of the most important configuration options, so that you can prepare with the minimum effort and minimum configuration. Server.

4.1 httpd. conf

Httpd. conf is the main configuration file. It tells ServerHow to run.

1. ServerType standalone | inetd

This configuration option specifies how to run the WEB Server. Apache can be run in two ways

Line Server: Standalone (independent) and inetd (run by inetd ).

The standalone parameter indicates that a WEB service process listens for client requests in the background in a separate waiting process. If yes, a sub-process is generated to serve it.

The inetd parameter indicates that the WEB service is not supported in the form of a separate waiting process. Instead, it's caused by the Inetd super ServerWhen a process receives a WEB service request from a client, it starts a WEB service process to serve the client.

From a functional perspective, the two methods are almost the same. But there is a big difference between them. ServerPerformance. A ServerThe process immediately exits when it finishes requesting the service. In standalone mode ServerThe process has to be suspended for a period of time before exiting, which gives them 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. inetd mode is considered to be more secure than standalone mode.

Standalone mode:

In this mode ServerListen for connection requests from specific ports. When the client sends

When configuring a connection request for a port address ServerThe process starts a WWW Service process to serve the request. As shown in:

Independent Server

You also need to tell the master ServerThe specific port address that the process listens to. Run the following command:

Port [number] (default value: 80)

Inetd Mode

Inetd is an Internet daemon that listens to connection requests from ports smaller than 1024 ( ServerProcess ). Unlike the previous method, when the customer system sends ServerInetd starts a WWW ServerProcess. As shown in:

Started by inetd Server

If you choose to use inetd ServerTo run Apache, 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 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 the inetd process ID:

Ps auxw | grep inetd

Then run the command: kill? HUP

In RedHat Linux, inetd is used by default. ServerTo run Apache, so as long as you select httpd during installation, 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 may occur when a system connection error occurs, so that visitors can promptly inform the WEB administrator of the situation.

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 client has not completed a request within the specified number of seconds, the server 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 ServerConfiguration, errors, and log files.

Command Format: ServerRoot [fully qualified path name]

Example: ServerRoot/etc/httpd

ServerName command, which configures ServerInternet host name

Command Format: ServerName [host name]

Example: ServerName www.xxx.com

4.2 srm. conf

Srm. conf is the resource configuration file, which is used to tell ServerWhat resources do you want to provide on the WWW site, where and how do you 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 main directory is "/home/test". When the client enters "http: // yourdomain /~ Test, the system will go to the corresponding directory "/home/test/UserDir/" to find. "UserDir" is the specified 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. In general, we use javasindex.html#or javasindex.htm as the homepage file name. ".

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

4.3 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:

Option Indexes Includes ExecCGI FollowSymLink

AllowOverride None

Order allow, deny

Allow from all

It should be noted that this part ends at the beginning. This indicates that the portion in the middle is for the specified directory "/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;

Indexes: If no index file exists in this directory, display is allowed.

Select files under this directory;

IncludesNOEXEC allows SSI (Server-side supported des), but not

Use the # exec and # include functions;

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 the permission set in the "access. conf" file can be overwritten by the permission 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 ServerGet control. 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: Allow to use this directory. If the index.htm file does not exist, list the directory information for selection, allow SSI, and allow CGI program execution, dynamic connection is enabled. It is no longer allowed to overwrite the permissions set here in the file ". htaccess. This allows everyone to gain control.

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

Option ExecCGI

AllowOverride None

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

It should be noted that in different LINUX systems, the information displayed in this file is not exactly the same, but according to the information given 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

Make the new configuration take effect immediately. We must restart the WEB service process. In LINUX, we can easily restart the WEB service process by using the command line.

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

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.