LAMP Notes

  1. The Ubuntu Apache config needs a few changes to permit user directories. Go to the directory:

    /etc/apache2/mods-available

    and, as root, copy two files from there to the to the mod-enabled dir in immediately above:

    cp userdir.conf ../mods-enabled
    cp userdir.load ../mods-enabled

    Restart Apache by either rebooting or, as root:

    /etc/init.d/apache2 restart

    Now you should be able to load html files from your public_html directory and execute php programs from your public_html/cgi-bin direct

  2. The following is a link to a dummy test database that can be used to test our configuration. It is a file of SQL commands. Right click and store it in a working directory:

    Database creation script

  3. Hello world PHP program

    <html> <body> <!-- put this program in ~/public_html/cgi-bin, name it p1.php (or some such thing with the php extension), and make it world executable. Invoke it with http://127.0.0.1/~youruserid/cgi-bin/p1.php --> hello world <p> <?php print "hello world\n"; phpinfo(); ?> </body> </html>

    The above will look something like this

  4. Next, test the MySQL installation using the client mysql. This is a line oriented program that can be used to connect with and send commands to the mysql server. Your installation will have man pages on it's options (man mysql). The screen caps show some examples (complete with error messages).

    Screen caps

  5. Accessing data from a browser form.

    Note: I had problems with this because the tutorial spelled the name of the function that is used to get the variables wrong. Trying to fix it, I installed php5 and php-pear before I noticed the spelling error. I believe the problem was solely the spelling error but it is possible that installing those other packages helped. Probably not but there is no way to tell :)

    Browser data access screen caps

  6. Browser to Web server to MySQL and back again.

    Screen caps