This forum is in READ-ONLY mode.
You can look around, but if you want to ask a new question, please use Stack Overflow.

Xampp and virtual host

Installation and environment issues, mainly on 1.x but there's some 2.x here too.

Xampp and virtual host

by erinhir » Thu Jul 31, 2008 5:17 pm

Hello everyone,

I have a question concerning virtual hosts in Symfony. Let me explain.

I have installed Xampp on windows xp. There was no problem with that. After installation http://localhost showed me the introduction page of xampp where i could play with the configuration.

After that, i installed Symfony via PEAR. Also no problem. I created a new project Test and a new application TestApp. Still no problem.

When i surfed to http://localhost/Test/web/frontend_dev.php/ it showed me the welcom page of symfony but with no css and images. On the website they said i must configure a virtual server. I did that like they said on the website. I have added in http.conf the following

<VirtualHost *:80>
ServerName Gogo
DocumentRoot "C:\xampp\htdocs\Test\web"
DirectoryIndex index.php
Alias /sf "C:/php5/pear/data/symfony/web/sf"
<Directory "C:\xampp\htdocs\Test\web">
AllowOverride All
Allow from All
</Directory>
<Directory "C:/php5/pear/data/symfony/web/sf">
AllowOverride All
Allow from All
</Directory>
</VirtualHost>

When i now go to http://localhost/Test/TestApp/web/frontend_dev.php/ is shows me a 404 not found.
If i go to http://localhost it shows me the symfony welcome page, now with the css and the images. But no more the welcome page of Xampp. It also works when i go to http://localhost/frontend_dev.php/

Now i have a few questions:

- Can someone explain me shortly how this process works of virtual hosts
- How comes that localhost gives me now the welcome page of symfony and not the welcome page of xampp?
- Can i configure it so that when i go to http://localhost i see the xampp welcom page, and when i go to http://localhost/Test i see the symfony page? Or something like that.

- What if i want to create a second project? How can i access it, via which url?
- How can i distinguish different applications in one project? http://localhost/Project/app1 http://localhost/Project/app2 ?

Thank you in advance

grtz
Erinhir
erinhir
Member
 
Posts: 62
Joined: Thu Jul 31, 2008 5:11 pm

Re: Xampp and virtual host

by trontank » Thu Jul 31, 2008 8:37 pm

Hi Erinhir,

you are not forced to configure a virtual host for every project. If you simply want to try out Symfony you should download sf_sandbox_1_1.tgz, uncompress it to your htdocs dir and you'r ready to go.

I'm not an Apache expert, but if you want to use virtual host, the httpd-vhosts.conf file is the configuration file you should use. Here's a short example:

Code: Select all
NameVirtualHost 127.0.0.1:80

# Configure a vhost for localhost, too.
# Should be configured in httpd.conf, so these three lines should be enough to make both your vhosts and localhost work.
<VirtualHost *:80>
 ServerName localhost
</VirtualHost>

# vhost gogo
<VirtualHost 127.0.0.1:80>
 DocumentRoot "C:/xampp/htdocs/Test/web"
 ServerName gogo
 # other stuff like error logs...
 <Directory "C:/xampp/htdocs/Test/web">
  AllowOverride All
  Allow from All
 </Directory>
 Alias /sf "C:/php5/pear/data/symfony/web/sf"
 <Directory "C:/php5/pear/data/symfony/web/sf">
   Allow from All
 </Directory>
</VirtualHost>


Make sure your httpd.conf file includes the httpd-vhosts.conf:

Code: Select all
# Virtual hosts
Include conf/extra/httpd-vhosts.conf


If you want, you can put the vhost stuff in your httpd.conf file, but i prefer having it in a seperate file.

Restart Apache.

Search for a file named "hosts" on your Windows PC. This is typically located in C:\WINDOWS\system32\drivers\etc\.

Open it and change it like that (without the <---- stuff of course):

127.0.0.1 localhost <---- in there by default
127.0.0.1 gogo <---- add this line

Browse to http://localhost. You should see the XAMPP Welcome page. Now point your browser to http://gogo and you should see the SF welcome page of your project. Hope this helps.
trontank
Senior Member
 
Posts: 178
Joined: Thu Jul 31, 2008 2:18 pm
Location: Germany

Re: Xampp and virtual host

by erinhir » Thu Jul 31, 2008 9:40 pm

Thank you for your answer. I did like you said, but when i go to localhost, i still receive the symfony welcome page.

Erinhir
erinhir
Member
 
Posts: 62
Joined: Thu Jul 31, 2008 5:11 pm

Re: Xampp and virtual host

by trontank » Thu Jul 31, 2008 9:55 pm

That's strange. Did you restart apache after you've made the changes to the .conf files?

Try this:

- open cmd
- cd to C:/xampp/apache/bin
- type httpd -S

This is how the output looks like on my Windows PC (my vhost is named "sftest"):

Code: Select all
VirtualHost configuration:
wildcard NameVirtualHosts and _default_ servers:
_default_:443 localhost (E:/xampp/apache/conf/extra/httpd-ssl.conf:74)*:80 is a NameVirtualHost

