Installing LAMP server to Ubuntu

  1. Installation
  2. If you have not already installed LAMP software, you can read my First steps after installing Ubuntu post, for installing the necessary Server software.

  3. Configuration
  4. if apache starts, you can see the below error in terminal.
    apache2: Could not reliably determine the server's fully qualified domain name, using for ServerName

    To rectify run the below code from terminal
    sudo echo "ServerName localhost" | sudo tee -a /etc/apache2/apache2.conf

  5. Adding Virtual Host
  6. By default, Ubuntu place its web root at /var/www. Since, we want to have have multiple hosts for development, add virtual host. We also want, to mimic the cpanel configuration we have at the production server.
    copy the default file to your new host name. It is not mandatory to have the host name, but it is easy to remember if you follow this convention.

    sudo cp /etc/apache2/sites-available/default /etc/apache2/sites-available/example

    Now edit the example file so that it reads as below.

    ServerName “http://example”

    DocumentRoot /home/yourhomedir/public_html

    Options FollowSymLinks
    AllowOverride None

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

  7. Enabling the availble site http://example
  8. We want to have the production server name minus the .com or .net in the local development server, we can now enable our site using the command

    sudo a2ensite example

  9. Adding host name to the hosts file
  10. Since your Server does not know how to resolve the name http://example, configures the hosts file accordingly.

    gksu gedit /etc/hosts
    add the host name example next your existing machine name. yourmachine example

  11. Changing the process owner of Apache2
  12. It will be very difficult for us to change the username between apache default username ‘www-data’ and ‘your username’, every time you add a new webfolder/host, so change the apache process name to your username and group.

    gksu gedit /etc/apache2/envars

    change the two lines in file envars, so that it looks like below.

    export APACHE_RUN_USER=example
    export APACHE_RUN_GROUP=example


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s