You will be adding PHP server-side scriping to your web server.
You will be implementing and benchmarking a PHP version and an Apache module version of the file-based name/value pair program.
Part 1. Install, configure, and test PHP on your Apache server.
To install PHP into your Apache web server, do the following:
sudo apt-get install php5 libapache2-mod-php5
You may need to restart the web server using the script apachectl.
Now test out the new PHP functionality of your server.
If something doesn't work, check the log files in /var/logs/apache2.
Start or restart your Apache server using apachectl.
Create an HTML page in your /var/www under the name test.php.
Test that a normal HTML page can be loaded from the test.php file.
Test adding some PHP script to test.php, e.g. <? phpinfo(); ?>.
Your browser should show the result of the PHP script and not display the actually PHP code itself.
Copy test.php to test.html. What happens if you go to http://localhost/test.html? You may want to View Source in Firefox.
Part 2.
Create a file-based name/value pair storing program just like in Assignment #1.
The PHP script will store the pairs in files in the /var/www directory.
You will need to set the permissions of this folder as in Assignment #1.
Create a PHP script lookup.php in your htdocs web server root directory.
The script is controlled by the HTML GET parameters: file, name, and val.
Parameters from a GET request are available in the PHP superglobal $_GET variable, e.g. $_GET["file"].
PHP supports a wide-variety of C-like file function, for example fopen.
To test your script, create two web pages get.php and set.php.
These pages should provide a form that allows the user to get and set values via your lookup.php script.
A common use of PHP is to include() a standard header or footer containing HTML code shared by all pages on a site.
Develop your own header.php and footer.php and use them from your new get.php and set.php pages.
The your web site design the better.
Part 3.
Create an in-process Apache module version of the name/value pair program.
The module will store the pairs in files in the /var/www directory.
You will need to develop the module in C.
The following instructions show how to build and install a simple module that prints "Hello world!" and returns the passed in query string.
Compile the module: apxs2 -c mod_lookup.c.
Note: You may need to install development tools onto your server first:
sudo apt-get install apache2-dev
Install the compiled module into Apache: sudo apxs2 -i -a -n lookup mod_lookup.la
You should now find that the module has been copied to the /usr/lib/apache2/modules directory.
You should also find that a lookup.load file has been added to your /etc/apache2/mods-available directory with a symbolic link placed in /etc/apache2/mods-enabled.
Configure your Apache server to send requests to a specific subdirectory to your custom Apache module by creating /etc/apache2/mods-available/lookup.conf.
You need to make sure Apache loads the above configuration whenever it starts. To do this, add a symbolic link to the lookup.conf file to the /etc/apache2/mods-enabled subdirectory.
Restart your Apache server.
Test that requests to the /lookup subdirectory are now serviced by the Apache module.
For example, try visiting http://localhost/lookup?name=val
Modify mod_lookup.c to support getting and setting of parameters.
Copy your get.php and set.php pages from Part 2 to get_mod.php and set_mod.php.
Modify get_mod.php and set_mod.php to use your Apache module instead of the PHP script.
Part 4.
Benchmark your PHP and Apache module versions using the Apache benchmark utility ab.
Type ab with no arguments to get a list of its features.
Complete this readme.txt file with the requests per second you measure using ab connecting locally to your server (that is using the base URL http://127.0.0.1).
Run results for both the PHP version and the Apache module version of the application.
Submission.
I will be testing your application by logging into your sever, starting Apache and then going to your get and set pages.
Submit the files lookup.php, set.php, get.php, header.php, footer.php, get_mod.php, set_mod.php, mod_lookup.c, and readme.txt
to the Moodle dropbox.
The Moodle timestamp is the completion time for the assignment.