(This page has no text content)
Apache HTTP Server introduction by Antun Peicevic First edition Technical editor: Marko Maslac Copyright© 2016 Geek University Press Disclaimer This book is designed to provide information about Apache HTTP Server. Every effort has been made to make this book as complete and as accurate as possible, but no warranty is implied. The information is provided on an as is basis. Neither the authors, Geek University Press, nor its resellers, or distributors will be held liable for any damages caused or alleged to be caused either directly or indirectly by this book. The opinions expressed in this book belong to the author and are not necessarily those of Geek University Press. Note that this is not an unofficial book. The Apache Software Foundation (ASF) is in no way affiliated with this book or its content. Trademarks Geek University is a trademark of Signum Soft, LLC, and may not be used without written permission. Feedback Information At Geek University Press, our goal is to create in-depth technical books of the highest quality and value. Readers’ feedback is a natural continuation of this process. If you have any comments about how we could improve our books and learning resources for you, you can contact us through email at books@geek-university.com. Please include the book title in your message. For more information about our books, visit our website at http://geek-university.com.
(This page has no text content)
About the author Antun Peicevic is a systems engineer with more than 10 years of experience in the internetworking and systems engineering field. His certifications include CCNA Routing and Switching, CompTIA Network+, CompTIA Security+, and much more. He is the founder and editor of geek-university.com, an online education portal that offers courses that cover various aspects of the IT system administration. Antun can be reached at antun@geek-university.com. About this book This book teaches you how to work with Apache HTTP Server, an open-source web server. The book is written for people with some experience in the world of internetworking. You should also have a basic understanding of Linux, since almost all examples in the book are produced in Ubuntu, a popular Linux distribution. What will you learn You will learn how to download and install Apache HTTP Server on your Windows and Linux system. You will learn how to configure Apache as a web server, proxy server, and reverse proxy server. You will learn to set up SSL and to expand Apache functionality by adding modules.
(This page has no text content)
Table of Contents Chapter 1 - Introduction 4 What is Apache HTTP Server? 5 What is a web server? 5 Install Apache on Ubuntu 6 Install Apache on Windows 8 Chapter 2 - Basic configuration 10 Configuration files 11 apache2.conf file 12 conf-available directory 13 conf-enabled directory 13 envvars file 14 magic file 15 mods-available directory 16 mods-enabled directory 16 ports.conf file 18 sites-available directory 18 sites-enabled directory 19 Chapter 3 - Virtual hosts 21 Default virtual host 22 Create new virtual host 23 Configure SSL 28 Log files - access.log and error.log 30 Chapter 4 - Modules 32 Configure Apache as a forward proxy 33 Configure Apache as a reverse proxy 37 Display server statistics 38
(This page has no text content)
Chapter 1 - Introduction In this chapter we will give you a brief overview what Apache HTTP Server really is and what it is used for. We will then describe how to install Apache on Windows and Linux.
(This page has no text content)
What is Apache HTTP Server? Apache HTTP Server (usually called just Apache) is an open-source web server developed by the Apache Software Foundation. Apache is the most popular web server software on the Internet; it is estimated that 50% of all active websites use Apache as their web server. The Apache project was launched in 1995 and was based on an older web server software called NCSA HTTPd. The software is free and open-source, licensed under the Apache License that allows the user of the software the freedom to use the software for any purpose, to distribute it, to modify it, and to distribute modified versions of the software. Apache HTTP Server is cross-platform. It is available for a number of operating systems, including: Windows OS X Linux Unix FreeBSD Solaris Apache support many features and its functionality can be extended using compiled modules. Here are the major features: a very robust web server that can handle large volumes of traffic. one Apache installation can serve many different Web sites using virtual hosts. configurable error messages. supported by several graphical user interfaces (e.g. ApacheConf). supports password and digital certificate authentication. supports load balancing across multiple servers. What is a web server? Although Apache can be used in many ways (e.g. as a proxy server or a load balancer), it is commonly used as a web server. A web server is a software with a primary function to store, process and deliver web pages to clients. The protocol used to deliver web pages is HTTP (Hypertext Transfer Protocol).
HTTP is a client-server protocol; a client (usually a web browser) requests a resource (a web page) from a web server. The web server responds with the requested web page. Here is a graphical representation of the communication between a web client and a web server: As you can see in the picture above, the client wants to access http://google.com and points the browser to the URL http://google.com (this is an example of an HTTP Request message). The web server (running Apache or a similar web server software) hosting http://google.com receives the request and responds with the content of the web page (an HTTP response message). Web servers usually use a well-known TCP port 80. If the port is not specified in a URL, browsers will use this port when sending HTTP request. For example, you will get the same result when requesting http://google.com and http://google.com:80. Install Apache on Ubuntu Apache HTTP Server is usually installed on a Linux distribution, although it has been ported to other operating systems as well. In this section we will describe a how to install Apache on Ubuntu, one of the most popular Linux distributions out there. The process is really simple and involves just two commands. First, update the packages on your Ubuntu installation by running the sudo apt-get update && sudo apt-get upgrade command:
After the upgrade process finishes, run the sudo apt-get install apache2 command to install Apache. Press Y when prompted: Apache should automatically start. To verify that, run the service apache2 status command:
To verify that Apache web server is working, go to your browser and simply type localhost in the address bar. You should get the Apache2 Ubuntu Default Page. Install Apache on Windows There are no official binary releases of Apache HTTP Server software for Windows, only source code. However, there are numerous binary distributions on unofficial websites. We will use binaries from Apache Lounge community. First, go to https://www.apachelounge.com/download/ and choose the binaries for 32-bit or 64-bit Windows version: Visual C++ Redistributable for Visual Studio 2015 Update 1 x64 is required in order for Apache to run. If you don’t have it, install it from https://www.microsoft.com/en- us/download/details.aspx?id=49984 Extract the content of the Apache24 folder from the downloaded .zip file to C:\Apache24:
To install Apache as a Windows service, go to the C:\Apache24\bin folder and run the httpd.exe -k install command: Finally, open the Services panel (Start > Run > services.msc), locate the Apache2 service that you’ve just installed, and start the service: NOTE - To verify that Apache web server is running, go to your browser and just type localhost in the address bar. You should get the It works! message.
(This page has no text content)
(This page has no text content)
Chapter 2 - Basic configuration In this chapter we will describe the Apache configuration files in Ubuntu. We will describe each file in detail.
(This page has no text content)
Configuration files The Apache HTTP Server is configured by placing directives in plain text configuration files. The location of the configuration files depends on the operating system version. Historically, the main Apache configuration file was called httpd.conf. However, on Ubuntu, the main configuration file is apache2.conf. In this section we will describe the main configuration files found in Ubuntu. In Ubuntu, the Apache configuration files are stored in the /etc/apache2 directory: Here is a brief description of the files in this directory: apache2.conf - the main Apache2 configuration file that contains settings global to Apache2. conf-available - a directory that contains available configuration files. conf-enabled - a directory that holds symlinks to the files in /etc/apache2/conf- available. envvars - a file where Apache environment variables are set. magic - a text file that instructions for determining MIME type based on the first few bytes of a file. mods-available - a directory that contains configuration files to both load modules and configure them. mods-enabled - a directory that holds symlinks to the files in /etc/apache2/mods- available. ports.conf - a configuration file that houses the directives that determine the TCP ports Apache is listening on. sites-available - a directory that has configuration files for Apache2 Virtual Hosts. Virtual Hosts allow Apache2 to be configured for multiple sites that have separate
configurations. sites-enabled - a directory that contains symlinks to the /etc/apache2/sites- available directory. apache2.conf file In Ubuntu, the main Apache2 configuration file that contains settings global to Apache is /etc/apache2/apache2.conf. This file contains a set of directives, which are instructions that tell Apache what to do. Most directives are followed by an argument, which is the data passed to the directive. Here is a description of the directives found in this file: ServerRoot - specifies where Apache configuration files and modules are kept. This server root directory is then used as a prefix to other directory entries. Mutex file - sets the mechanism and the lock file location, that httpd and modules use to serialize access to resources. PidFile - specifies the server’s process ID (PID) file. On Ubuntu, the PID is defined by the APACHE_PID_FILE variable in the /etc/apache2/envvars file. Timeout - specifies the number of seconds before the web server times out a send or receive request. KeepAlive - if set to On, this option will allow each connection to remain open to handle multiple requests from the same client. If set to Off (which is the default), each request will have to establish a new connection. MaxKeepAliveRequests - specifies the maximum number of requests on a persistent connection. KeepAliveTimeout - specifies the time that a given connection to a client is kept open to receive more requests from that client. User - specifies the user that run Apache. The user is defined by the APACHE_RUN_USERS variable in the /etc/apache2/envvars file (by default it is www-data). Group - specifies the group that run Apache. The group is defined by the APACHE_RUN_GROUP variable in the /etc/apache2/envvars file (by default it is www-data). HostnameLookups - specifies whether the DNS lookups should be enabled so that host names can be logged. Turned off by default. ErrorLog - specifies the location of the error log file. The location is defined by the APACHE_LOG_DIR variable in the /etc/apache2/envvars file. LogLevel - specifies the level at which messages will be logged. The warn level is the default, but you can choose others like notice, info, debug, crit, alert, and emerg. IncludeOptional & Include - enable inclusion of other configuration files. such as module, port, and site configuration files. <Directory />…</Directory> - enables you to define a block of directives that apply only to a particular directory. The first directory definition applies rules for
Comments 0
Loading comments...
Reply to Comment
Edit Comment