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
This textbox defaults to using Markdown to format your answer.
You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!
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.
Join our DigitalOcean community of over a million developers for free! Get help and share knowledge in Q&A, subscribe to topics of interest, and get courses and tools that will help you grow as a developer and scale your project or business.
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.
This will keep everything outside your web root, make your install more secure, and prevent unauthorized access to import items.
@cromartie
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
domain.com
as my filler domain – you’d simply replace that with your own.The above sets up a standard Port 80 (HTTP) VirtualHost block that responds to:
and
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 domain02.com, domain03.com, domain04.com, etc, you’d need VirtualHosts for each of them, and they would be similar.
For each one, you need to change
ServerName
,ServerAlias
, andDocumentRoot
.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 domain.com 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:
So i need to create a virtual host file for each of my website , even a wordpress one?
/var/www/html/domain.com -> /etc/apache2/sites-available/domain.com.conf /var/www/html/test.com -> /etc/apache2/sites-available/test.com.conf
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