default server sftest (E:/xampp/apache/conf/extra/httpd-vhosts.conf:46)

port 80 namevhost sftest (E:/xampp/apache/conf/extra/httpd-vhosts.conf:46)
port 80 namevhost localhost (E:/xampp/apache/conf/extra/httpd-vhosts.conf:63)
Syntax OK


And this is how my httpd-vhosts.conf file looks like:

Code: Select all
NameVirtualHost *:80

<VirtualHost *:80>
   ServerName sftest
   DocumentRoot "e:/xampp/htdocs/sf-test/web"
   DirectoryIndex index.php
   <Directory "e:/xampp/htdocs/sf-test/web">
      Options Indexes FollowSymLinks Includes ExecCGI
      AllowOverride All
      Order allow,deny
      Allow from all
   </Directory>
   Alias /sf "e:/xampp/php/PEAR/data/symfony/web/sf"
   <Directory "e:/xampp/php/PEAR/data/symfony/web/sf">
      Allow from all
   </Directory>
</VirtualHost>


<VirtualHost *:80>
   ServerName localhost
</VirtualHost>


Make sure both localhost and gogo are listed as vhosts in the cmd output. If not, try restarting your pc to make sure the apache server starts with the altered configuration files.
trontank
Senior Member
 
Posts: 178
Joined: Thu Jul 31, 2008 2:18 pm
Location: Germany

Re: Xampp and virtual host

by erinhir » Thu Jul 31, 2008 10:02 pm

Hi,

i did restart everything.
This is what i get:

C:\xampp\apache\bin>httpd -S
VirtualHost configuration:
127.0.0.1:80 is a NameVirtualHost
default server Test (C:/xampp/apache/conf/extra/httpd-vhosts.conf:47)
port 80 namevhost Test (C:/xampp/apache/conf/extra/httpd-vhosts.conf:47
)
wildcard NameVirtualHosts and _default_ servers:
*:80 localhost (C:/xampp/apache/conf/extra/httpd-vhosts.conf:6
4)
_default_:443 localhost (C:/xampp/apache/conf/extra/httpd-ssl.conf:74)

I changed also the name of gogo to test ;)~ ;-)~ :wink:

grtz
Erinhir
erinhir
Member
 
Posts: 62
Joined: Thu Jul 31, 2008 5:11 pm

Re: Xampp and virtual host

by erinhir » Thu Jul 31, 2008 10:12 pm

I found it.
This was in my conf file

NameVirtualHost 127.0.0.1:80

# vhost Test
<VirtualHost 127.0.0.1:80>
DocumentRoot "C:/xampp/htdocs/Test/web"
ServerName Test
DirectoryIndex index.php
# other stuff like error logs...
<Directory "C:/xampp/htdocs/Test/web">
AllowOverride All
Allow from All
</Directory>
Alias /sf "C:/php5/pear/data/symfony/web/sf"
<Directory "C:/php5/pear/data/symfony/web/sf">
Allow from All
</Directory>
</VirtualHost>

# Configure a vhost for localhost, too.
# Should be configured in httpd.conf, so these three lines should be enough to make both your vhosts and localhost work.
<VirtualHost *:80>
ServerName localhost
</VirtualHost>


I changed the 127.0.0.1:80 to *:80 and it works.

Allright.

Erinhir
erinhir
Member
 
Posts: 62
Joined: Thu Jul 31, 2008 5:11 pm

Re: Xampp and virtual host

by trontank » Thu Jul 31, 2008 10:16 pm

Damn, i got that wrong in my first reply. I have the same working config on my computer (*:80). I'm glad it works for you now!
trontank
Senior Member
 
Posts: 178
Joined: Thu Jul 31, 2008 2:18 pm
Location: Germany

Re: Xampp and virtual host

by patris » Mon Feb 28, 2011 1:22 pm

Thank you so much! I had the same problem.. but it works now thanks to you guys. :)
patris
Junior Member
 
Posts: 1
Joined: Mon Feb 28, 2011 1:13 pm

Re: Xampp and virtual host

by jupong47 » Wed Dec 11, 2013 4:39 am

nice.. i have fixed my problem too. just this day..

but the next problem is why is it that the other htdocs file is not accessible ?
my server domain is configured via webserver user interface..
and this is my conf:
#<VirtualHost *:80>
# DocumentRoot "c:\xampp\htdocs\climbs\web"
# DirectoryIndex index.php
# <Directory "c:\xampp\htdocs\climbs\web">
# AllowOverride All
# Allow from All
# </Directory>
# Alias /sf "c:\xampp\htdocs\climbs\lib\vendor\symfony\data\web\sf"
# <Directory "c:\xampp\htdocs\climbs\lib\vendor\symfony\data\web\sf">
# AllowOverride All
# Allow from All
# </Directory>
#</VirtualHost>
jupong47
Junior Member
 
Posts: 5
Joined: Tue Dec 10, 2013 5:18 am