Home » Linux » How To » Install LAMP stack on Ubuntu 16.04

Install LAMP stack on Ubuntu 16.04

Install LAMP stack is very well known to those who are already running their website on the any VPS or Dedicated server. In this tutorial I will show you how to install lamp stack on ubuntu 16.04 LTS system.

Who are recently moving to the hosting-by-myself community, the following illustration must be useful.

LAMP is pretty simple, its abbreviation of Linux, Apache, MySQL, PHP. So basically its a bunch of software to run PHP-MySQL script like WordPress, Joomla, Drupal.

The setup is also pretty simple.

Lets Install LAMP stack on Ubuntu 16.04 server.
Step 1

Install the packages

# apt-get update
# apt-get upgrade
# apt-get install apache2 mysql-server php libapache2-mod-php php-mysql php-gd php-mcrypt

If you are wish to run a single website this is enough. Add your web content to the ‘/var/www/html’.

If you want to install multiple website, please continue..

In order to host multiple website, need to setup apache vhost.

Step 2
Create vhost directory and vhost configuration files

# mkdir -p /var/www/vhosts/abc.com/httpdocs
# mkdir -p /var/www/vhosts/xyz.com/httpdocs
# touch /etc/apache2/sites-available/abc.com.conf
# touch /etc/apache2/sites-availabe/xyz.com.conf

Write down the below snippet to the file, change the site name accordingly

<VirtualHost *:80>
 ServerName abc.com
 ServerAlias www.abc.com
 ServerAdmin webmaster@abc.com
 DocumentRoot /var/www/vhosts/abc.com/httpdocs

ErrorLog ${APACHE_LOG_DIR}/error.log
 CustomLog ${APACHE_LOG_DIR}/access.log combined
 </VirtualHost>

Step 3
Enable the sites. The following command will create a symlink to /etc/apache2/site-enabled/

# a2ensite abc.com.conf
# a2ensite xyz.com.conf
# service apache2 reload

Place your web content files under /var/www/vhosts/abc.com/httpdocs and /var/www/vhosts/xyz.com/httpdocs accordingly.

Now your website is ready.

install-lamp-on-ubuntu-16.0

 

Congratulation’s! You have successfully installed LAMP. Thanks for using this tutorial for installing LAMP on Ubuntu 16.04 LTS system. For additional help or useful information, we recommend you to check the official Apache website.

Check Also

Install kernel 4.12 in centos 7

How to Install Kernel 4.12 in CentOS 7

Back in May, Linus Torvalds released Linux kernel 4.11, which was codenamed Fearless Coyote. It came …

Leave a Reply

Your email address will not be published. Required fields are marked *

%d bloggers like this: