I just purchased a vps and made it boot Ubuntu 12.04 LTS, installed LAMP web server and moved my web site. Here’s how did I install and set up the LAMP on Ubuntu 12.04 server. (All commands in this post assumes you have Root privilege, add sudo at beginning if need)

1. LAMP stands for Linux, apache, mysql and php. Ubuntu 12.04 Linux was already running in the case, it just need some configurations on hostname, timezone, static ip, etc.

  • change hostname:
    echo "YOUR_HOSTNAME" > /etc/hostname
    hostname -F /etc/hostname
  • reset timezone:
    dpkg-reconfigure tzdata
  • set static ip if need, edit network file:
    vi /etc/network/interfaces

    adding following lines (change ip and gateway):

    iface eth0 inet static

    remove dhcp:

    apt-get remove isc-dhcp-client dhcp3-client dhcpcd

    restart network service:

    service network restart
  • 2. Now update system:

    apt-get update
    apt-get upgrade --show-upgraded

    Install apache2 and php5 with this commands:

    apt-get install apache2 php5 libapache2-mod-php5

    I have a wordpress website, so Mode Rewrite and alloverride need enabled for .htaccess working. Run this to enable Rewrite:

    a2enmod rewrite

    Edit ‘/etc/apache2/sites-available/default'(I used the default site), change:

    Options Indexes FollowSymLinks MultiViews
            AllowOverride None
            Order allow,deny
            allow from all


    Options Indexes FollowSymLinks MultiViews
            AllowOverride All
            Order allow,deny
            allow from all

    Finally restart apache2 by:

    service apache2 restart

    3. Install Mysql:

    apt-get install mysql-server mysql-client php5-mysql

    while installing, it prompts to set root password for mysql. Login to mysql:

    mysql -u root -p

    You can install phpmyadmin for GUI managing mysql server:

    apt-get install phpmyadmin