Presentation is loading. Please wait.

Presentation is loading. Please wait.

Linux Operations and Administration

Similar presentations

Presentation on theme: "Linux Operations and Administration"— Presentation transcript:

1 Linux Operations and Administration
Chapter Ten Apache Web Server

2 Objectives Install Apache Web Server along with additional Apache modules Configure an Apache Web server with a GUI utility and by modifying Apache configuration files Create a Web page by writing an HTML script

3 Installing Apache Web Server
A network computer with the primary role of serving Web pages to clients on request Can also host a Web site along with images, style sheets, and other content Clients (Web browsers) can access the Web pages Receives data from clients

4 Installing Apache Web Server (cont’d.)
Open-source Free Developed by Apache Software Foundation (ASF) Designed to run on a wide variety of operating systems

5 Installing Apache Web Server (cont’d.)
Apache version 2.2 Included with openSUSE Not installed by default Configured to run “out of the box” with no further modifications needed

6 Installing Apache Web Server (cont’d.)
Apache software is mostly modular PHP module A poplar module PHP A server-side scripting language Commonly used to create dynamic Web pages

7 Installing Apache Web Server (cont’d.)
Options to install Apache Web Server yast command YaST Software Management module Activity 10-1: Installing Apache Web Server Install Apache Web Server and other Web-related packages

8 Starting and Stopping Apache
To start apache2 service using YaST: Open YaST Select System Services (Runlevel) Search for apache2 and enable the service

9 Starting and Stopping Apache (cont’d.)
To start apache2 service at the command line: rcapache2 command Can be used only by the root user Is a link to a startup script in /etc/init.d directory Used to start, stop, and restart apache2 service Table 10-1 Describes common options used with rcapache2 command

10 Starting and Stopping Apache (cont’d.)
Table 10-1 Common options used with rcapache2

11 Starting and Stopping Apache (cont’d.)
To test an Apache Web server: Start Firefox Enter in address bar Activity 10-2: Starting and Testing an ApacheWeb Server Check the status of an Apache Web server, stop and start the apache2 service, and test an ApacheWeb server at the command line and with a GUI tool

12 Starting and Stopping Apache (cont’d.)
Figure 10-1 The Apache test page © Cengage Learning 2013

13 Configuring Apache Web Server
Methods to configure Apache Web server Use the graphical YaST module (yast2-http-server) Advantages: convenient and easy to use Modify Apache configuration files httpd.conf Main configuration file Contains directives (instructions that tell Apache how to run) Advantage: can make more detailed changes

14 Apache Configuration with HTTP-Server
A YaST module for configuring Apache Package name: yast2-http-server Can be installed from YaST Software Management To begin the Apache configuration process in HTTP-Server: Use yast2 http-server command

15 Apache Configuration with HTTP-Server (cont’d.)
Figure 10-2 The HTTP Server Wizard © Cengage Learning 2013

16 Apache Configuration with HTTP-Server (cont’d.)
HTTP Server Wizard Five steps Can choose network interface and ports that Apache listens on Port An interface for connecting a hardware device, such as a disk drive or printer In networking, it’s a data connection established for communication between hosts Port number identifies the type of function assigned to it

17 Apache Configuration with HTTP-Server (cont’d.)
HTTP Server Wizard allows you to enable scripting languages Such as PHP and Perl Web server’s default host First declared virtual host in the configuration file Virtual host Makes it possible to run multiple domains on one physical machine You can add virtual hosts as needed with HTTP Server Wizard

18 Apache Configuration with HTTP-Server (cont’d.)
Figure 10-3 Configuring the default host © Cengage Learning 2013

19 Apache Configuration with HTTP-Server (cont’d.)
You can set the following for a Web server in Apache: DocumentRoot Alias ScriptAlias Include Server Name Server Administrator

20 Apache Configuration with HTTP-Server (cont’d.)
Activity 10-3: Using the HTTP Server Wizard Configure an Apache Web server with the HTTP Server Wizard Expert mode Enables you to adjust more settings than in the wizard

21 Apache Configuration with HTTP-Server (cont’d.)
Figure 10-4 Expert mode in the HTTP Server Wizard © Cengage Learning 2013

