1. Install the Apache server When installing the Red Hat Linux 9.0, you will be prompted to install the APACHE server. If you cannot determine if it is already installed, you can enter the following command at the Terminal Command window:
[root @ ahpeng root] rpm -qa gren httpd
If the result is displayed as "HTTPD-2.0.40-21", the system has already installed the Apache server.
If you do not select the Apache server when installing the Red Hat Linux 9.0, you can click the "Main Menu → System Settings → Add Delete Application" menu item in the graphical environment. Make sure "WA" Server option, and then click the "Update" button, follow the screen prompt to insert the installation CD to start the installation.
In addition, you can also insert the first installation disc, locate the httpd-2.0.40-21.i386.rpm installation package under / redhat / rpms, and then run the following command at the Terminal Command window:
[root @ ahpeng rpms] rpm -ivh httpd-2.0.40-21.i386.rpm
Install the Apache server, you can run the following command at the Terminal Command window:
[root @ ahpeng root] /etc/rc.d/init.d/httpd start
Restart Apache Service:
[root @ ahpeng root] /etc/rc.d/init.d/httpd restart
Close Apache Service:
[Root @ ahpeng root] /etc/rc.d/init.d/httpd stop
After confirming that the Apache service has been launched, we can enter the following address in the web browser, if you can see the default Apache home page, the Apache server is working properly.
HTPP: // WebserveraddRess
The Webserveraddress here refers to the IP address or domain name of the web server. That is to say that WebserveradDress should be replaced with the IP address or domain of the actual web server.
2. Configure the httpd.conf file in the early Apache server version, its configuration content is dispersed in httpd.conf, srm.conf, access.conf three files. The new version of the Apache server is unified in httpd.conf. For the default installed Red Hat Linux, this profile is located in the / etc / httpd / conf directory, if the TAR.GZ version is installed, the file is located in the / usr / local / apache / conf directory.
With httpd.conf, we can make a global configuration of the Apache server, the parameters definitions of the main or preset servers, and the settings of the virtual host. httpd.conf is a text file, we can modify using text editing tools such as VI, Kate. We are not difficult to find out by analyzing the httpd.conf configuration file:
This configuration file is divided into several section, such as Section 1: Global Environment (First Section: Global Environment); Section 2: 'Main' Server Configuration (Second Section: Primer Server Configuration), etc.
Each section has several configuration parameters, which express the "Configure Parameter Name Specific Value", and each configuration parameter has a detailed English interpretation (with # 号).
To help you understand, here is the most common configuration parameters of httpd.conf:
(1) DocumentRoot
This parameter specifies the path to the Apache server to store the web page. The default requires the connection to the HTTP service to provide the main directory in this directory. The following is the default value of Apache: DocumentRoot "/ var / www / html"
(2) MaxClients
This parameter limits the highest value of Apache to provide services, namely the number of connected to the same time cannot exceed this value. Once the number of connections reaches this limit, the Apache server is no longer available to other connections, so that the system performance is greatly reduced. This example assumes that the maximum number of connections is 150:
MaxClients 150
(3) Port
This parameter is used to specify the listening port of the Apache server. In general, the standard HTTP service default port number is 80, and this value is generally not changed. This example is 80 ports:
Port 80
(4) ServerName
This parameter allows the user to set the host name by itself to replace the true name of the Apache server host. This name must be a host name that has been registered on the DNS server. If the current host does not have a registered name, you can also specify an IP address. This example sets the server name as Peter. Vicp.net:
Servername peter.vicp.net
(5) MaxkeepaliveRequests
When using the Persistent Connection function, you can use this parameter to determine the upper limit of the number of requirements that can be issued each time. If this value is 0, there is no limit. It is recommended to use a higher value as much as possible to fully utilize the high performance of Apache. In this case, the number of requirements that can be issued each time is 100:
MaxkeepaliveRequests 100
(6) MaxRequestSperChild
This parameter limits the number of requests that can be processed each child process, once this sub-process will be suspended to avoid long-term occupation apache (or the library used by the Apache server). Prevent overload caused by memory or other system resources.
It should be noted that the value of this parameter does not include the number of requests issued by the connection. For example, if a sub-process is responsible for a request, the request will then keep the 10 requests required to connect the connection function. At this time, the Apache server will only deal with only 1 requirement for this sub-process. Non-11 requirements.
The following settings can process up to 10 requirements:
MaxRequestSperChild 10
(7) MaxSpareServers and MinSpareServers
The HTTP daemon of the web service is provided, and the number will change with the number of connections. The Apache server uses dynamic adjustment methods to maintain a sufficient number of HTTP daemon to handle current loads, that is, maintain a certain free HTTP daemon to wait for new connection requests.
Apache will check how many HTTP daemons are waiting for the connection request. If the idle HTTP daemon is more than the value specified by the MaxSpareServers parameter, apache will terminate some idle processes; if the idle http daemon is less than the value specified by the MINSPARSERVERS parameter Then Apache will generate a new HTTP daemon. This example sets the highest idle daemon to 20, set the lowest idle daemon to 5:
MaxSpareServers 20
MinSpareServers 5
Of course, this is just some of the basic settings of Apache, and everyone can make flexible modification according to their own actual situation to give full play to the potential of Apache. If you fail to take effect immediately after modifying the configuration file, you can restart the Apache service.
Note: Be sure to back up before modifying!
3. Graphical configuration interface
The graphical configuration is intuitive, simple enough, enough to meet the daily management maintenance of the Apache server. We can access the Apache Configuration dialog box by clicking the "ApacheConf" command in the "Main Menu → System Settings → Server Settings → HTTP Server" menu item or enter the "ApacheConf" command directly in the Run Commands dialog. You can see that the configuration dialog has 4 tabs. (1) "Main" tab
In the Server Name box, you can enter the name of the server, equivalent to the "ServerName" field in the httpd.conf file. In the Network Optical Email Address box, you can enter the administrator's email address, equivalent to the "ServerAdmin" field in the httpd.conf file. Click Add (or "Edit" button in the "Available Address" option group, we can add or modify the server's IP address and port.
(2) "Virtual Host" tab
The so-called virtual hosting service refers to a multi-web server that will be virtually virtual. With the "virtual host" service provided by the Apache server, we can use a computer to provide multiple web services.
To set up a virtual host service with Apache usually use two solutions: the virtual host based on the IP address and the name-based virtual host. The implementation method of the virtual host based on the IP address has a serious shortcomings. Each time a virtual host, an IP address must be added. So here you introduce how to create a name-based virtual host.
Assuming an IP address of an Apache server is 210.79.81.212, the host name is www.companyname.net, and it has two aliases: sales.companyname.net, marketing.companyname.net. Although the IP address of these three websites is the same, it is directed to 210.79.81.212, but since the name-based virtual host is set, you can point to different web pages.
When setting, click the Add button on the Virtual Host tab, select the "Name-based virtual host" option in the "Host Information" drop-down list box of the Open Configuration dialog box, then enter the appropriate data IP Address, host name, etc., remember, add a suitable alias, as shown in Figure 2.
The setting content of the other two tabs of the "Apache Configuration" dialog is basically equivalent to the httpd.conf parameter configuration introduced in the previous, and it will not be introduced here.