Details: LAMP stands for Linux, Apache, MySQL and PHP, which is a very common combination platform for Web Programming. Squid Cache Server, on the other hand, is a very popular, high-performance and free web cache server.
You will need to use 2 VMs for this lab: the Router VM as a server and
the Host VM as a client.
You will need to install the
Apache Web Server,
MySQL,
PHP and
Squid Web Cache on the
Router VM. Then you will verify them by using
either wget
or
telnet
from the Host VM.
/etc/httpd/conf/httpd.conf
.
Usually you would need to change "Listen" in the config file if the
server will not be running on the standard HTTP port, ie. 80. Change
"ServerAdmin" to your email address. Change "DocumentRoot" to
whatever directory that stores your homepages.
/etc/init.d/iptables stop
telnet
and examine the access_log on the Router VM.
Show the output in your report.
telnet
to "GET /passwd HTTP/1.0"
chkconfig
command to add httpd service into the
startup scripts (see my updated www lecture slides). Reboot the
Router VM to make sure the Apache Web Server starts automatically
after rebooting. Show the output in your report.
libphp5.so
is installed under
/usr/lib/httpd/modules/
. Show the output in your report.
php.conf
is installed under
/etc/httpd/conf.d
. Show the output in your report.
/var/www/html/index.php
with the content
below:
<? phpinfo(); ?>Verify that your web server is able to serve PHP pages. Show the output in your report.
mysql.txt
which is a script
that creates a database (cs183) and a table (grades), and then
inserts some data into the table. The content is as below:
# Create a database named cs183 create database cs183; # Select the database use cs183; # Create a grades table create table grades (name varchar(20), grade integer); # Add data into the table insert into grades values ('Alice', 80), ('Bob', 90), ('Claire', 92), ('David', 60);and then run:
$ mysql < mysql.txtto actually create the database and the table populated with data.
NOTE: For security purposes, you would normally setup a password for the MySQL root account before using MySQL. However, we do not do that here. Please see here for details.
/var/www/html/gradebook.php
, that connects to
the MySQL database and retrieves the information. The content is as
below:
<h1>CS183 Gradebook</h1> <pre> <? // Connect to the MySQL db $conn = mysql_connect("localhost", "root") or die(mysql_error()); // Select the cs183 database mysql_select_db("cs183") or die(mysql_error()); // SQL query $result = mysql_query("select * from grades order by grade desc;") or die(mysql_error()); // Display the result while ($row = mysql_fetch_assoc($result)) { printf("%10s: %d\n", $row["name"], $row["grade"]); } // Free up resources mysql_free_result($result); mysql_close($conn); ?> </pre>
gradebook.php
page. Show the result in your report
and argue that your PHP+MySQL works.
$ bzip2 -cd squid-2.6.STABLE20.tar.bz2 | tar xvf - $ cd squid-2.6.STABLE20 $ CFLAGS="-O3" ./configure --prefix=/import/pkgs/squid $ make -j2 $ make install $ pkginstall squid
/import/etc/squid.conf
.
acl our_networks src 10.0.0.0/24 http_access allow our_networks
/import/pkgs/squid/var/cache
and
change both the ownership and group ownership of it to "nobody".
/import/pkgs/squid/var/logs
to "nobody".
telnet
command. Show the output
in your report.
wget
with 'http_proxy'
environment variable set to "10.0.0.1:3128" to download the lastest
Linux kernel
(eg. http://www.kernel.org/pub/linux/kernel/v2.6/linux-2.6.25.tar.bz2)
twice. Use the time
command to measure the time taken
to download the first and second time. Show that in your
report. Hint: The second time should take a lot less time
than the first time.
/import/pkgs/squid/var/logs/access.log
on the Router VM
and explain it. Hint: Look for TCP_HIT or TCP_MISS
associated with the URL you just downloaded.
/etc/rc.d/rc.local
and reboot to make
sure your Squid Cache Server starts automatically after rebooting.
Show the output in your report.
<? phpinfo(); ?>
does in the
index.php
?
gradebook.php
. Show the result
that generated by gradebook.php
from the Host VM.