howtutorials linux

Posts Tagged ‘php in ubuntu’

Install a LAMPP server and Joomla in localhost

Posted by geekubuntu on December 16, 2008

Firstly, type the following command at the console:

sudo apt-get update

This will retrieve new lists of packages.

1.Install MySQL5 in Ubuntu

sudo apt-get install mysql-server-5.1

2.Install PHP MyAdmin

sudo apt-get install phpmyadmin

3.Install Apache2 in Ubuntu

sudo apt-get install apache2

This will complete the installation.

After installation Type the server’s IP address (or alias if you added the server to your /etc/hosts file) in your browser’s address bar or, if you are browsing on the server itself, type or localhost. If an error occurs, then you will have to edit the apache2.conf file to ensure that Apache can fully resolve the server’s name.If you have any problem then you have to edit the apache2 configuration file using the following command

sudo nano /etc/apache2/apache2.conf

Add the following type, at the lowers line

ServerName localhost


ServerName yourserverip

Include /etc/phpmyadmin/apache.conf

Save and exit, now you need to  restart Apache server using the following command.

sudo apache2ctl restart

4.Change default document root in Apache2

The main configuration file located at /etc/apache2/apche2.conf.If you want to change the default document root you need to edit the /etc/apache2/sites-available/default file and look for this line “DocumentRoot /var/www/” here you can change where ever you want to change.For example if you want to change /home/www the above line looks like this “DocumentRoot /home/www/”.

Save and exit the file

Now you need to  restart Apache server using the following command.

sudo apache2ctl restart

5.Enable PHP support for apache2 webserver

If you want to enable php5  support to your apache webserver use the following commands to install require packages

sudo apt-get install php5 libapache2-mod-php5

You also make sure the php5 modules are enabled using the following commands

sudo a2enmod php5

After installing php support you need to restart apache webserver using the following command

sudo apache2ctl restart

6.Test your PHP Support foe apache webserver

To check the status of your PHP installation

sudo nano /var/www/testphp.php

and insert the following line

<?php phpinfo(); ?>

Save and exit the file

Now open web browser at http://yourserveripaddress/testphp.php and check.

7.Enable CGI and perl support for apache2 server

You need to install the following package

sudo apt-get install libapache2-mod-perl2

8.Configure a cgi-bin directory

You need to create a cgi-bin directory using the following command

sudo mkdir /home/www/cgi-bin

Configuring Apache to allow CGI program execution is pretty easy. Create a directory to be used for CGI programs and add the following to the site configuration file (again between the <VirtualHost> tags).

ScriptAlias /cgi-bin/ /home/www/cgi-bin/

<Directory /home/www/cgi-bin/>

Options ExecCGI

AddHandler cgi-script cgi pl


The first line creates an alias that points to the directory in which CGI scripts are stored. The final line tells Apache that only files that end with the *.cgi and *.pl extensions should be considered CGI programs and executed.

9.Test your Perl Program

cd /home/www/cgi-bin
sudo nano perltest.pl

Copy and paste the following section save and exit the file.


#!/usr/bin/perl -w

print “Content-type: text/html\r\n\r\n”;

print “Hello there!<br />\nJust testing .<br />\n”;

for ($i=0; $i<10; $i++)


print $i.”<br />”;



make sure you change permissions on it

sudo chmod a+x perltest.pl

Now open your web browser open http://yourserverip/cgi-bin/perltest.pl.It should be working.

10.Installing Joomla in ubuntu

Set a mysql-root password (not the same as a root password, but a password for mysql)

Type the following command at the console:

mysql -u root

then type:

mysql> SET PASSWORD FOR ‘root’@’localhost’ = PASSWORD(‘yourpassword’);

mysql> SET PASSWORD FOR ‘root’@’yourhostname’ = PASSWORD(‘yourpassword’);

Where you should change ‘yourhostname’ in last line. Each successful mysql command will show:

Query OK, 0 rows affected (0.00 sec)

Quit the mysql prompt:

mysql> \q

You should now have a functional LAMP stack and a password for the mysql root user.

Visit Apache PHP MySQL for more information on LAMP.

Get the most recent version of Joomla!

Download it from [http://joomlacode.org/gf/download/frsrelease/111/264/Joomla_1.0.12-Stable-Full_Package.tar.bz2] here.

Put on the Desktop

You need to create a joomla directory using the following command:

on root@ubuntu:/var/www#

mkdir joomla

Unpack it

on root@ubuntu:/home/ubuntu/Desktop#

tar -xzvf Joomla_1.0.12-Stable-Full_Package.tar.bz2 -C /var/www/joomla

And then:

on root@ubuntu:/var/www#

chmod 777 -R joomla

Handle ownership (choose one option):

# 1. Allow writting in whole joomla subtree

sudo chown -R www-data:www-data /var/www/joomla

# 2. Allow writting only in places Joomla! needs to write to (more secure)

sudo chown -R root:root /var/www/joomla

Then type:

cd /var/www/joomla




















for i in $PLACES; do

sudo chown -R www-data:www-data $i


Handle file and directory permissions:

cd /var/www/joomla

sudo find . -type f -exec chmod 644 {} \;

sudo find . -type d -exec chmod 755 {} \;

Joomla needs a database, user and password

You need to create a database. You can do this with PhpMyAdmin or via the command line:

mysqladmin -u root -p create joomla

Where joomla is the name you picked for the mysql database that joomla will use. You can call it anything you want.

mysql -u root -pmysql> GRANT SELECT, INSERT, UPDATE, DELETE, CREATE, DROP, INDEX, ALTER, CREATE TEMPORARY TABLES, LOCK TABLES ON joomla.* TO ‘yourusername’@’localhost’ IDENTIFIED BY ‘yourpassword’;

You do not want to have Joomla use the mysql root user to access the database. The above command creates a mysql user (other than the mysql root user) with some priviledges to use the joomla database. You will need to chose the yourusername and yourpassword. If the command was successful, activate the new permissions:


Quit the mysql prompt:

mysql> \q

Reload Apache2

You may need to force-reload apache2 so that it knows to use the php module if you haven’t done so since you installed the LAMP stack.

sudo /etc/init.d/apache2 restart

Finish installation

Point your browser to localhost/joomla, and follow the onscreen instructions.


Posted in Tutorials | Tagged: , , , , , | 8 Comments »