By cromartie
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!
One VirtualHost handles one domain or sub-domain, such as domain.com (basic example).
So if, for example, 000-default.conf was setup to handle domain.com, it would also handle:
domain.com/dir01
domain.com/dir02
domain.com/dir03
or even:
domain.com/laravel
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/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
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.
<VirtualHost *:80>
ServerName domain.com
ServerAlias www.domain.com
ServerAdmin webmaster@localhost
DocumentRoot /var/www/html
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
The above sets up a standard Port 80 (HTTP) VirtualHost block that responds to:
http://domain.com
http://www.domain.com
and
domain.com
www.domain.com
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, 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 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:
/var/www/html/laravel01
/var/www/html/laravel02
/var/www/html/laravel03
/var/www/html/wordpress01
/var/www/html/wordpress02
etc
With the VirtualHost I used above, you’d then access them using:
domain.com/laravel01
domain.com/laravel02
domain.com/laravel03
domain.com/wordpress01
domain.com/wordpress02
Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.
Full documentation for every DigitalOcean product.
The Wave has everything you need to know about building a business, from raising funding to marketing your product.
Stay up to date by signing up for DigitalOcean’s Infrastructure as a Newsletter.
New accounts only. By submitting your email you agree to our Privacy Policy
Scale up as you grow — whether you're running one virtual machine or ten thousand.
Sign up and get $200 in credit for your first 60 days with DigitalOcean.*
*This promotional offer applies to new accounts only.