Category: Ubuntu

Added: 21st of December 2015

Viewed: 2369 times

Install a very basic LAMP server using Ubuntu 15.10

This tutorial works in Ubunbu, Kubuntu, Xubuntu, Lubuntu, Ubuntu Mate and other Ubuntu based distributions. The tutorial also works in Linux Mint and other Debian based distributions.

This tutorial will show you how to set up a very basic LAMP server in Lubuntu, allowing you to create and test your websites locally.


Step 1 - Install Apache2


The first thing we need to do is install Apache2, so open your terminal and enter the following command
sudo apt-get install apache2

After installation open your webrowser and enter the following url http://localhost
You should see the Apache holding page.

Step 2 - Create www folder


Webpages are served from the /var/www directory, but I always find it better to serve the pages from my home directory, so the next thing we will do is create a new www folder on your desktop, then create a new file named index.html inside the www directory, copy and paste the HTML code below and then save the file.
<!DOCTYPE html>
<html>
<head>
<title>Apache Holding Page</title>
</head>
<body> Apache Holding Page </body>
</html>


Step 3 - Change Apache configuration files to serve files from the www directory


Now we need to edit two Apache configuration files to point Apache to the www directory you created earlier
We first need to edit /etc/apache2/sites-available/000-default.conf file
sudo gedit /etc/apache2/sites-available/000-default.conf

When the configuration file opens for editing, find the following:
DocumentRoot /var/www

and change to
DocumentRoot /home/username/Desktop/www


The next file we need to edit is /etc/apache2/apache2.conf
sudo gedit /etc/apache2/apache2.conf

When the configuration file opens for editing, find the following:
<Directory /var/www/html/>
Options Indexes FollowSymLinks
AllowOverride None
Require all granted
</Directory>

and change to:
<Directory /home/username/Desktop/www>
Options Indexes FollowSymLinks
AllowOverride None
Require all granted
</Directory>


Now we need to restart apache2 so the changes to the configuration files take effect, open your terminal and enter the following command
sudo service apache2 restart

After this open your browser and enter http://localhost, apache should now default to the index.html page you create earlier.

Step 4 - Install PHP5, MySQL Database


Now we can go on and install all the other packages, php5, mysql to complete the installation on of our basic LAMP server.

To install PHP5 open your terminal and enter the following command
sudo apt-get install php5

To install PHP5 GD Libarary open your terminal and enter the following command
sudo apt-get install php5-gd

To install MySQL database enter the following command. For the purpose of this tutorial when MySQL asks you for a root password when installing the package, leave this blank.
sudo apt-get install mysql-server

To install the PHP5, MySQL bind package enter the following command
sudo apt-get install php5-mysql

Now we need to restart apache2 so the changes take effect, open your terminal and enter the following command
sudo service apache2 restart


Step 5 - Create a phpinfo file


Next create a file in your www directory named info.php, open the file, copy and paste the code below and save it
<?php
phpinfo();
?>

Open your browser and enter the following URL, http://localhost/info.php to display information about your system
PHP Information file

Step 6 - Success


We have now set up a very basic LAMP server. This is enough to help you develop basic websites locally using PHP, MySQL. This tutorial will be expanded over time.

Other Tips & Tutorials

Ubuntu

How to find out what date you installed Linux on your machine

Posted: 13th of April 2021

Views: 283

Ubuntu

Install bashtop in Ubuntu and Ubuntu based distributions. Monitor your cpu, memory, disks, network and other processes

Posted: 21st of February 2021

Views: 363

Ubuntu

Ubuntu 20.10 Groovy Gorilla installation error, installer crashed

Posted: 3rd of February 2021

Views: 686

Ubuntu

Find out what version of Ubuntu you are running, using the terminal

Posted: 29th of January 2021

Views: 316

Ubuntu

Install Redshift to automatically adjust the colour of your screen depending on time of day on Ubuntu and Ubuntu based distributions

Posted: 26th of November 2020

Views: 726

Ubuntu

PulseAudio, Pavucontrol not saving settings after reboot on Ubuntu and Ubuntu based distributions

Posted: 11th of November 2020

Views: 2539

Ubuntu

No sound after installation of Ubuntu or Ubuntu based distribution, install pavucontrol

Posted: 9th of November 2020

Views: 396

Ubuntu

Shutdown Ubuntu and Ubuntu based distributions at a specific time or within (x) minutes

Posted: 30th of October 2020

Views: 477

Ubuntu

Open and edit files using Visual Studio Code from FIlezilla FTP Client on Linux

Posted: 27th of October 2020

Views: 5685

Ubuntu

Download Microsoft Edge preview version for Ubuntu and Ubuntu based distributions

Posted: 22nd of October 2020

Views: 485