Cs 350 Lab 1

Run your personal wikipedia

The purpose of this lab is to make sure everyone has a working Apache web server, MySQL, PHP stack that they can use in class.

The lab has three parts:

  1. Install the web server, MySQL server, and PHP
  2. Install mediaWiki (the wiki used by wikipedia)
  3. Demo the install by editing and viewing wiki pages.

If you have a laptop, I encourage you to bring it to class and install the development stack on it. If you don’t have a laptop you should install the stack on a USB memory stick.

Please follow the Run Your Personal Wikipedia from a USB Stick

Grading

Through in-class demo

  • using browser directed at http://localhost/ displaying XAMPP welcome page or other html page. 50 points
  • Run through a basic wiki demo including editing pages similar to the video on the Run your personal wikipedia 45 points
  • add logo to site 5 points

Part 2 – trying mySQL and PHP

2.1 MySQL

Here is the scoop on how to run the SQL commands described in the textbook.

  1. Open up a terminal window and change directory to your XAMPP install.
  2. Change directory to xamppfiles/bin (Mac) or mysql/bin (Windows).
  3. Start mySQL by executing mysql -u root -p (the -u root means username = root, the -p means prompt for a password.
  4. You will be prompted for a password, type it in.
  5. Now you can start executing SQL commands as described in the book. For example, you can create a database called gregs_list and a table called doughnut_list as follows
>Ron-Zacharskis-iMac:bin raz$ ./mysql -u root -p

Enter password:

Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 28
Server version: 5.1.37 Source distribution

Type ‘help;’ or ‘\h’ for help. Type ‘\c’ to clear
the current input statement.

mysql> CREATE DATABASE gregs_list;
Query OK, 1 row affected (0.00 sec)

mysql> USE gregs_list;
Database changed
mysql> CREATE TABLE doughnut_list
-> (
-> doughnut_name VARCHAR(10),
-> doughnut_type VARCHAR(6)
-> );
Query OK, 0 rows affected (0.02 sec)

mysql> DESC doughnut_list;
+—————+————-+——+—–+———+——-+
| Field | Type | Null | Key | Default | Extra |
+—————+————-+——+—–+———+——-+
| doughnut_name | varchar(10) | YES | | NULL | |
| doughnut_type | varchar(6) | YES | | NULL | |
+—————+————-+——+—–+———+——-+
2 rows in set (0.01 sec)

mysql>

You can view what you have done using phpmyadmin (will demo in class).

2.2 PHP

In the xampp htdocs folder create a folder called test and in that folder create a file story.html with the following content.

<!DOCTYPE html PUBLIC “-//W3C//DTD XHTML 1.0 Transitional//EN”
“http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd”>
<html xmlns=”http://www.w3.org/1999/xhtml” xml:lang=”en” lang=”en”>
<head>
<meta http-equiv=”Content-Type” content=”text/html; charset=utf-8″ />
<title>Your Life</title>
<link rel=”stylesheet” type=”text/css” href=”style.css” />
</head>
<body>
<h2>Your life</h2>

<p>Share your story</p>

</body>
</html>

This is just standard static html. You should be able to view this file by pointing your browser to http://localhost/test/story.html

Now we are going to add some PHP code to this file. PHP code is delimited by the starting string <?php and the ending string ?> First, copy the file story.html to story.php (files that contain php code must end with .php). We are going to add a few lines to print out the standard ‘Hello World’:

<!DOCTYPE html PUBLIC “-//W3C//DTD XHTML 1.0 Transitional//EN”
“http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd”>
<html xmlns=”http://www.w3.org/1999/xhtml” xml:lang=”en” lang=”en”>
<head>
<meta http-equiv=”Content-Type” content=”text/html; charset=utf-8″ />
<title>Your Life</title>
<link rel=”stylesheet” type=”text/css” href=”style.css” />
</head>
<body>
<h2>Your life</h2>

<p>Share your story</p>

<?php
echo(“Hello World”);

?>

</body>
</html>

Point your browser to http://localhost/test/story.php to see the results.

Finally, here is a short php file that prints out lots of information about the XAMPP install.

<?php
phpinfo();
?>