ComputerSecurityStudent (CSS) [Login] [Join Now]




|UNIX >> Ubuntu >> Ubuntu 12.04 Desktop >> Current Page |Views: 6532

(Ubuntu: Lesson 10)

{ Install and Configure Apache2 }


Section 0. Background Information
  1. What is Apache
    • The Apache HTTP Server, commonly referred to as Apache, is a web server software notable for playing a key role in the initial growth of the World Wide Web.  Typically Apache runs on a Unix-like operating system.

  2. Prerequisite
  3. Lab Notes
    • In this lab we will how to do the following:
      1. We will update the apt-get package list.
      2. We will use apt-cache to search the package list for apache2.
      3. We will use apt-get to install apache2.
      4. We will use update-rc.d to create runlevel startup and kill scripts.
      5. We will create a basic index.html file.
      6. We will view that index.html file using a web browser.

  4. Legal Disclaimer
    • As a condition of your use of this Web site, you warrant to computersecuritystudent.com that you will not use this Web site for any purpose that is unlawful or that is prohibited by these terms, conditions, and notices.
    • In accordance with UCC § 2-316, this product is provided with "no warranties, either express or implied." The information contained is provided "as-is", with "no guarantee of merchantability."
    • In addition, this is a teaching website that does not condone malicious behavior of any kind.
    • You are on notice, that continuing and/or using this lab outside your "own" test environment is considered malicious and is against the law.
    • © 2012 No content replication of any kind is allowed without express written permission.

 

Section 1: Start Ubuntu 12.04
  1. Start VMware Player
    • Instructions
      1. For Windows 7
        1. Click Start Button
        2. Search for "vmware player"
        3. Click VMware Player
      2. For Windows XP
        • Starts --> Programs --> VMware Player

     

  2. Verify Virtual Machine Settings.
    • Instructions
      1. Click on Ubuntu 12.04
      2. Click on Edit virtual machine settings

     

  3. Configure Network Adapter
    • Instructions
      1. Click on Network Adapter
      2. Click on the Bridged Radio Button
      3. Click on the Close Button

     

  4. Start the Ubuntu 12.04 VM
    • Instructions
      1. Click on Ubuntu 12.04
      2. Click on Play virtual machine

 

Section 2: Login to Ubuntu
  1. Change to Gnome Classic
    • Instructions:
      1. Click on the Circle

     

  2. Select Gnome Classic
    • Instructions:
      1. Double Click on GNOME Classic

     

  3. Login to Server
    • Instructions
      1. User: Student
      2. Password: Please supply the student password.

 

Section 3: Become Root and Verify Network Connection
  1. Start up a Terminal
    • Instructions
      1. Click on the Terminal

     

  2. Become Root
    • Instructions
      1. sudo su -
      2. Supply the student password.

     

  3. Verify you have a network connection
    • Instructions
      1. ifconfig -a
        • eth0 is the name of my interface.
        • 192.168.1.106 is my network IP address.
    • Note(FYI):
      • If you do not have an DHCP IP Address try the following:
        • dhclient
          • OR
        • /etc/init.d/networking restart

 

Section 3: Update apt-get's package index
  1. Update apt-get's package index
    • Instructions
      1. apt-get update
    • Note(FYI):
      • update is used to resynchronize the package index files from their sources. I.e., The "update" flag updates apt-get's local database with debian server's pkglist files. The indexes of available packages are fetched from the location(s) specified in /etc/apt/sources.list.

 

Section 4: Search for apache2
  1. Search for apache2
    • Instructions
      1. apt-cache search apache2 | grep "^apache2 "
    • Note(FYI):
      • apt-cache is a command to manipulate and obtain information from the ubuntu packages.

     

Section 5: Install apache2
  1. Install apache2
    • Instructions
      1. apt-get install apache2
      2. Do you want to continue? Y

     

  2. Verify that apache is installed and is running
    • Instructions
      1. ps -eaf | grep -v grep | grep apache
        • ps -eaf, show all processes.
        • grep -v grep, filter out the grep process.
        • grep apache, show only the apache process.
      2. pgrep -l apache
        • pgrep, is a command that combines both the "ps" and the "grep" commands.

 

