Apache httpd Installation and configuration

Source: Internet
Author: User

1.1 Introduction

Apache HTTP Server (Apache) is an open source Web server of the Apache Software Foundation, which can run in most computer operating systems, and is one of the most popular Web server-side software due to its multi-platform and security [1] being widely used. It is fast, reliable, and can be compiled into the server by a simple API extension, such as the Perl/python interpreter.

Features include directory indexing, directory aliases, content negotiation, configurable HTTP error reporting, setuid execution of CGI programs, child process resource management, server-side image mapping, rewrite URLs, url spell checking, and online manuals.

The Apache HTTP server itself does not provide a servlet/jsp container. Therefore, in practical applications, the integration of Tomcat with Apache can create a commercially viable web platform with practical value.

1.2 Installation1.2.1 Windows installation

Download file, window version, http://httpd.apache.org, download file for Httpd-2.2.22-win32-x86-openssl-0.9.8t.msi.

1.2.2 Linux Installation

Download the TAR Package

The tar packages that need to be used are:

Httpd-2.2.22.tar.gz,apr-1.4.6.tar.gz,apr-util-1.5.2.tar.gz,pcre-8.32.tar.gz

Installing the TAR Package

After extracting each tar package (TAR–VXF), start the installation. The installation sequence is APR, Apr-util, Pcre, httpd.

If you are executing make to say that the GCC compilation environment is not found, then you need to install the GCC compilation environment:

Java code
    1. Yum install gcc gcc-c++ autoconf automake

I. Install Apr

Java code
    1. ./configure--prefix=/usr/local/apr
    2. Make
    3. Make test
    4. Make Install

II. Installing the Apr-util

Java code
    1. ./configure--prefix=/usr/local/apr-util/--with-apr=/usr/local/apr/bin/apr-1-config
    2. Make
    3. Make test
    4. Make Install

III. Installing the PCRE

Java code
    1. ./configure--prefix=/usr/local/pcre--with-apr=/usr/local/apr/bin/apr-1-config
    2. Make
    3. Make Install

Iv. Installing httpd

Java code
    1. ./configure--prefix=/opt/apache/httpd--with-apr=/opt/apache/apr/bin/apr-1-config--with-apr-util=/ opt/apache/apr-util/bin/apu-1-config--with-pcre=/opt/apache/pcre/bin/pcre-config
    2. Make
    3. Make Install

V. Start HTTPD

1. Starting apachectl-k Start

2. Stop Apachectl-k Stop

3. State Apachectl–k Graceful

4. Restart Apachectl–k restart

1.2.3 Modifying a running user

You must modify the owning users and groups in the <ifmodule unixd_module>. The folder after which you add the virtual path must have read and write permissions for the user and group, or you will be reporting permissions errors.

1.2.4 httpd Adding virtual paths

Open the Conf folder and add a section to the httpd.conf configuration file:

Java code
    1. alias/share "/home/vcs/service/data/version"
    2. <directory "/home/vcs/service/data/version">
    3. Options Indexes multiviews
    4. allowoverride None
    5. Order Allow,deny
    6. allow from all
    7. </Directory>

View the permissions for this folder through Ls–l to see if the user running Apache has permissions.

You can modify the owning group of a folder by Chown user File–r to modify the owner of the folder, CHGRP group File–r.

1.2.5 httpd Join system service

There is no Apache or httpd service in the system service,/usr/local/apache2/bin/apachectl start should be started every time. More trouble, the following operation can be loaded into the service httpd, the same can also be used for other service operations.

1. Copy the Apachectl file to/etc/rc.d/init.d, and then add the link under/etc/rc.d/rc5.d/. The command is as follows:

CP BIN/APACHECTL/ETC/INIT.D/HTTPD//If there are other versions of Apache, it can also be overwritten directly

Ln-s/etc/init.d/httpd/etc/rc.d/rc5.d/s85httpd//Build link (85 of the meaning is described later)

At this point, Apache can start automatically.

2. Run Chkconfig--list, found that there is no Linux service in the list httpd, by Chkconfig–add httpd to add, but prompted: httpd service does not support Chkconfig.

To edit/etc/rc.d/init.d/httpd, add the following comment information:

# chkconfig:345 85 15

# description:activates/deactivates Apache Web Server

The first line 3 numeric parameter meanings are: Which Linux level needs to start httpd (3,4,5), start serial number (85), close the ordinal (15).

