views:

39

answers:

1

I'm trying to configure my local Apache2 server to host several Symfony websites using virtual hosts, but I just can't make it to alias lib/vendor/symfony/data/web/sf directory as /sf. I see that using %1 and %2 in alias statement is the source of the problem, but I can't find the right solution. I added to /etc/hosts entry 127.0.0.1 jobeet.sandbox.sfdevel, I created in my home directory directory ~/Projekty/sandbox/jobeet. My Apache2 site configuration reads as follows:

<VirtualHost *:80>
        ServerName localhost
        ServerAlias *.sfdevel
        VirtualDocumentRoot /home/alef/Projekty/%2/%1/web

        <Directory /home/alef/Projekty/%2/%1/web>
                AllowOverride All
                Allow from All
        </Directory>

        Alias /sf /home/alef/Projekty/%2/%1/lib/vendor/symfony/data/web/sf
        <Directory /home/alef/Projekty/%2/%1/lib/vendor/symfony/data/web/sf>
                AllowOverride All
                Allow from All
        </Directory>

        ErrorLog /var/log/apache2/sfdevel_error.log
        LogLevel warn
        CustomLog /var/log/apache2/sfdevel_access.log combined

</VirtualHost>

When I change /home/alef/Projekty/%2/%1/lib/vendor/symfony/data/web/sf to /home/alef/Projekty/sandbox/jobeet/lib/vendor/symfony/data/web/sf it works just fine, but I want to use several separate Symfony websites. What changes should I include in my Apache2 configuration?

+3  A: 

I'm not sure if you can create aliases this way. There's nothing about it in the apache documentation.

I'd think about removing Alias from your virtualhost definition anyway. Symbolic link will work the same:

cd /home/alef/Projekty/sandbox/jobeet/web
ln -s ../lib/vendor/symfony/data/web/sf
kuba
Thanks, it works fine. I guess there is no way to achieve what I was trying to do in Apache2 site config - I would have to write separate config for each site, with full and explicit paths to directories.
Mariusz Alef Bąk
+1 for needing one VH container each site - it's slightly cumbersome, but then when are you going to have one server with more than a manually-manageable number of sites? :)
Raise