Introduction to Apache server configuration in Linux

Source: Internet
Author: User
Tags apache log
Article Title: how to configure Apache servers in Linux. 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.

  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 -- enable-so

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.

[1] [2] Next page

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.