Linux networking (1): WEB Servers

Source: Internet
Author: User
Article Title: Linux networking entry (1): WEB server. Linux is a technology channel of the IT lab in China. Includes basic categories such as desktop applications, Linux system management, kernel research, embedded systems, and open source.
One of the most popular services on the Internet is the World Wide Web. If you want to introduce yourself or your company to the world through the home page, you must put the home page on a WEB server. Of course, you can use some free home page space for publishing. However, if you have the conditions, you can register a domain name, apply for an IP address, and ask your ISP to resolve the IP address to your LINUX host. Then, set up a WEB server on the LINUX host. You can store the home page on your WEB server and publish your home page.
  
4.1 select and install WEB Server Software
At present, many companies and academic groups around the world develop different servers based on different computer systems, such as Apache, CERN, Microsoft Internet Information System, NCSA, and WebSite. They have their own strengths. In many LINUX releases, Apache has been integrated with a free, widely used, and sophisticated WEB server software.
After practical trial, I found that the cooperation between Apache and LINUX is still ideal. So I will introduce the configuration and implementation of Apache in Red Hat Linux 6.0.
If the httpd option is selected during the Startup Process of LINUX installation. In this way, Apache will automatically complete installation and meet the daily application requirements. We only need to perform more specific settings.
  
4.2 composition of Apache
In Red Hat Linux 6.0, Apache stores all its configuration files and log files in the "/etc/httpd" directory, "/etc/httpd/conf" is the configuration file, and "/etc/httpd/log" is the log file.
At the same time, it will create the "/home/httpd" directory and create three subdirectories under it: "html/": store HTML (home page) files under this directory; "cgi-bin/": Some CGI programs can be stored in this directory; "icons/": some icons that come with the server are stored in this directory.
  
4.3 Apache settings
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 the MIME format that the Apache server can recognize.
Before explaining this, we must tell you that the LINUX system has adopted a series of default values during installation. You can understand the meaning of these settings according to the instructions below, then, make some minor adjustments based on your actual situation to better suit your specific application.
4.3.1 access. conf configuration
When we use "vi" to open it, we will find that, just like LINUX, there are a lot of content that can be seen dizzy. Make it clear that all statements starting with "#" at the beginning indicate that this line is a comment statement to help you understand the content of the file, rather than the configuration file itself. In the following illustration, we will skip these annotation statements.
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
You should note that this part is Start End. 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, the files in this directory are allowed to be displayed for selection;
IncludesNOEXEC: Server-side supported des (SSI) is allowed, but # exec and # include functions are not available;
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 to be overwritten; None is not allowed to be overwritten.
3. Order command: Used to set who can get control from this server. It also has two parameters:
Allow can get control; deny cannot get 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.3.2 httpd. conf configuration
This file contains many setting commands to set the running environment of the server. The following are some common parts:
1. The ServerType command is used to set the server startup mode. The command format is as follows:
Command Format: ServerType [standalone/inted]
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, the super server Inetd waits for the process to do the work. When it receives a WEB service request from a client, it starts a WEB service process to serve it.
We recommend that you use the standalone parameter.
2. Port command: Specify the Port number (socket) for the server service ). In general, the WEB Service uses the well-known port number-80, if you set another port number, when others use your WEB service, you must enter "http://xxx.xxx.xxx: Port Number", this is inconvenient. Therefore, we recommend that you set Port 80 here.
Command Format: Port 80
3. The Server Admin command is used to set the email 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
4. The BindAddress command is used to set the address from which to receive the service.
Command Format: BindAddress [*/IP/FQDN]
For example, BindAddress IP indicates that only visitors who enter the IP address are allowed.
BindAddress FQDN indicates that only visitors who enter the domain name address are allowed.
BindAddress * Indicates accepting visitors in the above two ways
5. 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
6. The CacheNegotiatedDocs command allows the proxy server to keep data in the cache. In many cases, this setting command is commented out because the proxy server is not allowed to keep data in the cache by default.
7. The 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
8. Run the KeepAlive command to determine whether to enable the continuous request function.
Command Format: KeepAlive [on/off]
9. The MinSpareServer command is used to set the minimum number of idle WEB service processes. When the number of idle WEB service processes is less than this setting, the system will automatically open more service processes to make the minimum number of idle WEB service processes.
Command Format: MinSpareServer [number] example: MinSpareServer 5
Note that if this number is too large, idle processes are wasting system resources, greatly reducing the resources of the entire system. If it is too small, it may cause frequent connections to prevent the system from being connected. The Setting principle is that if this server is a dedicated WEB server, set this value as big as possible; otherwise, you can set it enough.
10. MaxSpareServer command, which is used to set the maximum number of idle WEB service processes.
Command Format: MaxSpareServer [number] example: MaxSpareServer 10
This command works with the previous one to make the WEB service process occupy the most reasonable resources in the memory.
11. The StartServers command is used to set several service processes generated when the WEB server is started.
Command Format: StartServers [number] example: StartServers 5
12. The MaxClients command is used to set the maximum number of client requests to maintain system stability and avoid excessive system load.
Command Format: MaxClients [number] example: MaxClients 150
  
4.3.3 srm. conf configuration
This file is mainly used to specify the location of the home page document. The following describes the three most common commands.
1. the DocumentRoot command is used to specify the address of the master document.
Command Format: DocumentRoot [Path] example: DocumentRoot/home/httpd/html
2. 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 inputs 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
3. 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. ".
  
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.