PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Wednesday, February 16, 2022

[FIXED] Symfony 2 on virtual hosts

 February 16, 2022     host, symfony, virtualhost     No comments   

Issue

I have a problem here with Symfony 2. I want to have virtual host on Windows Vista PC, so I can access my Symfony application like this myapp.local.com. What I have tried:

  • I added these lines to hosts file

    127.0.0.1 local.com    
    127.0.0.1 myapp.local.com
    
  • These I added to apache httpd-vhosts.conf

    < VirtualHost myapp.local.com:80 >
       DocumentRoot "d:/data/www/myapp/web"
       ServerName myapp.local.com
       Alias /sf /$sf_symfony_data_dir/web/sf
    < Directory "/$sf_symfony_data_dir/web/sf" >
       AllowOverride All
       Allow from All
    < /Directory >
    < Directory "d:/data/www/myapp/web" >
       AllowOverride All
       Allow from All
    < /Directory >
    < /VirtualHost >
    

but when I write myapp.local.com in my browser, it brings the index of my www directory. What am I doing wrong?


Solution

You are using the virtualhost configuration proposed for Symfony 1.

My virtualhost for Symfony2 under linux looks like this:

<VirtualHost *:80>
    ServerName www.domain.com.localhost
    ServerAlias domain.com.localhost
    ServerAdmin webmaster@localhost

    DocumentRoot /home/user/www/project/web
    <Directory /home/user/www/project/web/>
        Options Indexes FollowSymLinks MultiViews
        AllowOverride None
        Order allow,deny
        allow from all
        <IfModule mod_rewrite.c>
            RewriteEngine On
            RewriteCond %{REQUEST_FILENAME} !-f
            RewriteRule ^(.*)$ /app.php [QSA,L]
        </IfModule>
    </Directory>
</VirtualHost>

Try this (adapted to your config in windows), restart Apache, and try accessing the URL again.

You will find more informations on Symfony2 virtual hosts on this cookbook entry.



Answered By - Nanocom
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing