a practical guide to fedora and red hat enterprise linux unit 10: basic apache configuration and...

26
A Practical Guide to Fedora and Red Hat Enterprise Linux Unit 10: Basic Apache Configuration and Management Chapter 26: Apache (httpd): Setting Up a Web Server By Fred R. McClurg Linux Operating System © Copyright 2013, All Rights Reserved

Upload: lynne-tucker

Post on 25-Dec-2015

224 views

Category:

Documents


1 download

TRANSCRIPT

Page 1: A Practical Guide to Fedora and Red Hat Enterprise Linux Unit 10: Basic Apache Configuration and Management Chapter 26: Apache (httpd): Setting Up a Web

A Practical Guide to Fedora and Red Hat Enterprise Linux

Unit 10: Basic Apache Configuration and Management

Chapter 26: Apache (httpd): Setting Up a Web Server

By Fred R. McClurg

Linux Operating System

© Copyright 2013, All Rights Reserved

Page 2: A Practical Guide to Fedora and Red Hat Enterprise Linux Unit 10: Basic Apache Configuration and Management Chapter 26: Apache (httpd): Setting Up a Web

What is a web server?Defined: Server software that responds to requests for content (web pages, audio, etc) from clients like web browsers (Firefox, IE, etc). The web server then returns content which is then rendered by the browser.

Page 3: A Practical Guide to Fedora and Red Hat Enterprise Linux Unit 10: Basic Apache Configuration and Management Chapter 26: Apache (httpd): Setting Up a Web

Apache: Web Server

Worlds most popular web server

http://trends.builtwith.com/Web%20Server

Page 4: A Practical Guide to Fedora and Red Hat Enterprise Linux Unit 10: Basic Apache Configuration and Management Chapter 26: Apache (httpd): Setting Up a Web

Web Server Trends

June 2010: 47,215,212 (47 million)

http://news.netcraft.com/archives/2010/06/16/june-2010-web-server-survey.html

Page 5: A Practical Guide to Fedora and Red Hat Enterprise Linux Unit 10: Basic Apache Configuration and Management Chapter 26: Apache (httpd): Setting Up a Web

Apache: Before Installation

Page 6: A Practical Guide to Fedora and Red Hat Enterprise Linux Unit 10: Basic Apache Configuration and Management Chapter 26: Apache (httpd): Setting Up a Web

Apache: Minimal Installation

Install httpd (HTTP Daemon):◦yum install httpd

Page 7: A Practical Guide to Fedora and Red Hat Enterprise Linux Unit 10: Basic Apache Configuration and Management Chapter 26: Apache (httpd): Setting Up a Web

Apache: Minimal Installation

Install apr (Apache Portable Runtime):◦yum install apr

Page 8: A Practical Guide to Fedora and Red Hat Enterprise Linux Unit 10: Basic Apache Configuration and Management Chapter 26: Apache (httpd): Setting Up a Web

Apache: Minimal Installation

Install apr-util (APR utilities):◦yum install apr-util

Page 9: A Practical Guide to Fedora and Red Hat Enterprise Linux Unit 10: Basic Apache Configuration and Management Chapter 26: Apache (httpd): Setting Up a Web

Apache: StartupRun chkconfig to start httpd upon multi-user mode (boot):◦/sbin/chkconfig httpd on

Page 10: A Practical Guide to Fedora and Red Hat Enterprise Linux Unit 10: Basic Apache Configuration and Management Chapter 26: Apache (httpd): Setting Up a Web

Apache: Start httpd now

Start apache daemon now:◦/sbin/service httpd start

Page 11: A Practical Guide to Fedora and Red Hat Enterprise Linux Unit 10: Basic Apache Configuration and Management Chapter 26: Apache (httpd): Setting Up a Web

Runs as background process

Look at Apache processes:◦ps -ef | grep httpd

