Tutorial: Part 1: Turn a GeekBox into a Web Development Box

From Free Geek Toronto
Jump to: navigation, search

by Eugene Ruthven, 20110504

Turning a GeekBox (pc with Ubuntu Desktop installed) into a web development box – why do this?

This is of interest to someone who wants to develop websites – for their own use, for an intranet for an office/company or a home, or for being hosted at an isp.

This is of particular interest to a website being hosted at an isp because in most cases the operating system would be a Linux flavour.

The ability to mimic an isp's environment on your own box is a major consideration – can set up memory limits, .htaccess files, determine what modules are needed for your app and what needs to be on the isp for the app to work.

In a Linux environment, case matters for file and folder names – unlike in a Windows environment – so any typing errors can be caught early.

To do web development, need:

1. a web server – Apache is the first choice

2. a database – for database backed websites – for things like Joomla!, Drupal, Wordpress, SugarCRM – mysql is the first choice

3. a scripting language – php is the first choice – but another can be easily used

4. a text editor – recommend Bluefish

5. a database administration tool – phpMyAdmin is a top one

Since the GeekBox is a Linux box, what this will show you is how to setup a LAMP box (LinuxApacheMysqlPhp).

Are these already installed?

How to check:

1.Click Applications

2.Click Accessories

3.Click Terminal

4.Type sudo sysv-rc-conf and hit Enter

5.Type in your password when asked --> password and hit Enter

 if get command not found
   i) need to install it
   ii) go to Applications --> Ubuntu Software Center
   iii) in search box type sysv-rc-conf 
   iv) should get SysV init runlevel configuration tool for the terminal
   v) click Install
   vi) enter your password when asked
   vii) wait for installation to be completed

6.You will be shown a list of services currently running on your box – look for apache and mysql – if they are not there, you will need to install them (php will not appear)

Assuming they are not there here is an easy way to install them:

7.Go System --> Administration --> Synaptic Package Manager

8.Enter your password when asked

9.Click Edit

10.Click Mark Packages by Task

11.Get a window with the title: Which tasks should be performed by your computer?

12.Find LAMP server and click its checkbox

13.Click OK

14.Get a window with the title: Mark additional required changes? Click Mark

15.Click Apply

16.Get a window with the title: Apply the following changes? Click Apply again.

17.Wait for download of package files and for their installation.

18.Get a window with the title: Configuring mysql-server-5.1, enter your password for root and click forward.

19.Repeat the typing of your password, click forward again.

20.Wait some more

21.Get a window with the title: Changes applied, click Close

22.Close Synaptic Package Manager

23.Open Terminal again.

24.Type sudo sysv-rc-conf and hit Enter

25.You should see apache2 and mysql in the list – if so – done, if not – go back and start from the beginning.

26.A simple test to see if apache2/webserver is working: open FireFox and type http://localhost and you should get a page saying It works!

27.Another way to see if apache2 and mysql are running: go into terminal again and type sudo service apache2 status and hit Return – and you should see that it's running – if not – go back and retry the steps.

Do the same thing for mysql by typing sudo service mysql status and hit Return – and you should see that it's running – if not – go back and retry the steps.

28.To try mysql – go into terminal and type mysql -u root -p and hit Enter

29.Type your password when asked and hit Enter

30.You will get the mysql> prompt.

31.Type show databases; and hit Enter and see the list of databases created by default (actually used by mysql to do its own thing)

32.Type quit at mysql> prompt to leave mysql

33.To actually create php and web page files you can use gedit as your text editor from Accessories but this is only suitable for quick fixes – not for extensive use for php, html and javascript.

Install Bluefish Editor by going to Applications --> Ubuntu Software Center and typing bluefish in the search box – it should come up first in the list – click Install

34.Wait for it to be installed.

35.When done you will find it at Applications-->Programming-->Bluefish Editor

36.Another useful tool to install is phpMyAdmin – for working with mysql databases – do not use Ubuntu Software Center – this method doesn't handle a mysql installation with a password – instead go back into Terminal and type sudo apt-get phpmyadmin and hit Enter

37.You will be asked for your mysql password – just put it in when asked

38.When it's done go into FireFox and type http://localhost/phpmyadmin and hit Enter

39.You should get the login page appear – just type root for the username and your password

40.You will be able to create and manipulate databases from within a web browser.


42.See Part 2: Setting up a Test Website – to see examples of:

 i) setting up a test website
 ii) creating a sample html page
 iii) creating a sample php file
 iv) creating a sample php file with database access