Category Archives: Linux

Install LAMP in UBUNTU 12.10 / 13.04 / 13.10

I installed Ubuntu 12.10 on my new laptop and now I have to setup LAMP on it. To setup LAMP I need to install Apache Web Server, PHP and MySQL.
For installation issue following commands:

Above command will download and install Apache Web Server. It will ask for permission to download the setup file. After completion of above command open the browser and browse following URL:

If it is opening properly, your web server is installed properly. Now we will install PHP:

Above command will download and install PHP and apache integration library. It will ask for permission to download the setup file.
To check the installation of php issue following command:

Write following code in this file and save it:

In the browser open following URL:

It will display PHP configuration details. We have installed PHP and integrated it with Apache Web Server.
If you are not getting required page the you need to restart Apache:

Our next task is to install MySQL server and PHP-MySQL connector. For this issue following command:

If you are running Ubuntu 13.10, issue following command:

It will download and install MySQL Server. After installation it will ask to setup root password for database server.
Now we have installed Apache Web Server, PHP and MySQL. For database management you may need phpMyAdmin. To install phpMyAdmin issue following command:

After installation open following URL:

You will get the login screen of phpMyAdmin.

Congrats, You are done!!

Android USB Tethering in UBUNTU 12.04

I was struggling to use the internet connection of my Android in my laptop. I
searched on google and fond that Ubuntu recongnize it automatically if USB
tethering is enabled on the connected Android phone. Then I tried to enable the
USB modem interface usb0 using following command:

it gave me following error:

Ignoring unknown interface usb0=usb0.

Then I checked the file /etc/network/interfaces. I found there is no entry for
usb0. I added following lines at the end of the file:

and again tried the above command but this time it gave me following message:

Rather than invoking init scripts through /etc/init.d, use the service(8)
utility, e.g. service smbd reload

Since the script you are attempting to invoke has been converted to an
Upstart job, you may also use the reload(8) utility, e.g. reload smbd

Then I tried following command and was able to use internet on my laptop.

Sync Multiple Eclipse to a Single GitHub Repository

I configured eclipse and eGit in two different laptops to integrate my git repository with my development copy of source code. Now I can easily make changes in local repository and push it to github. But the problem is if I am editing something in first laptop and pushed it to github. Now on the second laptop I dont have the latest code. So I need to pull from github. I search a lot in eclipse but unable to find anything useful. After putting a lot of efforts I finally found a way to pull the code from github using command line. I just need to add a new repository. Let us call it upstream. To do this I issued following command:

Adding Virtual Host to Apache in Ubuntu

Now that I have Ubuntu installed on my computer and the Apache web server is working. I need to configure a virtual host. Right after you get Apache going, it defaults to serving from a default location, in this case /var/www. Any http requests coming into the box are all routed to that directory.

But Apache supports multiple hosts and I want to add one virtual host to Apache so that if I route say to my IP, I want it to be served from its own directory. The default /var/www has system ownership and would need to be changed. So I’m going to create a directory for site under my user directory. So I’ll create /home/rashid/htdocs/example to host the files for this site.

Step 1: create /home/rashid/htdocs/example to host the files for this site.

Now we need to make Apache use them. In the default configuration, Apache is already set up to support multiple virtual Hosts. In order to get the new sites working, we need to create a couple of configuration files in the /etc/apache2/sites-available directory, then enable them, and then restart Apache.

If you look in the sites-available, you’ll find a file called default. This represents the default Apache serving configuration. Copy this file twice to serve as a basis for the new configuration files.

Step 2: cd /etc/apache2/sites-available
sudo cp default example

You need to make two or three changes to this file, and add one line.

Step 3: Put your email address against ServerAdmin. If you want, you can make the value a real e-mail address.

Step 4: There are also two lines labelled DocumentRoot and another in a <Directory> statement that have the path to the directory being served – in this case, it should be /var/www/. Change both of those to the directory that will contain the new site files – /home/rashid/htdocs/example/.

Step 5 : Now after the ServerAdmin line add a new line:

Step 6: If you want to have nickname of your host then add a new line after ServerName:

Now we have to tell Apache to serve the new domains. Ubuntu has a couple of convenience commands to enable and disable sites.

Step 7: So, to enable the new sites, enter sudo a2ensite example1 . This command copy the configuration files you created into the /etc/apache2/sites-enabled directory. We’re almost there.

Finally, you have to restart Apache2 so that it reconfigures to serve the new sites.

Step 8: Simply enter sudo /etc/init.d/apache2 reload.

Now we are done with the virtual host configuration in easy 8 steps.

Change Network Card MAC Address in Ubuntu

There are a lot of reasons you might want to manually set your MAC address for your network card.

To change this setting, we’ll need to edit the /etc/network/interfaces file. You can choose to use a different editor if you’d like.

sudo gedit /etc/network/interfaces

You should see the line for your network interface, which is usually eth0. If you have dhcp enabled, it will look like this:

auto eth0
iface eth0 inet dhcp

Just add another line below it to make it look something like this:

auto eth0
iface eth0 inet dhcp
hwaddress ether 01:02:03:04:05:06

Obviously you would want to choose something else for the MAC address, but it needs to be in the same format.

sudo /etc/init.d/networking restart

You will need to restart networking or reboot to take effect.