Tutorial: Part 2: Setting up a Test Website

From Free Geek Toronto
Jump to: navigation, search

by Eugene Ruthven, 20110427

This is to be done after Part 1: Turn a GeekBox into a Web Development Box. This was about turning an Ubuntu Desktop computer into a box on which web development can take place.

1.Click Places

2.Click Home Folder

3.Double-click Public folder

4.Click File

5.Click Create Folder

6.Change untitled folder → aatest

7.Double-click aatest

8.Click File

9.Click Create Folder

10.Change untitled folder → logs

11.Click Applications

12.Click Accessories

13.Click Terminal

14.Type sudo nautilus and hit Return – type your password when asked

15.Go to File Systemetcapache2sites-available

16.Right-click default

17.Click Open with gedit

18.Highlight <VirtualHost *:80>....</VirtualHost>


20.Hit Down-arrow

21.Hit Return twice

22.Ctrl+V (pasting text)

23.Remove all lines except:

i) ServerAdmin

ii) DocumentRoot

iii) ErrorLog

iv) CustomLog

24.Change DocumentRoot /var/www to DocumentRoot /home/fgtuser/Public/aatest

25.Change ErrorLog /var/log/apache2/error.log to ErrorLog /home/fgtuser/Public/aatest/logs/aatesterror.log

26.Change CustomLog /var/log/apache2/access.log combined to ErrorLog /home/fgtuser/Public/aatest/logs/aatestaccess.log combined

27.Add the line: ServerName aatest

28.Save file

29.In gedit, open /etc/hosts

30.Add line: aatest below the other lines

31.Save hosts file

32.Click Applications

33.Click Programming

34.Click Bluefish Editor

35.Close Bluefish tip

36.Type this is the aatest website

37.Save as index.html in fgtuser/Public/aatest

38.In Terminal type: sudo /etc/init.d/apache2 restart and hit Return

39.Go to FireFox, and in a new tab type aatest and hit Return

40.You should see: this is the aatest website This means your test website is available to have html pages for a website installed or created.

41.Back to Bluefish

42.Start a new document

43.Type: <?php phpinfo(); ?>

44.Save as aainfo.php in /fgtuser/Public/aatest folder

45.In FireFox, type aatest/aainfo.php and hit Return

46.You should see a page with PHP Version...ubuntu.. at the top of it – this means php scripting works – you can create php files in aatest and do serverside scripting

47.In FireFox, type localhost/phpmyadmin

48.For Username type root, For Password type your password and click Go

49.In box under Create new database, type aatest and click Create button to its right

50.In box under Create new table on database aatest , type test and in Number of fields type 2 and click Go at the right side

51.In box to right of Field type testid and check AUTO_INCREMENT

52.In second box beside Field type testname, in Type dropdown box pick VARCHAR, in box under VARCHAR and for Length/Values type 20

53.Click Save

54.You should see a message Table 'aatest'.'test' has been created.

55.Click Insert at top

56.In box to right of testname type Bill

57.In second box to right of testname type Susan

58.Click Go below and at end of either name

59.You should see a message about 2 row(s) inserted

60.Click Browse

61.You should see 2 rows:

testid testname

1 Bill

2 Susan

62.Click Insert again

63.Again, for testname, in the top box type Elizabeth and in the bottom box type Henry

64.Click Go below and at end of either name

65.Again, you should see a message about 2 row(s) inserted

66.Click Browse again

67.Again, you will see a list of names – this time 4 rows:

testid testname

1 Bill

2 Susan

3 Elizabeth

4 Henry

68.Go back to Bluefish

69.Start a new document

70.Type the following:


$mysqli = new mysqli('localhost','root','password','aatest');

if ($result = $mysqli->query("SELECT testid, testname FROM test")) {

echo '<p>there are '.$result->num_rows.' rows/names.</p>';

while ($row = $result->fetch_object()) {

echo 'testid: '.$row->testid.', testname: '.$row->testname.'<br />';


} else {

// Notice below that the errors are still contained within the mysqli class. This means

//that each result will affect a single "error" property. In otherwords, if your result fails,

//the error returned from MySQL is assigned to the property "error".

// This means the query failed

echo $mysqli->error;

} // end else



71.Save as aadb.php in /home/fgtuser/Public/aatest

72.Go to FireFox and type aatest/aadb.php and hit Return

73.You should see a list of names from the table you had created. This means that you can create php pages that can read info from and insert info into a database.