In this topic (which will span through several posts) I will share my experiences in creating a dynamic web page on the example of www.epska.org, the site I am currently building on my own from scratch (unlike this blog, which is done using the Drupal CMS). It is dynamic on several levels:
1. content is separated from design using a .css file
2. navigation menu, header and footer are separated from the content of the page by using the php include function.
3. content is dynamically extracted from a MySQL database
In this first part, we will install and set up a working localhost server – for debugging or (in case you have your own server) actual hosting of the web site.
Update: I found out that the prefered method of installation is actually:
sudo tasksel install lamp-server
You can install an Apache MySql PHP server in Ubuntu by installing the following packages:
apache2 php5-mysql libapache2-mod-php5 mysql-server
This can be done either through Synaptic or through the terminal with:
sudo apt-get install apache2 php5-mysql libapache2-mod-php5 mysql-server (I only tested it in Synaptic)
You can also install phpmyadmin, a nice graphical tool for administering the database. Of course by… sudo apt-get install phpmyadmin. After the installation, a small change to the apache conf file is necessary. gksudo gedit /etc/apache2/apache2.conf and then add the line Include /etc/phpmyadmin/apache.conf to it. In the end you just restart apache by issuing sudo /etc/init.d/apache2 restart.
This should be all. LAMP server functionality can be tested by opening localhost from your favourite browser. A nice “It works!” sign should appear… If so, rejoice!
If you want to change the default apache folder (/var/www) you can do it by doing: gksudo gedit /etc/apache2/sites-available/default. Here you have to change both occurrences of “/var/www” to your desired location. I suggest commenting the original line (with a #) so that you can return the original values if necessary.
If you want to take a first few bytes off of your MySQL goodies, you can try these here few steps:
– create a database – for example using phpmyadmin – just to see how simple it is
– create a user – let’s do this from the command line (couldn’t find it in phpmyadmin 😀 edit: just found it – it’s under privileges). First from the terminal we kick the thing off with a mysql -u root -p (you will be prompted for a password – the one you set during the installation). You should now have a nice “mysql>” prompt. We do the actual work with create user username identified by ‘userpassword’;. Piece of cake.
You can do most things – like creating tables, inserting entries etc. in a similar way. MySQL Reference Manual is a good source of information (in addition to good ol’ googlin’).
So much for part 1…