(Ubuntu:
Lesson 10)
{ Install and Configure
Apache2 }
Section 0.
Background Information |
- 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.
- Prerequisite
-
Lab Notes
- In this lab we will how to do the following:
- We will update the apt-get package
list.
- We will use apt-cache to search the package
list for apache2.
- We will use apt-get to install apache2.
- We will use update-rc.d to create
runlevel startup and kill scripts.
- We will create a basic index.html file.
- We will view that index.html file using
a web browser.
- 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 |
- Start VMware Player
- Instructions
- For Windows 7
- Click Start Button
- Search for "vmware player"
- Click VMware Player
- For Windows XP
- Starts --> Programs --> VMware
Player
- Verify Virtual Machine Settings.
- Instructions
- Click on Ubuntu 12.04
- Click on Edit virtual machine settings
- Configure Network Adapter
- Instructions
- Click on Network Adapter
- Click on the Bridged Radio Button
- Click on the Close Button
- Start the Ubuntu 12.04 VM
- Instructions
- Click on Ubuntu 12.04
- Click on Play virtual machine
Section 2: Login to
Ubuntu |
- Change to Gnome Classic
- Instructions:
- Click on the Circle
- Select Gnome Classic
- Instructions:
- Double Click on GNOME Classic
- Login to Server
- Instructions
- User: Student
- Password: Please supply the student
password.
Section 3: Become
Root and Verify Network Connection |
- Start up a Terminal
- Instructions
- Click on the Terminal
- Become Root
- Instructions
- sudo su -
- Supply the student password.
- Verify you have a network connection
- Instructions
- 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
- /etc/init.d/networking restart
Section 3: Update
apt-get's package index |
- Update apt-get's package index
- Instructions
- 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 |
- Search for apache2
- Instructions
- 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 |
- Install apache2
- Instructions
- apt-get install apache2
- Do you want to continue? Y
- Verify that apache is installed and is
running
- Instructions
- 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.
- pgrep -l apache
- pgrep, is a command that combines
both the "ps" and the "grep" commands.
Section 6: Startup
Script for apache2 |
- Startup Script for apache2
- Instructions
- 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.
- Stopping and Starting apache2 with /etc/init.d/apache2
- Instructions
- cd /etc/init.d
- ./apache2 stop
- ps -eaf | grep -v grep | grep apache2
- Notice, that no lines are returned,
because apache2 is not running.
- ./apache2 start
- ps -eaf | grep -v grep | grep apache2
- Now one line is returned, because
apache2 is running.
- Stopping and Starting apache2 with the "service"
command
- Instructions
- 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.
- ps -eaf | grep -v grep | grep
4750
- Replace 4750, which your is your
apache2 PID.
- service apache2 stop
- This command still stop the apache2
daemon.
- ps -eaf | grep -v grep | grep apache2
- Notice, no processes are displayed
for apache2, because we stopped apache2 in the above command.
- service apache2 start
- 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 |
- 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
- echo "ServerName localhost" >
/etc/apache2/conf.d/fqdn
- ls -l /etc/apache2/conf.d/fqdn
- service apache2 stop
- service apache2 start
- ps -eaf | grep -v grep | grep apache2
Section 8: Create
startup and kill scripts for apache2 |
- Create startup and kill scripts for apache2
- Instructions
- 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.
- Verify startup and kill script was created
- Instructions
- 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 |
- Ubuntu apache2 root directory
- Note(FYI):
- The /var/www is the default root
directory for the Ubuntu apache2 webserver.
- Instructions
- cd /var/www
- ls -l *
- cp index.html index.html.BKP
- ls -l *
- Create index.html file
- Note(FYI):
- The index.html file is the default
homepage for the webserver.
- Instructions
- date > index.html
- echo "<br>" >> index.html
- echo "Your Name" >> index.html
- Replace the string "Your Name" with
your actual name.
- cat index.html
- Start Up Firefox
- Instructions
- Applications --> Internet --> Firefox
Web Browser
- Proof of Lab
- Instructions
- 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
- Press both the <Ctrl> and <Alt> keys at
the same time.
- Do a <PrtScn>
- Paste into a word document
- Upload to Moodle
|
|