Page 12: A Practical Guide to Fedora and Red Hat Enterprise Linux Unit 10: Basic Apache Configuration and Management Chapter 26: Apache (httpd): Setting Up a Web

Running on local server

http://localhosthttp://127.0.0.1http://iowa

Page 13: A Practical Guide to Fedora and Red Hat Enterprise Linux Unit 10: Basic Apache Configuration and Management Chapter 26: Apache (httpd): Setting Up a Web

Creating a web page

DocumentRoot location:◦/var/www/html

Page 14: A Practical Guide to Fedora and Red Hat Enterprise Linux Unit 10: Basic Apache Configuration and Management Chapter 26: Apache (httpd): Setting Up a Web

Browser Rendering Web Pages

File protocol:◦file:///var/www/html/index.html

Page 15: A Practical Guide to Fedora and Red Hat Enterprise Linux Unit 10: Basic Apache Configuration and Management Chapter 26: Apache (httpd): Setting Up a Web

Apache Serving Web Pages

Main “home” page:◦/var/www/html/index.html

Page 16: A Practical Guide to Fedora and Red Hat Enterprise Linux Unit 10: Basic Apache Configuration and Management Chapter 26: Apache (httpd): Setting Up a Web

<html> <head> <title> Website's Home Page </title> </head>

<body> <h1> Website's Home Page </h1>

<p> Location: /var/www/html </p> </body></html>

HTML Template

Page 17: A Practical Guide to Fedora and Red Hat Enterprise Linux Unit 10: Basic Apache Configuration and Management Chapter 26: Apache (httpd): Setting Up a Web

Template in Web Browser

Page 18: A Practical Guide to Fedora and Red Hat Enterprise Linux Unit 10: Basic Apache Configuration and Management Chapter 26: Apache (httpd): Setting Up a Web

httpd.conf Configuration File

Apache Directive to control directory listings:◦IndexOptions

Page 19: A Practical Guide to Fedora and Red Hat Enterprise Linux Unit 10: Basic Apache Configuration and Management Chapter 26: Apache (httpd): Setting Up a Web

Result of IndexOptions

Page 20: A Practical Guide to Fedora and Red Hat Enterprise Linux Unit 10: Basic Apache Configuration and Management Chapter 26: Apache (httpd): Setting Up a Web

httpd.conf Configuration File

Apache Directive granting access to directory:◦DocumentRoot

Page 21: A Practical Guide to Fedora and Red Hat Enterprise Linux Unit 10: Basic Apache Configuration and Management Chapter 26: Apache (httpd): Setting Up a Web

httpd.conf Configuration File

Apache Directive grants access to a directory:◦Allow from

Page 22: A Practical Guide to Fedora and Red Hat Enterprise Linux Unit 10: Basic Apache Configuration and Management Chapter 26: Apache (httpd): Setting Up a Web

httpd.conf Configuration File

Apache Directive setting the server name:◦ServerName

Page 23: A Practical Guide to Fedora and Red Hat Enterprise Linux Unit 10: Basic Apache Configuration and Management Chapter 26: Apache (httpd): Setting Up a Web

Restart Apache Process

Restarting apache after httpd.conf modification:◦/sbin/service httpd restart

Page 24: A Practical Guide to Fedora and Red Hat Enterprise Linux Unit 10: Basic Apache Configuration and Management Chapter 26: Apache (httpd): Setting Up a Web

Apache access log

Records requests made to the server:◦/var/log/httpd/access_log

Page 25: A Practical Guide to Fedora and Red Hat Enterprise Linux Unit 10: Basic Apache Configuration and Management Chapter 26: Apache (httpd): Setting Up a Web

Apache error log

Records runtime server errors:◦/var/log/httpd/error_log

Page 26: A Practical Guide to Fedora and Red Hat Enterprise Linux Unit 10: Basic Apache Configuration and Management Chapter 26: Apache (httpd): Setting Up a Web

IP Address GeolocationThe approximate location of your IP address can be obtained