22 Manual Apache Configuration
Can configure an Apache Web server manually Edit configuration files in /etc/apache2/ directory Table 10-2 Describes common configuration files stored in this directory Apache configuration files follow the syntax: One directive per line # symbols indicate comments

23 Manual Apache Configuration (cont’d.)
Table 10-2 Apache configuration files

24 Manual Apache Configuration (cont’d.)
apache2ctl -t command Verifies that configuration files have no syntax errors Activity 10-4: Using Apache Configuration Files Explore common Apache configuration files

25 Manual Apache Configuration (cont’d.)
Figure 10-5 Contents of an Apache configuration file © Cengage Learning 2013

26 Virtual Hosts Virtual hosts can be used to support multiple Web sites on one physical server By default, Apache is configured with a default host and no virtual host Apache supports: Name-based virtual hosts Multiple Web sites share the same IP address IP-based virtual hosts Multiple IP addresses for a single machine

27 Name-Based Virtual Hosts
Ways to create name-based virtual hosts: Editing httpd.conf file Virtual host configuration files NameVirtualHost directive Specifies the IP address to use for name-based virtual hosts

28 Name-Based Virtual Hosts (cont’d.)
An httpd.conf file that has been modified to support two virtual hosts:

29 Name-Based Virtual Hosts (cont’d.)
ServerName directive Specifies name of the server Apache uses it to determine which virtual host is displayed All virtual hosts you create must have their server name resolved on the network

30 Name-Based Virtual Hosts (cont’d.)
ServerAlias directive Can be used to define multiple names for a virtual host Order, Allow, and Deny directives Enable you to define which hosts can access files in a particular directory and which hosts can’t Order directive Tells Apache which filter (allow or deny) should be run first

31 Name-Based Virtual Hosts (cont’d.)
Another way to create virtual hosts is to create a virtual host configuration file in /etc/apache2/vhosts.d directory Virtual host template (vhost.template) You can copy it and rename A virtual host configuration file must have a .conf extension

32 Name-Based Virtual Hosts (cont’d.)
ServerAdmin directive Lists the Apache administrator’s account The only directives you must change: ServerName directive DocumentRoot directive Defines the directory path Apache uses to serve files for this host Directory directive Applies only to the named file system directory and subdirectories and their contents

33 Name-Based Virtual Hosts (cont’d.)
After creating a virtual host configuration file, define NameVirtualHost directive in /etc/apache2/listen.conf file Activity 10-5: Creating Virtual Hosts Use a template to create virtual Apache Web servers

34 Name-Based Virtual Hosts (cont’d.)
Figure 10-7 Defining the NameVirtualHost directive in the listen.conf file © Cengage Learning 2013

35 Creating a Web Page DocumentRoot directive
Defines the directory Apache uses to serve Web pages to clients Uniform Resource Locator (URL) An address to a resource on the Internet index.html file Main Web page Default content in HTML markup: <html><body><h1>It works!</h1></body></html>

36 Creating a Web Page (cont’d.)
Figure 10-8 A URL requesting a directory © Cengage Learning 2013

37 Creating a Web Page (cont’d.)
Hypertext Markup Language (HTML) Hypertext Contains references or links to access other files or text Markup language Consists of instructions called tags that define how text is displayed

38 Creating a Web Page (cont’d.)
Figure 10-9 Placing HTML tags on separate lines © Cengage Learning 2013

39 Creating a Web Page (cont’d.)
Table 10-3 Common HTML tags

40 Creating a Web Page (cont’d.)
To create a Web page in openSUSE Linux: You must use a text editor Activity 10-6: Creating Web Pages with HTML Create a basic HTML Web page

41 Summary Apache Web Server rcapache2 command can be used to:
Web server software that can be downloaded free Available with the latest version of openSUSE rcapache2 command can be used to: Check status of Apache Web server Start, stop, and restart the server HTTP-Server is a YaST application module for configuring Apache Manual Apache configuration: modifying directives (instructions) in Apache configuration files

42 Summary (cont’d.) With virtual hosts in Apache Web Server, you can run multiple Web sites on one physical machine Apache Web Server supports two types of virtual hosts: Name-based virtual hosts IP-based virtual hosts A number of directives can be configured on an Apache Web server Includes the mandatory DocumentRoot, Directory, and ServerName

Download ppt "Linux Operations and Administration"

Similar presentations

Ads by Google