michail_w
michail_w

Reputation: 4481

Apache 2, ubuntu - VHost doesn't work

I want to create VHost on my machine.

My config:

/etc/hosts

127.0.0.1 mysite.dev

/etc/apache2/sites-available/mysite.dev

<VirtualHost *:80>
    SetEnv APPLICATION_ENV "development"
    ServerName mysite.dev
    DocumentRoot /home/michal/Public/mysite/public/frontend

    <Directory /home/michal/Public/mysite/public/frontend>
        Options Indexes FollowSymLinks Includes
        AllowOverride All
        Order allow,deny
        Allow from all
    </Directory>
</VirtualHost>

After I run

sudo a2ensite mysite.dev
sudo /etc/init.d/apache2 restart

Now when I type mysite.dev to the browser, I see standard Apache index.html ("It works!"). Why? Where should I find my problem?

Upvotes: 1

Views: 761

Answers (3)

Shivam Mishra
Shivam Mishra

Reputation: 1

You are seeing default index.html page because you haven't disabled Apache default virtual host, Disable the default Apache virtual host using the command:

sudo a2dissite 000-default.conf

Upvotes: 0

OK, this was asked like a year ago but today I ran into this same problem and probably the solution I found will be very helpful for somebody else, so here it is.

What worked for me was renaming the soft links in /etc/apache2/sites-enabled, appending the extension .conf to every link in that folder.

So if we had the following links:

/etc/apache2/sites-enabled$ ls -l
lrwxrwxrwx 1 root root 23 Nov 30  2012 site1 -> ../sites-available/site1   
lrwxrwxrwx 1 root root 23 Nov 30  2012 site2 -> ../sites-available/site2

we should rename both to site1.conf and site2.conf

/etc/apache2/sites-enabled$ sudo mv site1 site1.conf
/etc/apache2/sites-enabled$ sudo mv site2 site2.conf

and then of course, restart apache

/etc/apache2/sites-enabled$ sudo /etc/init.d/apache2 restart

The reason why this worked forme is that Apache has changed sometime in the recent past the way this files should be named in order for them to be loaded correctly, as described in the last lines of apache2.conf file.

# Include the virtual host configurations:
IncludeOptional sites-enabled/*.conf

Upvotes: 0

Rupeshit
Rupeshit

Reputation: 1466

Not very clear from your question exactly what you want to achieve. If you want forward to specific URL say HTTPS URL then it can be achieve using following lines:

  <VirtualHost *:80>
     ServerName localhost:80
     RedirectMatch permanent ^(.*)$ https://localhost:8443$1
</VirtualHost>

If you are trying to configure apache server , jboss server and mod_jk then you can refer this link

Upvotes: 0

Related Questions