This question already has an answer here:

While completing some exercises from a book on HTML5, I reached a chapter about installing a server to test-drive web applications. The problem is the book just assumes all users of Linux distros know which and how to set-up servers on their machines. The author also claims that Linux distros may have Apache installed by default.

Is this the case with Ubuntu 16.04? If so, how do I access it to test-drive my web apps? If not, what alternative do I have?

marked as duplicate by muru, Fabby, karel, Zanna, user364819 Jul 21 '17 at 8:51

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

  • apache is not installed by default, but I do believe it is available in the repos, do you have the universe repository enabled? – ravery Jul 21 '17 at 3:18
  • While LAMP might be overkill, it's easy to set up. Also see: help.ubuntu.com/lts/serverguide/httpd.html, askubuntu.com/q/46331/158442 – muru Jul 21 '17 at 3:24
  • @muru Isn't the op asking only about apache? – fosslinux Jul 21 '17 at 3:33
  • Yes he is, but he's also new and LAMP is easy... – Fabby Jul 21 '17 at 6:27

I'd suggest you keep things simple. You can install Apache2; MySQL; PHP and all the required dependencies with a single command.


From your terminal, type:

sudo apt install lamp-server^

If you have sudo rights, you'll then be prompted for your password. Enter your password, and apt will pull together a list of required dependencies.

It will then ask you if you would like to confirm the installation of these packages.

Press the Y, then the Enter key

During the installation of the packages, you will see your screen change to something like this:

enter image description here

Enter a new root password for MySQL. This is the MySQL administrator password that you will use for making adjustments to databases and user permissions.

You'll be prompted again:

enter image description here

Enter your new root password again, and press Enter


This will install and start Apache2; MySQL and PHP 7.

The root directory for your website will be:


You can put your files in this directory, and the web address will be:

http://<ip address of server>/


Remember, that there is already an index.html inside the /var/www/html that you will probably need to replace or remove.

  • 1
    Wow, thank you so much for the detailed write-up. Got me up and running immediately. – Matt Jul 21 '17 at 17:27
  • 1
    +1 most useful for beginners like me !! – 151291 May 22 '18 at 8:10

Matt, as you've asked about alternatives for test-driving your web apps, you can simply use Python's built-in web server called with python -m SimpleHTTPServer. This works very well for basic needs.

I mention this because, unless there's a need for specific Apache features, you can skip the install of the LAMP stack entirely, as Ubuntu 16.04 already has Python installed, which gets you SimpleHTTPServer with zero installation.


I suggest following this article: https://www.digitalocean.com/community/tutorials/how-to-install-linux-apache-mysql-php-lamp-stack-on-ubuntu-16-04

LAMP stands for Linux, Apache, MySQL, PHP. Since I assume you only want to run a simple website, you don't need MySQL or PHP.

Or, if you don't need to open it to the outside world, you could try something even easier and simpler like livereload


If you need a webserver you can use the built-in webserver for Python for example, richbl, mentioned it already, PHP built-in webserver or even NodeJS webserver which are pretty easy to install.

Honestly, my advice, don't install such tools directly on your system. You can better use Vagrant to do that. You can use for example ScothBox from sctoch.io which comes with dozens of pre-installed tools for web development.

The only thing you need to do is installing Virtual Box on your system and then downloading that scotch box. The benefit of using such a solution is really remarkable because if you mess up with configuration or anything else related to the webserver, you can easily do a vagrant destroy and then everything will be deleted (remember don't forget to backup your files from /var/www before doing that). And then doing vagrant up for a new scotch box after downloading it from the internet.

Maybe it will be a little bit difficult to get the whole idea of vagrant and vagrant boxes, but believe me it's really handy to have such environment for developing. The big benefit is keeping you OS really clean from messy web development tools because you don't need to have Apache running all the time on your OS while you will need it just once or twice.

Not the answer you're looking for? Browse other questions tagged or ask your own question.