Installing LAMP

LAMP = Linux, Apache, MySQL, PHP



1. Installing Linux 

More detailed information from my previous post.

  • Before starting the installation of a new OS make sure you have all the important files from your computer in a safe place (just in case something goes wrong). I used Buffalo's external hard drive (250 Gt).
  • I started by downloading Xubuntu 13.04 (64 bit version) torrent file and used UNetboot to create a bootable memory stick.
  • When the Live USB was done I restarted my computer, pressed F12 during the start-up and navigated myself to Boot manager where I chose to try Xubuntu without installing.
  • I opened the internet browser and made a Google search to lightly test my new OS.  

2. Installing Apache

More detailed information from my previous post.

  • Before installing anything it is important to update in order to get all the newest versions of packages. Do this with the command sudo apt-get update in Terminal.
  • After this start the installation of Apache2 by writing sudo apt-get install apache2.
  • I changed the location folder to user's directory with sudo a2enmod userdir and restarted Apache.
  • When testing functionality you should be able to open "It works!" -page by writing your computer's IP address (or simply localhost) to the address bar.
  • I created a new directory public_html (mkdir public_html) and added there a file called foo (nano foo). The operation was successful since my file appeared in localhost/~xubuntu

3. Installing PHP

  • To start the installation of PHP module use the command sudo apt-get install libapache2-mod-php5
  • Notice that after the installation the PHP module is not working by oneself yet. When visiting /etc/apache2 and using the command grep -ir php we can easily see what lines in which file we have to comment to get the module working. 
Grep-command prints all the wanted elements. In this case we are searching for PHP.

  • Go to the folder /etc/apache2/mods-enabled and start editing the file "php5.conf" with the command sudoedit php5.conf
  • Comment the needed lines with # and save the modified file. 
The modified php5.conf file.
  • Now the module should run fine so let's test it by creating a PHP file to user directory's public_html.
  • As we can see the PHP file is working fine and the code prints the number 4 to my webpage as it should. 
  • But what to do if there is something wrong with the code and the browser only shows you a blank page?
    • Go to the error log /var/log/apache2 and tail error.log
  • Thanks to the error log it is easy to figure out where the problem is. Here we can see that on Sunday 22nd 12:23:25 (GMT+0) year 2013 the error occurred because there was unexpected mark ":" in the file /home/xubuntu/public_html/foo.php on line 2. 


4. Installing MySQL

  • Run the command sudo apt-get install mysql-server. After a moment you are asked to define the root user's password.
  • When the installation of MySQL is done we are able to connect it with phpMyAdmin (sudo apt-get install phpmyadmin.)
  • The next part is really important and without doing it right you are not able to connect phpMyAdmin. Select apache2 with a star (use space key) and continue.
  • Now the installation screen will tell you that you must have a database installed and configured in order to use phpMyAdmin. Since I already did this I select "Yes".
  • Now you will be asked to give the same password you configured for the root user and a new password you never need to use so the wise thing is to leave this space empty and let the computer generate it for you.
  • The installation is done and if everything went as planned phpMyAdmin should be found from localhost/phpmyadmin (once again, put this address to your browser's address bar). You can log in by using the username root and the password you selected before.


I wanted to play a little bit with my shiny new phpMyadmin and created a new database called "Hunting dogs" and inserted there information and values to test it.




Linux version: Xubuntu 12.04, 64-bit

System information - OS: Windows 8 64bit Manufacturer: Dell Inc.Model: Inspiron 3721 BIOS: A05 Processor: Intel(R) Core(TM) i5-3337U CPU @ 1.80GHz (4 CPUs), ~~1,8GHz Memory: 8192MB RAM

Based on Linux course by Tero Karvinen (http://terokarvinen.com/)

Comments

Popular Posts