In linux, set WWWServer-Linux Enterprise Application-Linux server application information. For more information, see. Editor's note: the lives of many people have become increasingly simple: food, water, air, and Internet. This simplicity comes from a "Transparent"-network operations have become increasingly transparent to users. However, behind such transparency is increasingly large and complex network operating systems with increasingly opaque management. You can see several articles on this topic.
In fact, it is really difficult to write about the network operating system. This is just the tip of the iceberg. But maybe it's the brightest part: How to set up WWW Server and DNS Server on Linux, how to teach you how to share printers with each other in SCO OpenServer and Windows NT and Windows 95, solaris and NetWare5 installation tips. Of course, there are many other UNIX operating systems, and several of them cannot represent all of them. I hope you can draw some inspiration from each other.
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 become a dominant player 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. Redhat5.2 comes with Apache 1.3.
I. InstallationApache installation is very simple. It is best to install the web server when installing red hat, 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.
1. 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.
2. 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 the 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. 3. 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", which only uses 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: Specifies the Directory to be set, and then uses 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 in the specified directory in the specified way. After the command is executed, when reading the data in this directory, the system requires that the Username and Password be entered.
* Advice: 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 assumed that the pid Number of httpd is different in actual use)
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.
3. Virtual Host settings
As a system administrator, if you only have one IP address but have several domain names and want to access each domain name to see different content, what should you do? I don't always want to add a server to each domain name. This requires the use of Virtual Host technology. Fortunately, Apache supports this function. There are two methods for a VM: IP-Based and Name-based ). IP-Based refers to a domain Name corresponding to an IP address, while Name-based refers to multiple domain names corresponding to one IP address.
The VM settings are not complex. You only need to add the corresponding commands to the httpd. conf file. The following is an example of httpd. conf for a Name-based (Domain Name-based) virtual host (Editor's note: for space reasons, we only provide the relevant sections. For the full text, see www.swm.com.cn ).
The IP address is 192.9.188.20. The two domain names are long.com.cn and com.cn.