Section 6: Startup Script for apache2
  1. Startup Script for apache2
    • Instructions
      1. ls -l /etc/init.d | grep apache2
    • Note(FYI):
      • As part of the apache2 installation, the apache2 startup script is placed in /etc/init.d/apache2.

     

  2. Stopping and Starting apache2 with /etc/init.d/apache2
    • Instructions
      1. cd /etc/init.d
      2. ./apache2 stop
      3. ps -eaf | grep -v grep | grep apache2
        • Notice, that no lines are returned, because apache2 is not running.
      4. ./apache2 start
      5. ps -eaf | grep -v grep | grep apache2
        • Now one line is returned, because apache2 is running.

     

  3. Stopping and Starting apache2 with the "service" command
    • Instructions
      1. service apache2 status
        • Notice, if apache2 is running a process number is displayed call the PID (process ID).
        • In my case, the PID is 4750.
      2. ps -eaf | grep -v grep | grep 4750
        • Replace 4750, which your is your apache2 PID.
      3. service apache2 stop
        • This command still stop the apache2 daemon.
      4. ps -eaf | grep -v grep | grep apache2
        • Notice, no processes are displayed for apache2, because we stopped apache2 in the above command.
      5. service apache2 start
      6. ps -eaf | grep -v grep | grep apache2
        • ps -eaf, display all processes.
        • grep -v grep, filter out the grep command.
        • grep apache2', search for any process containing the string apache2.

     

Section 7: Could not determine the server's fully qualified domain name
  1. Fix message "Could not determine the server's fully qualified domain name"
    • Note(FYI):
      • Early in (Section 6, Step 2), you might have receive the following error message after restarting the apache server.
      • apache2: Could not determine the server's fully qualified domain name.
      • Below we will populate the fqdn file with the ServerName directive to silence this message.
    • Instructions
      1. echo "ServerName localhost" > /etc/apache2/conf.d/fqdn
      2. ls -l /etc/apache2/conf.d/fqdn
      3. service apache2 stop
      4. service apache2 start
      5. ps -eaf | grep -v grep | grep apache2

 

Section 8: Create startup and kill scripts for apache2
  1. Create startup and kill scripts for apache2
    • Instructions
      1. update-rc.d apache2 defaults
    • Note(FYI):
      • The update-rc.d command is used to create startup, enable, kill, and remove scripts for services listed in the /etc/init.d.
      • If defaults is used then update-rc.d will make links to start the service in runlevels 2345 and to stop the service in runlevels 016. By default all the links will have sequence number 20.
      • In our case, the apache2 installation already created the startup scripts.

     

  2. Verify startup and kill script was created
    • Instructions
      1. find /etc/rc*.d/* -print | xargs ls -l | grep apache2
        • find /etc/rc*.d/* -print, list all the file in /etc/rc*.d/*
        • xargs ls -l, Use the xargs command to issue provide a long list of each file that find displays.
        • grep apache2, only display files containing apache2.

 

Section 9: Create index.html file
  1. Ubuntu apache2 root directory
    • Note(FYI):
      • The /var/www is the default root directory for the Ubuntu apache2 webserver.
    • Instructions
      1. cd /var/www
      2. ls -l *
      3. cp index.html index.html.BKP
      4. ls -l *

     

  2. Create index.html file
    • Note(FYI):
      • The index.html file is the default homepage for the webserver.
    • Instructions
      1. date > index.html
      2. echo "<br>" >> index.html
      3. echo "Your Name" >> index.html
        • Replace the string "Your Name" with your actual name.
      4. cat index.html

     

Section 10: Proof of Lab
  1. Start Up Firefox
    • Instructions
      1. Applications --> Internet --> Firefox Web Browser

     

  2. Proof of Lab
    • Instructions
      1. Place your server's IP address in the URL box
        • E.g. http://192.168.1.106
        • Replace 192.168.1.106 with IP address obtain in (Section 3, Step 3).
    • Proof of Lab Instructions
      1. Press both the <Ctrl> and <Alt> keys at the same time.
      2. Do a <PrtScn>
      3. Paste into a word document
      4. Upload to Moodle

 



Help ComputerSecurityStudent
pay for continued research,
resources & bandwidth