History and prospects of the first stop Apache
In 1995, a developer of the National Computer Security Association (NCSA) created the NCSZ global network service software. Its biggest feature was the HTTP genie program, it was easier to configure and create the source code than the CERN server at that time. Due to the lack of other server software at that time, it soon became popular. But later, almost all core developers of the server left NCSA, and some users set up an organization to manage the patches they prepared, so Apache Group came into being. They call the server software Apache. Apache originated from the pronunciation of A patchy server, which means A server filled with patches. Apache has gradually become the most popular Web server software on the Internet. Among all Web server software, Apache occupies an absolute advantage, far ahead of Microsoft IIS, which ranks second. If you are interested in it, you can visit the official Apache website: http://www.apache.org. As one of the Free Software, Apache, like other free software, is implemented and gradually improved by a large number of free developers who have invested a lot of time and energy, therefore, we have reason to believe that the development prospects of Apache will be better.
Installation of Apache 2.0 on the second site
The configuration and installation of Apache 2.0 are very different from those of Apache 1.3. Like other open-source software, it uses libtool and autoconf to configure the environment. However, Apache usually has two installation methods: source code installation and RPM package installation. The two installation types have their own characteristics. The RPM package installation does not require compilation, while the source code installation requires configuration compilation before installation. The RPM package is installed in a fixed position, select a fixed module, while the source code installation allows you to select the installation path and select the desired module. The following describes two types of installation methods in the form of instances.
1. Use source code for Installation
(1) obtain the source code
# Lynx http://www.apache.org/dist/httpd/httpd-2_0_NN.tar.gz
NN indicates the current version number.
(2) Extract
# Gzip-d httpd-2_0_NN.tar.gz
# Tar xvf httpd-2_0_NN.tar
(3) configuration.
#./Configure -- prefix =/usr/local/apache
Indicates that Apache will be installed in the/usr/local/apache directory.
(4) Compilation and Installation
# Make
# Make install
(5) test
#/Usr/local/apache/bin/apachectl start
Ii. Use the RPM package for Installation
# Rpm-ivh apache-*. rpm
After the installation is complete, the configuration file is in the/etc/httpd/conf/directory, the root directory of the file is/var/www/html, and the tool file is in the/etc/rc. d/init. d/directory. The log files are in the/var/log/httpd/directory.
Third-site Apache 2.0 Configuration
The main configuration file of Apache 2.0 is httpd. conf. If the source code is installed, the configuration file is saved in the/usr/local/apache/conf/directory, if the RPM package is used for installation, the configuration file is saved in the/etc/httpd/conf/directory. You can directly modify the httpd. conf file or use the graphical tool of redhat linux 9 to configure it. Choose Start program> system Settings> Server Settings> HTTP server. Main Interface
Next, let's take a look at several commands in httpd. conf. "#" is followed by comments.
Port 80 # defines the listening Port of the web server. The default value is 80, which is one of the TCP network ports. If multiple ports are written, the last port prevails.
User apache # generally, the web server runs with a nobody User and a nobody group because
All processes sent by the Group apache # Server Run as root, which has security risks.
ServerAdmin root @ localhost # specify the email address of the server administrator. The server automatically reports the error to this address.
ServerRoot/etc/httpd # the root directory of the server. Generally, all configuration files are under this directory.
ServerName new. host. name: 80 # name of the host searched by the web Client
KeepAliveTimeout 15 # specifies that a continuous request is waiting for 15 seconds. If the request exceeds 15 seconds, a new TCP connection is established.
MaxKeepAliveRequests 100 # Number of HTTP requests for permanent connection
MaxClients 150 # Total number of clients connected to the server at the same time
ErrorLog logs/error_log # used to specify the name and path of the Error Log File
PidFile run/httpd. pid # is used to store the httpd process number to stop the server.
Timeout 300 # Set the request Timeout time. If the network speed is slow, set the value to a large value.
DocumentRoot/var/www/html # used to store webpage files
Management of Apache on Site 4
(1) Start and Stop Apache
/Etc/rc. d/init. d/httpd start
/Etc/rc. d/init. d/httpd stop
(2) Apache Log Files
Some people say that determining whether an administrator is excellent is to check whether it is a log analysis expert, because the feedback obtained from the log file is very important for the administrator. Apache logs to files mainly include access logs and error logs. The access log records all the request processes of the server. It mainly records the customer's information. Through this log, we can know who accessed the website and when to visit it, what is the accessed content. The error log records the details of server errors and how to handle them. The location of the log file is specified by the above main configuration file httpd. conf. The Redhat tool is system log. The main interface is as follows:
The following is an example to illustrate the format:
Error Log Syntax:
[Mon sep 22 14:32:52 2003] [error] [client 127.0.0.1] client denied by server configuration:/export/home/live/ap/htdocs/test
[Mon sep 22 14:32:52 2003] Error occurrence time.
[Error] indicates the error level. There are debug, info, notice, warn, error, crit, alert, and emerg, which indicate the severity of the error from low to high.
[Client 127.0.0.1] indicates the client IP address.
Client denied by server configuration:/export/home/live/ap/htdocs/test is the specific error message.
Access log Syntax:
127.0.0.1-wangdong [22/sep/2003: 13: 55: 36-0800] "GET/apache_pb.gif HTTP/1.0" 200 2326
127.0.0.1 indicates the IP address of the client accessing this server.
Wangdong indicates the user's login name.
[22/sep/2003: 13: 55: 36-0800] time when the server completes client requests, in the format of [day/month/year: hour: minute: Second Time Zone]
"GET/apache_pb.gif HTTP/1.0" indicates the method used by the client to access this resource.
200 records the status code returned by the server to the customer. 200 indicates that the request is successful, and 4 indicates an access error.
2326 indicates the total number of bytes sent to the client. If it is "-", the access resource is not found.
However, in practical applications, for large websites, log files often grow rapidly, which is not conducive to our query, reduces server efficiency and occupies a large amount of disk space, therefore, we must regularly maintain logs.
Since the log file is large, how can we organize a lot of boring data into a form that is easy for us to understand? Is there any tool like this? Fortunately, the redhat linux 9 comes with a log analysis tool-webalizer,
We can also find a large number of such excellent free tools on the Internet, such as WebTrends Analysis Series.
Configure virtual hosts on site 5
A vm provides www services for multiple independent domain names on a www server. Each domain name has its own directory and configuration, which is equivalent to dividing a host into multiple hosts, the virtual host technology is very effective for users who want to provide independent Web services. It seems unwise for a company to use expensive servers to provide only one Domain Name Service. More and more companies prefer to use multiple domain name services on one server, the benefits of setting up different websites are obvious.
Apache supports Virtual Hosts in two ways: IP-based virtual hosts and name-based virtual hosts. Name-based virtual hosts use the same IP address to configure different virtual hosts, which makes up for problems caused by insufficient IP addresses. The name-based virtual host configuration is quite simple. You only need to configure the DNS server so that each host name corresponds to the correct IP address, then configure Apache HTTP Server so that it can recognize different host names.
Assume that we have set up a multimedia production company with an Apache server and an IP address 192.168.0.1 to run two types of business: an e-commerce website with the domain name www.business.media.com, the other is the teaching website with the domain name www.teaching.media.com. First, you can set the domain name www.business.media.com and www. teachin... conf on the DNS server.
NameVirtualHost 192.168.0.1
ServerName www.business.media.com
DocumentRoot/var/www/html/business
ServerName www.teaching.media.com
DocumentRoot/var/www/html/teaching
IP-based virtual hosts require different IP addresses to be used to distinguish different virtual hosts. This requires multiple NICs to be used to bind different IP addresses to different NICs, alternatively, you can bind multiple IP addresses to a network card. Suppose the IP address of our host is 192.168.0.1 (www.media.com), and there are two other IP addresses ?.. Nf/httpd. conf. [/Url]
ServerAdmin webmaster @ business.media.com
DocumentRoot/var/www/html/business
ServerName www.business.media.com
ErrorLog/var/www/html/business/logs/error_log
TransferLog/var/www/html/business/logs/access_log
ServerAdmin webmaster@teaching.media.com
DocumentRoot/var/www/html/teaching
ServerName www.teaching.media.com
ErrorLog/var/www/html/teaching/logs/error_log
TransferLog/var/www/html/teaching/logs/access_log
Configure Apache proxy on site 6
A proxy server is a transfer station for network information services. If we compare the Apache proxy server to an agent, when a consumer buys something from the agent, if the agent has it, it can be directly sold to the consumer. If not, the agent will purchase the goods from the manufacturer, then sell it to consumers. This has the following benefits: (1) Improved access speed. (2) act as a firewall to increase security. (3) Some poor websites can be filtered out. (4) cache function. (5) Saving IP overhead. The proxy server can be divided into two types: client proxy and server proxy. Next we will explain several instructions and then illustrate their respective configuration methods.
ProxyRequest On/Off # enable or disable the Apache proxy service.
CacheRoot "/etc/httpd/proxy" # root directory of proxy cache.
CacheSize 5 # Proxy Cache size.
CacheGcInterval 4 # Set the interval between useless data collection programs running the management Cache
CacheMaxExpire 24 # file expiration time.
CacheDefaultExpire 1 # specify the validity period of the file that does not contain the expired information.
NoCache a-domain.com another-domain.edu # files for this site will not be cached.
L client proxy configuration
(1) modify the commands in/etc/httpd/conf/httpd. conf.
(2) Modify/etc/httpd/conf/httpd. conf to add access control to the proxy directory.
Order deny, allow
Deny from all
Allow from .your-domain.com
(3) Restart httpd.
L server proxy configuration
The server-side proxy is different from the client-side proxy. It installs the Apache server on the firewall and uses it to provide proxy access to the WWW server. This method separates the WWW server from the external, improving the security. For users, it seems that there is no change. Assume that the IP address of the WWW server in the internal LAN is 192.168.0.2, the internal IP address of the firewall host is 192.168.0.5, and the external IP address is 192.9.202.1.
(1) Configure Apache on the firewall
(1) Add a VM to/etc/httpd/conf/httpd. conf.
ServerAdmin webmaster@business.media.com
DocumentRoot/www/docs/business.media.com
ServerName www.business.media.com
ErrorLog logs/business.media.com-error_log
CustomLog logs/business.media.com-log_common
(2) configure the DNS server in the LAN and direct www.business.media.com to 192.9..1 .1.
(2) configure the WWW server in the LAN
In Linux, Squid is a popular proxy server software. It is very powerful and supports proxies for HTTP, FTP, Gopher, SSL, WAIS, and other protocols. It is easy to set up and only needs to be slightly changed in the configuration file.
Now, the WWW server configuration process is complete. I hope that the people who have read this article will gain some benefits. Finally, I hope that fans who are on the road to learning Linux will never give up and become a real master.