107
Chapter Apache Installation on Linux

Linux Webserver Installation Command and GUI.ppt

Embed Size (px)

Citation preview

Page 1: Linux Webserver Installation Command and GUI.ppt

Chapter

Apache Installation on Linux

Page 2: Linux Webserver Installation Command and GUI.ppt

Acknowledgement

• The contribution made by Darrin Morison is acknowledged

Page 3: Linux Webserver Installation Command and GUI.ppt

• Demonstrate a basic installation and setup of an Apache Web Server on a PC running the Linux OS.

Chapter Objectives

Page 4: Linux Webserver Installation Command and GUI.ppt

Chapter Modules

• Apache Web Server installation

Page 5: Linux Webserver Installation Command and GUI.ppt

Introduction to Apache

• Apache is a web server package that works under Linux as well as under other operating systems

• The name Apache comes from the concept of extensive patching of existing code

• The primary advantage of Apache is that it is generally free or available at modest costs

Page 6: Linux Webserver Installation Command and GUI.ppt

Apache Server Installation

• Download newest version of Apache– May be installed from a CD-ROM as well

• Unzip downloaded file• Untar the tar file• Create the MAKE files• Make Install• Edit httpd.conf file• Start Apache Server

Page 7: Linux Webserver Installation Command and GUI.ppt

Installing Apache From a CD-ROM

• If your CD-ROM has Apache and you want to use RPM to install the package, issue this command– rpm –i apache_1_3_4.rpm(substitute the full name of the Apache

package)

Page 8: Linux Webserver Installation Command and GUI.ppt

Downloading the newest Apache

• First, in Linux, create a folder to hold the Apache file you will download.

• The newest version of Apache Server and Documentation can be found at The Apache Software Foundation http://www.apache.org/

• To download the newest version of Apache go to http://www.apache.org/dist/ and click on apache_1.3.12.tar.gz.

• Download this file into your newly created directory.

• NOTE: apache 1.3.12 is the latest version at the time of this writing. You may want to check for newer releases.

Page 9: Linux Webserver Installation Command and GUI.ppt

Unzipping Downloaded File

• After you have downloaded your Apache file go into the folder you have downloaded it into by typing cd /path to folder/name of folder/.

• Next, to unzip the .gz file at the prompt type: gunzip apache_1.3.12

and press the enter key.• This will unzip the file into the current

directory.

Page 10: Linux Webserver Installation Command and GUI.ppt

Untarring the TAR file

• After unzipping the .gz file the resulting file will be a .tar file. (Which stands for tape archival)

• You will need to untar this file by typing at the prompt: tar –xvf apache_1.3.12 and press the enter key.

• This will untar the file to a new directory named apache_1.3.12

Page 11: Linux Webserver Installation Command and GUI.ppt

Creating the Make Files

• Go into the folder that now contains the untarred apache files. To change into that folder, at the prompt type: cd /<path to folder>/apache_1.3.12.

• Once you are in the apache_1.3.12 folder you will need to create the apache make files.

• To do this, at the prompt type: • ./configure --prefix=/usr/local/apache and press

the enter key. This will install apache in the folder /usr/local/apache.

• You may chose to install in another directory.

Page 12: Linux Webserver Installation Command and GUI.ppt

Compiling Make Files

• After running the configure command you will need to compile the make files.

• To compile the make file, from inside in the apache_1.3.12 directory, at the prompt, simply type: make

and press the enter key.

Page 13: Linux Webserver Installation Command and GUI.ppt

Running the Make Install

• Next you must run the make install.• While still in the directory

apache_1.3.12, at the prompt, type: make install

and then press enter.• This will install the apache server to

the directory defined in the configure command.

Page 14: Linux Webserver Installation Command and GUI.ppt

Editing the httpd.conf File

• In order to get the apache server started you must edit the httpd.conf file. The file is located in whatever directory you installed apache in.

• Once in your apache install directory find the folder named conf.

• Change into the conf folder and locate the file named httpd.conf.

• Open the httpd.conf file with any file editor.• Next locate the line # ServerName <Name>

and uncomment out this line by deleting the # symbol preceding ServerName.

• Save the file and close it.

Page 15: Linux Webserver Installation Command and GUI.ppt

