Apache Server Advanced settings guide

Source: Internet
Author: User
Currently, there are many WWWServer software that can run in linux, including NCSAHTTPdServer, CERNHTTPdServer, pache, NetscapeFastTrackServer, and ZeusServer. These software features: NCSA (National Super Computing Application Center of the University of Illinois) is the birthplace of WWWBrowserMosaic and also known as Netscape Public Apache

At present, there are many WWW Server software and many can run in linux, including NCSA HTTPd Server, CERN HTTPd Server, pache, Netscape Fast Track Server, and Zeus Server. These software features: NCSA (National Super Computing Application Center of the University of Illinois) is the place where WWW Browser Mosaic was developed and where Netscape Anderson became famous; CERN (European nuclear research center) is the origin of WWW. in 1989, Tim berneas-Li successfully developed the world's first Web server and client. The two WWW Servers have complete functions and become the standards of similar software. In addition, they are all Freeware, so they were very popular when they were launched. In the past few years, NCSA and CERN were the most widely used WWW Server software in linux, but over the past one or two years, Apache has been the only one to show off and is called "The King of WWW Server ". Apache is included in the latest versions of Red Hat, Slackware, and OpenLinux.

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

I. Installation

Apache installation is very simple. It is best to install the Web Server when installing RedHat, so that even if you are not familiar with the compilation operation, you can easily set up the Server.

If you want To compile the source file in person, you are not a beginner. you are advised To go directly To the How-To document or other materials. Open the machine, enter the X-Window system, start Netscape Navigator, and enter the IP address of the local machine. if the welcome page "It worked" appears, the server program works properly. You can perform the next step. In different versions, the default working root directory of the server is different. Red Hat uses/etc/httpd by default. the configuration file is in the/etc/httpd/conf directory, and the page file is in the/home/httpd directory.

2. set the httpd. conf, srm. conf, and access. conf files.

After Apache is installed successfully, there are four files in the conf sub-directory: httpd. conf, srm. conf, access. conf and magic (note: in the www-howto document, the fourth file is mime. types, but in actual installation, it is a magic file in the conf sub-directory ). Httpd. conf is the main file in the Apache configuration file. when the httpd program starts, it will first read httpd. conf. Srm. conf is a data configuration file. it mainly sets the directory for WWW Server to read files, the screen for Directory indexing, and the Directory for CGI execution. Access. conf is responsible for basic file read control and limits the functions that can be performed by the Directory and permission settings for accessing the directory.

The following describes the three data settings files.

Httpd. conf file

TransferLog:

If you want to know which page on your website is most popular with visitors and how many people visit your website within a period of time, you can set a counter, however, the counters on each page are too cumbersome and the results are not reliable. The best way is to view the corresponding log file. the TransferLog command is to specify that when the browser requires the server to transfer the file to the set file, you can view which users have viewed the HTML file based on the file. Some programs can be used to analyze the data of this file to obtain useful data for monitoring. The default access log file is logs/access_log.

ErrorLog:

This command specifies the file to which the error message is stored when a problem occurs during the operation of the WWW Server. The default value is logs/error_log.

VirtualHost:

This command is used to set up a virtual host, that is, using a host to execute WWW Server with multiple domain names. Detailed command usage will be explained in the third part.

Srm. conf

DocumentRoot:

Specifies the root directory for WWW Server to store html files. The WWW Server reads html files from the hard disk and sends them to the browser. instead of reading files from any directory, it reads files from a specific directory, the specified directory is specified by the DocumentRoot command. The default directory in red hat5.2 is/home/httpd/html.

If you access http://www.swm.com.cn/netlife/index.html, then WWW server does not read index.html from the netlife.html file in the system's root directory, but reads the index.html file from the/home/httpd/html/netlifefile.
UserDir:

If you want to open space for some users on the WWW Server and put it on the personal homepage, it is best not to put all html files in the DocumentRoot directory, use the UserDir command to place the pages of each person in their home directory. The default directory is public_html.

If the directory set by UserDir is public_html, and Username is yan, and the home directory of the user is/home/yan, then you access http://www.swm.com.cn /~ The intr.html file viewed at yan/intr.html is stored in/home/yan/public_html instead of/home/httpd/html.

Access. conf

If some directories only allow access by some people, or only allow CGI programs under a specific directory, modify access. conf.

There are two access control methods for Apache: one is "overall access control", only through access. conf to control the file settings, to limit the functions that can be performed by the Directory and the permission settings for accessing the directory. The second is "access control for specific Directories". create an access setting file in a specific directory. the file name is determined by AcessFileName in srm. conf. the default value is. htaccess. For example, if files in some directories are only accessible to some people, you can create files in these directories. the htaccess file is automatically read when the WWW Server reads the directory. htaccess to determine whether to read and execute or require password verification. These two methods use almost the same commands and the same format.

Directory:

Description of the directory to be set, and then use commands to set the features and permissions of the Directory.

Options:

Set the functions that the directory can perform. Options include None, All, ExecCGI, Des, Indexs, IncludesNoExec, FollowSymlink, and SymlinksOwnerMatch. If you want a directory to execute CGI programs, add the ExecCGI option to the Options command.

Require:

Set the Users and Group that can be accessed to the specified directory in a specified way. After the command is executed, when reading the data in this directory, the system requires that the Username and Password be entered.

Tips: do not restart the server to make the settings take effect as you do in Windows. Remember, in linux, one of the advantages of using linux is that you do not need to see the blue screen when Windows 98 crashes and do not have to make a little modification to the configuration file, so you will be bored and often restart the machine. Many people visit your WWW server at any time. restarting the server frequently will drive your guests away. You must learn not to restart the machine, but to restart a program that is being executed (Process, strictly called Process and job ). You can run the kill command to restart the program. For more information about how to use kill, see the relevant documentation.

Run the ps command to view the httpd pid and kill it to restart httpd. The command is as follows:

Linux> ps-x
Linux> kill-HUP 13668

(13668 is the pid number of httpd. in actual use, different values are also different)

In this way, you can restart httpd to make the modified configuration file take effect. After reading a bunch of commands above, isn't it annoying? in fact, it doesn't matter if you don't know these commands, and you can work normally with the default settings of the system.

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.