If you have a LAMP-installation installed on a computer / server(hardware) that has one or more network-interface cards, one of which has a public/Live IP-address, a huge security risk would be to leave your LAMP-installation on the default "localhost or" setting.

Leaving it as default allows your LAMP installation to be accessed from all IP-addresses configured for your server, for example:, http://ip-address#1 and http://ip-address#2 will all resolve to the "It works" Apache page:


If one of your network-interface card's IP address is public/Live, your LAMP installation would also be accessible from the internet by anyone around the world; and just in case your 'PHPMyadmin' directory or some other '/www/DIR' isn't secured, someone can begin to hacker-practice on your machine, for example with http://live-ip-address/phpmyadmin.

In this tutorial, I will explain how to change the localhost-IP address( to an IP-address(assumed static) of one of your network interface cards.

It is thus assumed that LAMP is installed. If not, then read: How to setup a LAMP Server on Debian 6.0.6 Squeeze.

Suppose we have a static-IP: on an interface card and we want to set this as LAMP's default IP-address, just 2-file needs to be edited.

a) hosts file, found at: /etc/hosts. Add a new line with the static-IP of an interface-card and a new hostname.

sample-before: localhost debian

sample-after: localhost debian debian2

save and close the hosts file.

b) 000-default file, found at /etc/apache2/sites-enabled/000-default. Find and edit the first line with "VirtualHost" - at the top.

VirtualHost *:80


save and close the file.


Reload apache2 with command: service apache2 reload

Restart apache2 with command: service apache2 restart



For better security, the default port of LAMP on debian can also be changed: How to change LAMP Default Webserver Port in Debian Squeeze.

Add comment

Security code