Posts Tagged ‘ubuntu’

If you develop web applications and scripts, it will be nice testing them locally in your own computer before launching them online. This will require the installation of a webserver on your computer.LAMP (Linux, Apache, MySQL, PHP) is one of the easiest and perfect environment where you can test all your PHP codes. In this tutorial, we will help you install the LAMP webserver in the following Ubuntu/Linux Mint distributions:

  • Ubuntu 13.04/12.1012.04/11.10 or older
  • Linux Mint 14/13/12 or older

LAMP Installation

The LAMP webserver can be installed easily with this command (the caret (^) is required, don’t exclude it):

sudo apt-get install lamp-server^

During the installation, you will be asked to enter a new root password for the MySQL database, submit it and press Enter:

You will be prompted to enter the password again for confirmation. Wait now until the installation is complete. You have now installed the LAMP webserver on Ubuntu 11.04/11.10. Let’s now go to the next step.

Testing Apache

Launch your web browser (Firefox, Google Chrome, etc.) and open one of these addresses (or provide your server IP address if needed):



If you get this page, then Apache is started:

Otherwise try to restart Apache with this command:

sudo /etc/init.d/apache2 restart

Then give it another try.

Testing PHP

Let’s now test PHP. You need to create an empty PHP file in /var/www  and insert this snippet of code into it:

<?php phpinfo(); ?>

You can easily do it with these two commands via the terminal:

echo “<?php phpinfo(); ?>” | sudo tee /var/www/test.php

sudo /etc/init.d/apache2 restart

Then open this address:


You should see a page like this:

Configuring MySQL

Since you are using the LAMP webserver locally, your MySQL database must uses the same IP address of your localhost which is: Via the Terminal, run this command to verify it:

cat /etc/hosts | grep localhost

Here is the correct output you must get:

~$ cat /etc/hosts | grep localhost localhost
::1     ip6-localhost ip6-loopback

Also verify that the bind address is set correctly by running this command:

cat /etc/mysql/my.cnf | grep bind-address

You should get this output:

~$ cat /etc/mysql/my.cnf | grep bind-address
bind-address =

If you get a different IP address, then edit the my.cnf file with this command:

sudo gedit /etc/mysql/my.cnf

Search for the line containing “bind-address” and correct its address by replacing it with

phpMyAdmin Installation

If you want an easy GUI for managing your MySQL databases, you can install phpMyAdmin with this command:

sudo apt-get install libapache2-mod-auth-mysql phpmyadmin

During the installation you will be asked to select a web server that will be configured automatically to run phpMyAdmin. Select apache2 using your spacebar and press Enter:

You will be asked next to configure a database for phpmyadmin with dbconfig-common, select Yes and press Enter:

phpmyadmin-dbconfig-commonIn the next screen, enter the MySQL password you have submitted before and press Enter:


Select  NO and press ENTER
And, Type below command in terminal

sudo cp /etc/phpmyadmin/apache.conf /etc/apache2/conf.d

restart your apache server using

sudo /etc/init.d/apache2 restart


Congratulation! phpMyAdmin is now installed in your system. To test it, open simply this address via your web browser:


Login to phpMyAdmin using root as username and the password you created earlier:

phpmyadmin (1)

phpmyadmin (2)

You have now successfully installed LAMP on your system. All your projects and files must be placed in /var/www so that you can run them.

Removing LAMP & phpMyAdmin

To uninstall the LAMP web server and phpMyAdmin, open the terminal and run this command:

for pkg in `dpkg -l *apache* *mysql* phpmyadmin | grep ^ii | awk ‘{ print $2 }’`; do sudo apt-get -y purge –auto-remove $pkg; done;

That’s it!


[Recover grub back again after if it is lost of these reasons– windows 7/xp/vista/8 installation, uninstalled package grub from Linux system.]

So you were enjoying life using Ubuntu and then one day you had to install Windows for that one application your boss makes you use and now no more Ubuntu. When we need a dual boot system it’s always best to install Windows first then Ubuntu due to Windows stripping out the boot loader but what if you have no choice? or a crash that corrupted the boot loader. Boot-repair  to the rescue.

So what is Boot-Repair?
Its a small graphical tool used to restore access to Ubuntu and other OS’s such as Windows when disaster strikes, it has two basic options.(See Figure)  and follow steps below-
  •  run Ubuntu  media in live mode.
  •  connect Ubuntu to Internet source
  • open up a terminal and type the following:
  • sudo add-apt-repository ppa:yannubuntu/boot-repair && sudo apt-get update
  • sudo apt-get install -y boot-repair && boot-repair 
  • click “Recommended repair” and apply.  make sure you leave the “Reinstall GRUB” check-box ticked. Now reboot your system. now you can see GRUB back.

Installing and Configuring Samba Ubuntu 12.04

One of the most common ways to network Ubuntu and Windows computers is to configure Samba as a File Server.
Samba allows file and print sharing between computers running Windows and computers running Unix.  Samba sets up network shares for chosen Unix directories (including all contained sub-directories). These appear to Microsoft Windows users as normal Windows folders accessible via the network.
In this tutorial, we will configure Samba on Ubuntu 12.04 Desktop edition.
First thing to do is to make sure that your Ubuntu system is up-to-date with all the latest packages and updates.
To ensure this, run the following command:
# sudo apt-get update
Once the update completes, we can now setup the Samba server on Ubuntu.
First, we install the necessary Samba packages
# sudo apt-get install samba samba-common

The next thing to do is install Python-Glade.
# sudo pat-get install python-glade2


Before we move ahead further with the installation, it is recommended that you create a user for your Samba Server. This user will be a dedicated user account used with Samba.
To create a new user:
# adduser <username>
NOTE: You need to have root (sudo) privileges to run this command.


The last step is to install the Samba UI. This option is available ONLY in the Desktop editions of Ubuntu. In case you have a Ubuntu Server, then you need not run this command.
# sudo apt-get install system-config-samba


Once installed, we can view the Samba configuration utility by opening the dash and using the search bar to find Samba like so:


To share a folder with Samba, click the green ‘+’ (plus) icon to open a dialogue box called ‘Create Samba Share’ like so:



Complete the ‘basic’ tab with the required information.
  • Directory: Click ‘Browse’ to locate the relevant folder you wish to share.
  • Share Name: Use this field to specify a ‘human friendly’ name for your share folder.
  • Description: Type a description of the ‘share folder’ in this field.
  • Writable: Shared folders are ‘read-only’ by default, so place a tick in this box if you would like to enable ‘write’ access.
  • Visible. Place a tick in this box if you want your share folder to be ‘visible’ on the network.


Following this, we now need to set the permissions for your new share folder.
To do this, simply click the ‘Access’ tab in the same dialogue box like so:
You can select the users you want to have access to Samba Server from here.
NOTE: You can alternatively select “Allow Access to Everyone”, but this setting is not recommended in production environments.



Once your settings are completed, you are now ready to test out your Samba Server



On your Windows system, go to “Network“. If your Ubuntu system is not visible, just refresh the Network.



You will see your shared folder



Depending on your security setting, you may be prompted to enter credentials for the Shared Folder.


If all goes well, you now have a shared folder between your Ubuntu and Windows Server.