Starting, Stopping and Restarting Your Apache

Server

• To start your Apache server you must either put the location of the directory, where your Apache server is installed, in you PATH environment variable or you must change into your Apache directory and at the prompt type: apachectl start and press return

• If the path to your Apache install directory is already in your PATH environment variable, then you can type: apachectl start to start your apache Server from anywhere within your environment.

Page 16: Linux Webserver Installation Command and GUI.ppt

Starting, Stopping and Restarting Your Apache

Server (cont.)

• To stop your Apache Server, from inside the directory where your Apache is installed, type: apachectl stop

and press enter.• To restart your Apache Server, from

the directory where your Apache is installed, type: apachectl restart

and press enter.

Page 17: Linux Webserver Installation Command and GUI.ppt

Testing Your Apache Installation

• After you have installed and started your Apache server you can test to if everything is running OK by doing the following…

• Start a browser application.• If you installed Apache as root, type in the

address bar of your browser the name of your computer and press enter.

• If you installed Apache as a user, type in the address bar the name of the computer followed by a colon and then 8080. For example….

your_computer_name:8080.• 8080 is the default port for user and 80 is

the default port for root.

Page 18: Linux Webserver Installation Command and GUI.ppt

Testing Your Installation (cont.)

• If everything has gone as it should have you should see a page with the apache logo at the top explaining why you are seeing this page. This page gives you links to all the apache documentation which you should read.

• If you would like to customize this index page it is called index.html.en in the htdocs directory located in the directory your Apache server is installed.

