0

I want to create a virtual host for my application i got some tutorials of how to setup a virtual host but still i am having issues with it, first i create a new file in the /etc/apache2/sites-avalable/popinbay.dev This is the popinbay.dev file please note that i am using ubuntu 14.04

    <VirtualHost *:80>
    ServerAdmin udemesamuel256@gmail.com
    ServerName popibay.dev
    DocumentRoot /var/www/laravel4        
   </VirtualHost>

then i edited the /etc/hosts and added this line

    127.0.0.1       popibay.dev

then i did a sudo service apache2 reload based on this tutorial virtual host in ubuntu not work But the problem is it still goes to the default localhost page instaed of the laravel4 page.

Community
  • 1
  • 1
ubilli
  • 89
  • 1
  • 10

2 Answers2

2

You are using a "Name-based Virtual Hosts".

From Apache docs on Using Name-based Virtual Hosts:

To use name-based virtual hosting, you must designate the IP address (and possibly port) on the server that will be accepting requests for the hosts. This is configured using the NameVirtualHost directive. In the normal case where any and all IP addresses on the server should be used, you can use * as the argument to NameVirtualHost.

Try add NameVirtualHost *:80 to the top of your configuration, then restart your apache. E.g.

NameVirtualHost *:80

<VirtualHost *:80>
    ServerAdmin udemesamuel256@gmail.com
    ServerName popibay.dev
    DocumentRoot /var/www/laravel4        
</VirtualHost>

Note that you might need to change your DocumentRoot to /var/www/laravel4/public. That's where your http server should point to by default in Laravel projects.

Unnawut
  • 7,500
  • 1
  • 26
  • 33
  • i tried what you said but it id not work it still going to the localhost index.html file – ubilli Jul 02 '14 at 15:18
  • @ubilli try Abhineet's answer too. It could be what he said or combination of both his answer and mine. Sometimes I need to restart my browser too for the updated `/etc/hosts` file to be recognized. – Unnawut Jul 02 '14 at 15:19
0

You added virtual host file in sites-available folder but didn't Enabled it.

Use

sudo a2ensite virtuatl_host.conf

In your case,

sudo a2ensite popibay.dev.conf

And then,

sudo service apache2 reload
Abhineet Verma
  • 1,008
  • 8
  • 18
  • ➜ sites-available>sudo a2ensite popinbay.dev ERROR: Site popinbay.dev does not exist! ➜ sites-available> – ubilli Jul 02 '14 at 15:19
  • Are you sure that your conf name is `popinbay.dev`? If not, then replace the `popinbay.dev` with that name – Abhineet Verma Jul 02 '14 at 15:20
  • this is my command line ➜ sites-available>ls 000-default.conf default-ssl.conf popibay.dev ➜ sites-available> – ubilli Jul 02 '14 at 15:28
  • @Abihineet Verma it is popibay.dev not popinbay.dev – ubilli Jul 02 '14 at 15:31
  • Got it. It's popibay.dev, you mentioned popinbat.dev in your question. Anyways use `sudo a2ensite popibay.dev` instead of `sudo a2ensite popinbay.dev` – Abhineet Verma Jul 02 '14 at 15:32
  • ➜ sites-available>sudo a2ensite popibay.dev ERROR: Site popibay.dev does not exist! ➜ sites-available> @Abihineet Verma – ubilli Jul 02 '14 at 15:34
  • 1
    rename `popibay.dev` to `popibay.dev.conf` : each virtual host file should be ended in `.conf` – Razor Jul 02 '14 at 15:35
  • Guys, try this http://stackoverflow.com/questions/20591889/site-does-not-exist-error-for-a2ensite. Could be to do with file extension – Unnawut Jul 02 '14 at 15:36
  • It's a bit strange, have you got the same error? Anyway, follow this link https://www.digitalocean.com/community/tutorials/how-to-set-up-apache-virtual-hosts-on-ubuntu-14-04-lts , it will guide you step by step. – Razor Jul 02 '14 at 16:09