Save after execution: Chkconfig--add httpd, successfully added.

The S85HTTPD link file appears in the RC3.D, RC4.D, rc5.d Path, and the K61HTTPD link file appears in the other run-level paths.

3, run Chkconfig--list httpd at this time already can see httpd service. You can now use the service httpd command.

service httpd start

Service httpd Restart

service httpd stop

service httpd status

1.3 Common Configuration Items

Global variables Globals Environment

Field name Default value Description
Serverroot> The SERVERROOT directive sets the directory where the server resides. In general it will contain conf/and logs/subdirectories. Systems installed with the Deb package, the default value for this entry is "/etc/apache2" which means that only the Apache2 configuration file is included. It is important to note that the directory is protected and does not allow non-root users to modify it.
Pidfile /var/run/apache.pid Specifies the file that records the process number of the HTTPD profile daemon. Because the httpd configuration file can automatically replicate itself, there are multiple httpd processes in the system, but only one process is the process that was originally started, and it is the parent process for the other processes. Sending a signal to this process will affect all httpd processes. The process number of the httpd parent process is recorded in the Pidfile defined file.
DocumentRoot /var/www/html This parameter specifies the path of the Apache server to hold the Web page, and by default all connections that require an HTTP service are the main directory. In each directory accessed by the Apache server, services that allow and prohibit client access can be set for each directory and subdirectory. The following are the default values for Apache.
MaxClients 150; This parameter limits the highest number of services that Apache can provide, that is, the number of connections at the same time cannot exceed this value. Once the number of connections reaches this limit, the Apache server is no longer serving other connections to avoid a significant decline in system performance.
Port 80 This parameter is used to specify the listening port of the Apache server. In general, the standard HTTP service default port number is 80, generally do not change this value.
KeepAlive On Most browsers now request the server to maintain a continuous connection, a feature called "KeepAlive", which is the standard specification in HTTP1.1, and is typically used to harden the server's performance. When using the Keep-connect feature, setting the maximum number of files that a client requests for a connection can affect the max file size, it is recommended to set the default value to on to improve access performance.
Maxkeepaliverequests 100 Use this parameter to determine the maximum number of requests that can be made per connection when using the Keep-connected (persistent connection) feature. If this value is 0, no limit is expressed. It is recommended to use a higher value as much as possible to give full play to Apache's high performance.
Maxrequestsperchild 10 This parameter limits the number of requests that can be processed by each subprocess (child process) before it ends, and once that number is reached, the subprocess is aborted to avoid prolonged occupation of Apache (or the library of functions used by Apache servers) to prevent overloading of memory or other system resources.
Maxspareservers/minspareservers 20/5 The number of HTTP daemons that provide Web services varies with the number of connections. The Apache server is dynamically tuned to maintain sufficient number of HTTP daemons to handle the current load, while maintaining a certain idle HTTP daemon to wait for new connection requests.
DirectoryIndex Inde.html Add additional default home page filenames after this command, such as adding index.htm, and so on. Of course, this is only some of the basic Apache settings, we can adapt to their own actual situation to be flexible, to give full play to the potential of Apache. If you modify the configuration file so that it takes effect immediately, you can restart the Apache service.

1.4 Virtual Host VirtualHost

A virtual host is one that runs multiple sites on a single machine (for example, www.company1.com and www.company2.com). A virtual host can be "IP-based", that is, one site per IP, or "Based on name", that is, multiple sites per IP. The fact that these sites run on the same physical server is not clearly disclosed to the end user.

Allows Apache to listen to multiple ports to access different paths. or multiple domain names are mapped to the same Apache when different access assignments are made.

The following instance is a listening 8001 port, mapped to a local physical address.

Java code
  1. Listen 8001
  2. namevirtualhost *:8001
  3. <virtualhost *:8001>
  4. ServerAdmin Limingnihao@iteye . com
  5. documentroot "e:/_org.js/extjs-4.1.0/"
  6. ServerName extjs.localhost
  7. errorlog "Logs/dummy-host2.localhost-error.log"
  8. customlog "Logs/dummy-host2.localhost-access.log" common
  9. </VirtualHost>
  10.   
  11. <directory "e:/_org.js/extjs-4.1.0/">
  12. Options Indexes multiviews
  13. allowoverride None
  14. Order Allow,deny
  15. allow from all
  16. </Directory>

Apache httpd Installation and configuration

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.