Is it possible to install laravel alongside other websites (on localhost) ?

Posted May 23, 2017 6.8k views
ApacheUbuntu 16.04

I installed laravel on ubuntu 16.04 in that folder /var/www/html/
But when i use this :
sudo a2dissite 000-default.conf
sudo a2ensite laravel.conf
My localhost does not display the contents of the folder.
What i want is localhost/laravel to show the laravel page
and localhost to show the other websites

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Submit an Answer
4 answers


One VirtualHost handles one domain or sub-domain, such as (basic example).

So if, for example, 000-default.conf was setup to handle, it would also handle:

or even:

VirtualHosts only need to be setup for domains and sub-domains.

If you can post the contents of both files to a code block (click the </> icon and post the contents between the backticks), we can take a look at them to see if there’s anything that may cause issues.

So i need to create a virtual host file for each of my website , even a wordpress one?

/var/www/html/ -> /etc/apache2/sites-available/
/var/www/html/ -> /etc/apache2/sites-available/

and disable the default conf -> sudo a2dissite 000-default.conf

Or is it better to put all the websites not done with laravel on a folder inside /var/www/html/examples
and create a virtual host file for this folder -> /etc/apache2/sites-available/examples.conf


It really depends on how you want to set things up. For example, if I was to setup a new site, I would probably use something such as this for my VirtualHost. I’ll use as my filler domain – you’d simply replace that with your own.

<VirtualHost *:80>
    ServerAdmin webmaster@localhost

    DocumentRoot /var/www/html

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

The above sets up a standard Port 80 (HTTP) VirtualHost block that responds to:


The type of site doesn’t matter. You could drop WordPress in ./html, or Laravel, or a static site. The configuration, in this case, doesn’t dictate what kind of sites you’re hosting.

For each domain or sub-domain, you do need a VirtualHost set up though. So if you wanted to set up,,, etc, you’d need VirtualHosts for each of them, and they would be similar.

For each one, you need to change ServerName, ServerAlias, and DocumentRoot.

How you access the sites depends on setup as well.

You can’t access multiple sites on the same domain, but you could separate them by directory or even by sub-domain. As in, you can’t visit and choose which site you want to navigate to, you need to separate them out by directory or sub-domain, or even domain.

For example, you’d create directories for each site:


With the VirtualHost I used above, you’d then access them using:

You can install Laravel in sub folder along side of your other websites. To install Laravel in a subfolder let’s walk through a typical server setup to demonstrate it. Typically the path to the web root is something like this, but it can vary depending on your host:


With this path, the “html” folder is the web root, and your domain will typically point here. Now, let’s say you are building a blog and you create /var/www/html/blog. All the contents of your Laravel “public” folder would go in this folder. For example:


You will then put the rest of your Laravel folders and files in another place outside of “html”, for example:


Then for the final steps modify your “blog/index.php” file and adjust the following two paths.

// blog/index.php change to point to /var/www/laravel/

require __DIR__.'/../bootstrap/autoload.php'; 
$app = require_once __DIR__.'/../bootstrap/app.php';

This will keep everything outside your web root, make your install more secure, and prevent unauthorized access to import items.