Apache Server Advanced Settings Guide (i)

Source: Internet
Author: User
Tags documentation execution functions log require versions root directory linux
apache| Server | Advanced Current WWW Server software has many, can run under Linux also a lot of, there are NCSA HTTPd server, CERN HTTPd server, Pache, Netscape Fast Track Server, Zeus server and so on. These software features: NCSA (National Center for Supercomputing Applications, University of Illinois, USA) is the birthplace of www Browser mosaic and the place where Netscape Anderson became famous; CERN (European Centre for Nuclear Research) is the birthplace of WWW, Tim 1989 Benas-Lee is the first Web server and client in the world to develop successfully. These two launch of the WWW server full-featured, become the standard of similar software, plus they are all freeware, so the first launch is very popular. A few years ago, in Linux under the WWW server Software most used is NCSA and CERN, but this one two years, an up-and-comer Apache but the coquettish, known as "The King of WWW server." Apache is included in the latest red Hat, Slackware, and openlinux versions.

Apache is developed on the basis of NCSA, so the configuration files of the two are very similar.

First, installation

The Apache installation is simple. It's a good idea to install Web server when you install Redhat, so that you can easily set up the server even if you're not familiar with the compilation operation.

If you want to compile the source files yourself, then you are not a beginner and suggest you go directly to the how-to documentation or other material. Turn on the machine, enter the X-window system, start Netscape Navigator, typing the local IP address, if the "It worked" Welcome page, that means that the server program is working properly. You can do the next configuration work. Under different versions, the server defaults to the working root directory. Red hat defaults to/ETC/HTTPD, the configuration file is in the/etc/httpd/conf directory, and the paging file is in the/HOME/HTTPD directory.

Second, set up httpd.conf, srm.conf, access.conf documents

After the Apache installation was successful, there were four files in the Conf subdirectory: httpd.conf, srm.conf, access.conf, Magic (note: In the WWW-HOWTO document, said that the fourth file is Mime.types, but in the actual installation, in the Conf subdirectory is the Magic file. The httpd.conf is the primary file in the Apache settings file, and the HTTPD program reads the httpd.conf first when it starts. Srm.conf is a data configuration file in which the main setting is the directory where WWW server reads files, the screen of the directory index, the directory at the time of CGI execution, and so on. ACCESS.CONF is responsible for basic read file control, limit the functions that the directory can perform and access the permissions settings of the directory.

The following is a simple description of these three data settings files.

httpd.conf file

Transferlog:

If you want to know which pages on your site are most popular with visitors and how many people visit your site over a period of time, you can certainly set a counter, but each page has a counter, too cumbersome and the results are not very reliable. The best way is to view the log file, the Transferlog command is to specify when the browser requires the server to transfer files recorded to the set of files, you can see from this file which users have seen which HTML files. Some procedures can be used to analyze the data of this document and to draw up monitoring of various useful data. The default access log file is Logs/access_log.

ErrorLog:

This command specifies which file the error message is stored when a problem occurs while the WWW server is running. The default is Logs/error_log.

VirtualHost:

This command is used to set up a virtual host, a www Server that executes multiple domain names with a single host. Detailed command usage will be explained in detail in the third section.

Srm.conf

DocumentRoot:

Specifies that the WWW server stores the root directory of HTML files. The WWW server reads HTML files from the hard disk to the browser, not to read files from either directory, but to start reading files from a specific directory that is specified by the DocumentRoot command. The default directory in red hat5.2 is/home/httpd/html.

If the user accesses http://www.swm.com.cn/netlife/index.html, the WWW server does not read index.html from the Netlife directory in the root directory of the system, but from/home/httpd/ Read the index.html file in the Html/netlife directory.
Userdir:

If you want to create a space on the WWW server for some users, lets personal homepage, it is best not to put everyone's HTML files into the DocumentRoot directory, with the Userdir command allows everyone's page to be placed in their own home directory. The default directory is public_html.

If the directory where the Userdir is set is public_html, and username is Yan, and the user's home directory is/home/yan, then you visit http://www.swm.com.cn/~yan/ The intr.html files you see when you intr.html are stored in/home/yan/public_html, not/home/httpd/html.

access.conf

If you have directories that you want to access only to certain people, or only allow CGI programs in a specific directory, then modify the access.conf.

There are two kinds of access control methods in Apache: One is "whole access control", only through access.conf to control the setting of the file, to limit the functions that the directory can perform and access the permission settings of the directory. The second is "specific Directory access control", in a specific directory to establish access settings file, this file name in the srm.conf acessfilename to determine, the default is. htaccess. For example, files in some directories allow access only to certain people, and the. htaccess file can be created in that directory, and will be read automatically when WWW server reads the directory. htaccess to determine whether to read execution or require password verification. The commands used in these two ways are almost the same, and the formatting is the same.

Directory:

Describe the directory you want to set up, and then use the command to set the functionality and permissions of the directory.

Options:

Sets what functionality the directory can perform. There are none, all, execcgi, Includes, Indexs, IncludesNOEXEC, Followsymlink, Symlinksownermatch, and other options. If you want a directory to perform CGI programs, you should add the EXECCGI option to the Options command.

Require:

Sets the users and group that can be accessed in a specified way to the specified directory. When this command is executed, the system asks for input username and password when reading the directory data.

Advice: After modifying the settings file, do not restart the machine to take effect as you did with Windows. Keep in mind that one of the benefits of using Linux under Linux now is that you don't have to see the blue screen of Windows 98 when it's dead, and you don't have to make a little change to the configuration file to restart the machine as tedious and frequent. Your WWW server is accessed by many people at any time, and restarting your machine frequently will drive your guests away. To learn not to reboot the machine, but to restart a program that is being executed (process, strictly called processes, jobs). You can use the KILL command to enable the program to restart. Use the specific kill to see the documentation.

First use the PS command to view the httpd PID number, and then kill it with the kill command, restart httpd. The specific orders are as follows:

Linux> Ps-x
Linux> Kill-hup 13668

(13668 is assumed httpd pid number, in actual use, different situation values are also different)

This allows the httpd to be restarted so that the modified configuration file takes effect. Read the above a lot of orders, is not a bit annoying, in fact, you do not understand these commands do not matter, with the system default settings can also work properly.


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.