(source: http:// www.apache.org/)

Page 19: Linux Webserver Installation Command and GUI.ppt

Apache Installation is Finished!

• The basic installation of the Apache server is finished.

• There is much more to an Apache server customization. You should then read the documentation provided with your release to become more familiar with your Apache setup.

Page 20: Linux Webserver Installation Command and GUI.ppt

Setting Up the Website

• Create the home directory for the website, we will use /usr/www/ganesan

• Create 3 subdirectories under the site directory– conf– htdocs– logs

Page 21: Linux Webserver Installation Command and GUI.ppt

Setting Up the Website (con’t)

• You will find a subdirectory called conf under the directory where you installed Apache– Copy 3 files (srm.conf-didst,

access.conf-dist, http.conf-dist) from this directory into /usr/www/ganesan/conf

– If you cannot find the 3 files, use the find command to find them

Page 22: Linux Webserver Installation Command and GUI.ppt

Setting Up the Website (con’t)

• Rename the 3 files you just copied to drop the “-dist” portion of the name

• Edit the httpd.conf file to specify – the port number on which your web

server responds– the user running the httpd daemon,

etc…• Specify the server name

– ServerName ganesan.com

Page 23: Linux Webserver Installation Command and GUI.ppt

Setting Up the Website (con’t)

• Add a line that specifies the root directory for your website– DocumentRoot /usr/www/ganesan/htdocs

• Edit the srm.conf file to set up the web home directory and any special internal command usage

• Edit the access.conf file to set a basic set of access permissions

Page 24: Linux Webserver Installation Command and GUI.ppt

Setting Up the Website (con’t)

• In the htdocs directory create an HTML file for the server to read when it starts– This can be any HTML file– The filename should be default.html

• Start the httpd daemon– httpd –f /usr/www/ganesan/conf

Page 25: Linux Webserver Installation Command and GUI.ppt

Setting Up the Website (con’t)

• Test the web server by starting a browser and specify the URL http://127.0.0.1/

• If the system is working properly, you will see a screen with a list of files in the htdocs directory

Page 26: Linux Webserver Installation Command and GUI.ppt

Server Configuration

Page 27: Linux Webserver Installation Command and GUI.ppt

Server Configuration

• Make sure the ServerType directive is set to “standalone”

• Check the Port device to make sure it is set to the TCP/IP port to which your Apache server listens

• Set the User directive to either the user ID (UID) or the user name used for all web visitors

Page 28: Linux Webserver Installation Command and GUI.ppt

Server Configuration (con’t)

• Set the Group directive to either the group ID (GID) or the group name assigned to all web users

• Modify the ServerAdmin directive to include the e-mail address of the administrator

• Set the ServerRoot directive to the absolute path to the directory where all Apache resource and configuration files are stored– /usr/apache/conf or /etc/httpd

Page 29: Linux Webserver Installation Command and GUI.ppt

Server Configuration (con’t)

• Set the ServerName directive to the fully qualified domain name of your server

Page 30: Linux Webserver Installation Command and GUI.ppt

Starting and Stopping Apache

Page 31: Linux Webserver Installation Command and GUI.ppt

Starting and Stopping Apache

• If you are running Apache as a standalone server, you need to start and stop Apache manually– Start with httpd –d rootdir –f configs– To stop Apache use ps to detect the

httpd daemon’s PID and use the kill command to terminate the process

Page 32: Linux Webserver Installation Command and GUI.ppt

A Note on Starting and Stopping Apache

• Later versions of Apache include a script that does the start and stop tasks for you

Page 33: Linux Webserver Installation Command and GUI.ppt

Chapter

Apache Installation in Linux-Mandrake

Page 34: Linux Webserver Installation Command and GUI.ppt

Acknowledgment

• The following information has been obtained directly from www.mandrake.com

• All credit it due to the above

Page 35: Linux Webserver Installation Command and GUI.ppt

Linux

Unix Windows

Linux:Where Unix

meets Windows

GUI based approach to Apache installation.

Page 36: Linux Webserver Installation Command and GUI.ppt

Apache Configuration Using KDE

• In this section, Apache will be configured using the available tools and utilities of the KDE desktop. This is not necessarily a recommended way to run a web server, but it does offer a convenient environment to begin learning the first steps of running a web server in the safety of an internal LAN.

Page 37: Linux Webserver Installation Command and GUI.ppt

Checking for Already Installed Apache

Page 38: Linux Webserver Installation Command and GUI.ppt

Using ktail to Monitor Installation

• Alt-F2 will open a mini-command line in KDE, and kdesu -c ktail will launch ktail as the root user. Ktail will be used throughout the following pages to monitor Apache's log files during configuration

Page 39: Linux Webserver Installation Command and GUI.ppt

Launching ktail to Monitor the Installation

Alt F2 opens a mini command line

Page 40: Linux Webserver Installation Command and GUI.ppt

Providing root Password

Page 41: Linux Webserver Installation Command and GUI.ppt

Accessing the Service Activity

Page 42: Linux Webserver Installation Command and GUI.ppt

Activating the httpd Service

Page 43: Linux Webserver Installation Command and GUI.ppt

Starting Stopping and Restarting Apache

Page 44: Linux Webserver Installation Command and GUI.ppt

Monitoring Start, Stop

and Restart

Page 45: Linux Webserver Installation Command and GUI.ppt

Accessing the Web

Page 46: Linux Webserver Installation Command and GUI.ppt

Accessing the Web Server Using Localhost

Page 47: Linux Webserver Installation Command and GUI.ppt

Gain Access as Super User to

root

Page 48: Linux Webserver Installation Command and GUI.ppt

Root Folder(File)

Page 49: Linux Webserver Installation Command and GUI.ppt

Location of Apache Files

Page 50: Linux Webserver Installation Command and GUI.ppt

Bookmark the Location

Page 51: Linux Webserver Installation Command and GUI.ppt

Location od Web Files

Page 52: Linux Webserver Installation Command and GUI.ppt

Renamed Index.html

Page 53: Linux Webserver Installation Command and GUI.ppt

Loading Your Own Web

• A web can now be stored in this folder to become the website on the Apache server

• Index.html will be the first file that would be accessed first

Page 54: Linux Webserver Installation Command and GUI.ppt

KDE File Manager as a Limited Web Browser

Page 55: Linux Webserver Installation Command and GUI.ppt

Accessing the Website from Other MachinesUse IP Address

Page 56: Linux Webserver Installation Command and GUI.ppt

Location of Logs

Page 57: Linux Webserver Installation Command and GUI.ppt

Drag and Drop Logs into ktail for Viewing

Page 58: Linux Webserver Installation Command and GUI.ppt

Other Details in Error Log

Page 59: Linux Webserver Installation Command and GUI.ppt

Event Details

• Date and time of event

• What type of event

• The event itself

Page 60: Linux Webserver Installation Command and GUI.ppt

Other Details in Access Log

Page 61: Linux Webserver Installation Command and GUI.ppt

Other Details on Access Log

• The machine's name or IP address that accessed the server

• Date and time of access• The file that was transferred • An access code and the number of bytes transferred • The server's name or IP address that was requested • The web browser that was used • And some info about the visitor's system

Page 62: Linux Webserver Installation Command and GUI.ppt

Location of conf Files

A copy has been made of the conf files folder

Page 63: Linux Webserver Installation Command and GUI.ppt

Making a Copy of the Conf Files

• /etc/httpd/conf is where Apache's configuration files are located. You may want to first make a backup copy of the original configuration directory before making edits to the enclosed files. Ctrl-t opens a konsole in the current directory, and cp -r conf confOrigBackup recursively copies the folder & contents with a new name.

Page 64: Linux Webserver Installation Command and GUI.ppt

Locating Apache’s Main httpd.conf File

Page 65: Linux Webserver Installation Command and GUI.ppt

Editing httpd.conf Using Kedit

Page 66: Linux Webserver Installation Command and GUI.ppt

Disabling Some Kedit Options Before Saving Changes to httpd.conf

Page 67: Linux Webserver Installation Command and GUI.ppt

Section1: Modules

Page 68: Linux Webserver Installation Command and GUI.ppt

A Note on Modules

• This first section of Apache's configuration file deals with modules. Modules add extra capabilities to Apache that aren't normally included in its basic set of features. If you install Mandrake's RPM modules for Apache you most likely won't ever need to manually enter any module information yourself, as the required entries will automatically be added with the packages.

• continued

Page 69: Linux Webserver Installation Command and GUI.ppt

php3 Module: An Example

• mod_php3 is a module that enables this popular scripting language to be used with Apache. If mod_php3 is installed on your system, you can test it by creating a simple test page as seen on the next page

Page 70: Linux Webserver Installation Command and GUI.ppt

Creating index.php3 for Testing of php3 Support

Page 71: Linux Webserver Installation Command and GUI.ppt

Testing for php3 Support

Page 72: Linux Webserver Installation Command and GUI.ppt

Success in Testing for php3

• You can test Apache by loading the page into Netscape. If php3 wasn't enabled properly, a screen of raw text would appear instead of a normal looking web page as seen here.

Page 73: Linux Webserver Installation Command and GUI.ppt

A Note on Testing for php3

• This is just a quick way to demonstrate if php3 is enabled on a server. php3 is a full-featured, HTML-embedded scripting language used for creating dynamically generated web pages. One common use of php3 is as a replacement for CGI scripts. Unfortunately this topic can't be covered in detail on these pages. For more info on php3, phpbuilder is a good starting point.

Page 74: Linux Webserver Installation Command and GUI.ppt

Location of Web Documents (Root)

Page 75: Linux Webserver Installation Command and GUI.ppt

Document Root

• The document root is where the web pages of the active website are kept– Similar to the home directory of the www

server in Windows

Page 76: Linux Webserver Installation Command and GUI.ppt

Display of Directory Listing

Page 77: Linux Webserver Installation Command and GUI.ppt

Absence of index File

• A directory listing is displayed as shown in the previous slide in the absence of an index file

Page 78: Linux Webserver Installation Command and GUI.ppt

Activating Configuration Changes

• After every configuration change Apache must be restarted

• It is usually a good practice to make one change at a time and then check ktail to ensure that the change had been made without any errors before proceeding to make the next change

Page 79: Linux Webserver Installation Command and GUI.ppt

Starting, Stopping and Restarting Apache

• Commands– apachetl start, apachetl stop, apachetl restart

• GUI– Apache may also be started, stopped and

restarted through the control services GUI• Access the httpd service for this purpose

Page 80: Linux Webserver Installation Command and GUI.ppt

Redirecting 404 and

Other Error Messages

Page 81: Linux Webserver Installation Command and GUI.ppt

Viewing of Serve Status

Other IP addresses may be specified for

viewing of server status from other machines.

Page 82: Linux Webserver Installation Command and GUI.ppt

Display of Server Status

From a different machine.

Page 83: Linux Webserver Installation Command and GUI.ppt

Server Type and Port Numbers

Page 84: Linux Webserver Installation Command and GUI.ppt

Note on Server Type and Port Numbers

• Standalone is recommended for server type

• Information on port numbers can be found in /etc/services

• Users do not have to enter a port number on the address if default port numbers are maintained– Example is Port 80 used for www service

Page 85: Linux Webserver Installation Command and GUI.ppt

Phantom User Nobody

• Apache runs as a phantom user known as nobody with very limited access

• Anyone exploiting this name to gain access to Apache will severely be restricted from causing any damage

Page 86: Linux Webserver Installation Command and GUI.ppt

Phantom User

Page 87: Linux Webserver Installation Command and GUI.ppt

Location of Apache

Configuration

Page 88: Linux Webserver Installation Command and GUI.ppt

Server Name

Page 89: Linux Webserver Installation Command and GUI.ppt

A Note on Server Name

• Server name is the one seen by the browsers in the filed “location name”

• For hosting a name accessible over the Internet, the name must have been registered and it must have a DNS entry on a DNS sever

• Server name need not relate to the machine’s host name

Page 90: Linux Webserver Installation Command and GUI.ppt

Access to Local Host Name

Page 91: Linux Webserver Installation Command and GUI.ppt

Adding a Host

Name

Page 92: Linux Webserver Installation Command and GUI.ppt

The New Name

Page 93: Linux Webserver Installation Command and GUI.ppt

A Note on Changing Name

• In general, changing host names should be avoided

• Certain services are configured based on the host name and they may not function properly after changing the name of the host

Page 94: Linux Webserver Installation Command and GUI.ppt

Permissions on Folders

Page 95: Linux Webserver Installation Command and GUI.ppt

Access Given to Folders

Permission given to others.

Page 96: Linux Webserver Installation Command and GUI.ppt

Right Clicking on Folders to

Give Permission

Page 97: Linux Webserver Installation Command and GUI.ppt

Changing Permissions

• Show entries and change into commands will give public to enter the folder and view its contents

Page 98: Linux Webserver Installation Command and GUI.ppt

Summary

• Windows users may still use some of the techniques learned to configure and operate Linux operations

• However, some command line programming is still inevitable

• In the long run, more GUI based operations is likely to be introduced in Linux

Page 99: Linux Webserver Installation Command and GUI.ppt

Giving Permission

using the chmod Command

Page 100: Linux Webserver Installation Command and GUI.ppt

Virtual Hosting

Page 101: Linux Webserver Installation Command and GUI.ppt

Virtual Hosts

• A virtual host is a web server that resides on one domain but acts as if it was on another. For example, suppose you control ganesan.com and cis454.com. Instead of setting up 2 servers, you can set up a single machine that serves both domains.

• Virtual hosting saves on machinery and allows for a lot of flexibility in setting up web servers

Page 102: Linux Webserver Installation Command and GUI.ppt

Setting Up Virtual Hosting

• If your network uses a name server for DNS, modify it so that the domain name points to your web server for each domain you’ll host

• Use the ifconfig command to set up the IP address for each domain on your server– ifconfig eth0:1 xxx.xxx.xxx.xxx

Page 103: Linux Webserver Installation Command and GUI.ppt

Setting Up Virtual Hosting (con’t)

• Add the route to the network configuration using the route command– route add –host xxx.xxx.xxx.xxx dev eth0:1

• Edit the Apache httpd.conf file to set up virtual hosting– <VirtualHost www.cis454.com>

DocumentRoot /usr/www/cis454/htdocsTransferLog /usr/www/cis454/logs/accessErrorLog /usr/www/cis454/logs/errors</VirtualHost>

Page 104: Linux Webserver Installation Command and GUI.ppt

Setting Up Virtual Hosting (con’t)

• The previous step defines the virtual host for cis454.com and specifies its DocumentRoot, since each virtual host will have different web directories

• If more than one virtual host is defined, the entries are to be repeated for each

Page 105: Linux Webserver Installation Command and GUI.ppt

End of Module

Page 106: Linux Webserver Installation Command and GUI.ppt

Apache Web Server Resources

• The Apache Software Foundation This is the official Apache web site

where you can find Apache Web Server documentation, the latest release for download, installation and setup instructions and much more.

http://www.apache.org/

Page 107: Linux Webserver Installation Command and GUI.ppt

END OF PRESENTATION