1

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?

michail_w
  • 4,318
  • 4
  • 26
  • 43
  • Do you see any errors/warnings when you run this command 'sudo /etc/init.d/apache2 restart' – Ozair Kafray Aug 28 '12 at 09:59
  • I only can see "Couldn't resolve server name, using 127.0.1.1 instead". But when I type 127.0.1.1 in /etc/hosts, nothing new happens. – michail_w Aug 28 '12 at 14:07
  • See if in your hosts file there are any entries with 127.0.1.1 comment them out or remove them. This has happened to me once and it was only when I had not enabled the site or not restarted apache. So, in your case it might be restarting of apache that is failing at some point and at some point aborting in configuring virtual hosts. – Ozair Kafray Aug 29 '12 at 05:55

3 Answers3

0

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

Rupeshit
  • 1,476
  • 1
  • 14
  • 23
  • I dont want to redirect. I only try to configure my VHost. But when i call my vhost address, apache returns standard index.html response. – michail_w Aug 27 '12 at 13:35
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
0

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

  • As it’s currently written, your answer is unclear. Please [edit] to add additional details that will help others understand how this addresses the question asked. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community Dec 20 '21 at 03:22