Archive for October, 2009

[Ubuntu] HOWTO: Restore GRUB (if your MBR is messed up)

October 31, 2009

Don’t forget that this method, as described, puts GRUB back on the MBR (master boot record) of the hard drive instead of in the root parititon. This is fine for most people, but not if you already have an alternative boot manager.

In other words, if you use something like Boot Magic or System Commander, the commands you’ve just read will overwrite what you’ve got.

If you’ve installed GRUB into the Root Partition instead of the MBR, the commands are a little different. Here’s are the instructions that I have for my system:

How to Restore the Grub Menu after a Re-Ghosting:

1. Boot from a Live CD, like Ubuntu Live, Knoppix, Mepis, or similar.

2. Open a Terminal. Go SuperUser (that is, type “su”). Enter root passwords as necessary.

3. Type “grub” which makes a GRUB prompt appear.

4. Type “find /boot/grub/stage1″. You’ll get a response like “(hd0)” or in my case “(hd0,3)”. Use whatever your computer spits out for the following lines.

5. Type “root (hd0,3)”.

6. Type “setup (hd0,3)”. This is key. Other instructions say to use “(hd0)”, and that’s fine if you want to write GRUB to the MBR. If you want to write it to your linux root partition, then you want the number after the comma, such as “(hd0,3)”.

7. Type “quit”.

8. Restart the system. Remove the bootable CD.

Hope this helps. Since I use Norton Ghost to make regular backups and restores (I do a lot of testing), I do this all the time…

[Ubuntu] HOWTO: localhost subdomains

October 1, 2009

Creating subdomain(s) in any web development environment is essential. For example, I have 2 projects going on at the same time and developement is concurrent. And subdomains were not created. So we have this scenario:

  • http://localhost/alphaproject/
  • http://localhost/betaproject/
  • http://localhost/phpmyadmin/

As you can see, I am assuming a Apache/PHP/MySql developemnt stack. 3 localhost urls that will be frequently accessed. Imagine what will happen when you want to access beta project? You “control+t” a new browser tab, and type in “localhost” only to have the url bar showing its history of the above 3 urls. Then you press the down arrow key to access the required url.

Waste of keystroke I will say. Now we create subdomains and we have:

  • http://alphaproject.localhost/
  • http://betaproject.localhost/
  • http://phpmyadmin.localhost/

So now when we want to access beta project? Type in “beta” and simply selected the required “remembered” url. Save some keystrokes and it will save up a a sizable amount of effort over time.

So how to create subdomain in Ubuntu?

Simple, I will cover the basic steps here. (Windows users, sorry, not here my friends).

Edit /etc/host and add the following line

127.0.0.1 alphaproject.localhost

Create a new configuration file in /etc/apache2/sites-available/alphaproject using

gksudo gedit /etc/apache2/sites-available/alphaproject

In this configuration file, have the following:

<VirtualHost *>
    DocumentRoot /home/username/alphaproject/
    ServerName alphaproject.localhost
    <Directory /home/username/alphaproject/>
        Options Indexes FollowSymLinks MultiViews +Includes
        AllowOverride None
        Order allow,deny
        allow from all
    </Directory>
</VirtualHost>

Save the file, and run the following:

sudo a2ensite alphaproject

Finally restart the Apache Server. Which I assume you should be using Apache2.

sudo /etc/init.d/apache2 restart

And by going to http://alphaproject.localhost/ you should be able to access you newly created subdomain.

On a ending note, phpmyadmin does come installed as a package but default to http://localhost/pma which I do strongly encourage users to change it to http://pma.localhost/

Think of the key strokes you be saving. And yes, do name your subdomain smartly, try picking each subdomain to have a different starting character.


Follow

Get every new post delivered to your Inbox.