Poetry of Programming

Because coding is art
  • rss
  • Home
  • Search

Setting the web server to gain access to symfony_data/web/sf/ directory

Krzysztof Karolczak | Friday August 8th, 2008

The happiness of running the first Symfony project is very often spoiled by a message displayed on the first Symfony-based web page:

Congratulations! You have successfully created your symfony project.

Project setup successful

This project uses the symfony libraries. If you see no image in this page, you may need to configure your web server so that it gains access to the symfony_data/web/sf/ directory.

The proper configuration of the web server seems to be the most troublesome part of Symfony installation. But fortunately there are several quick ways to solve that problem. This short guide will describe two of them from the perspective of an Apache web server user.

I’m assuming that you have Symfony already properly installed (if not the installation guide is here). I’m working on a WAMP installation of Apache+MySQL+PHP, so the directory paths in my examples will reflect that.

Method 1 - setting a virtual host

This is the most recommended method of setting up your working environment - creating a virtual host for every application. The example will show how to configure your web server to cope with one project (a multi-application vhost  example is coming up soon :) ).

First - find your apache config directory (in my WAMP install it’s C:\wamp\bin\apache\apache2.2.6\conf) and open the httpd-vhosts.conf (which is in the sub-directory extra - C:\wamp\bin\apache\apache2.2.6\conf\extra). Delete or comment out all the lines (by adding ‘#’ at the beginning of each one) if you’re not sure what they do (if you haven’t written them they are probably just examples of vhost configuration). Now add at the end of the file your virtual host config which should look similar to this:

NameVirtualHost *:80

<VirtualHost *:80>
ServerName your_server_name
DocumentRoot “c:/wamp/www/your_project/web”
DirectoryIndex index.php
Alias /sf c:/wamp/bin/php/php5.2.5/PEAR/data/symfony/web/sf

<Directory “c:/wamp/www/your_project/web”>
Options Indexes FollowSymlinks ExecCGI
AllowOverride All
Order allow,deny
Allow from All
</Directory>

<Directory “c:/wamp/bin/php/php5.2.5/PEAR/data/symfony/web/sf”>
Allow from All
</Directory>

</VirtualHost>

In lines ‘Alias /sf c:/wamp/bin/php/php5.2.5/PEAR/data/symfony/web/sf’ and <Directory “c:/wamp/bin/php/php5.2.5/PEAR/data/symfony/web/sf”> replace my path with the path to your symfony/web/sf dir. And do the same with lines DocumentRoot “c:/wamp/www/your_project/web” and <Directory “c:/wamp/www/your_project/web”> changing the path to one that points to the web dir in your project. You can also specify the name of the virtual server you want to setup by modifying ‘your_server_name” in the ‘ServerName your_server_name’ line.

Make sure that in the httpd.conf file (main Apache config file located in a directory like C:\wamp\bin\apache\apache2.2.6\conf) the line ‘Include conf/extra/httpd-vhosts.conf‘ is uncommented (no ‘#’ before it).

Now - after an apache restart - if you type in your browser http://localhost/ your Symfony welcoming page should have all the graphics displayed correctly.

But it still can be better ;). You can declare your own domain locally. If you add a line like ‘127.0.0.1 your_name‘ to the host file (located in C:\WINDOWS\system32\drivers\etc\)  entering an URL like http://your_name/ will take you to the homepage of your project :). Just make sure that you add your line after ‘127.0.0.1 localhost‘ (which should be in fact the first line). You may also need admin privileges to modify that file.

Method 2 - the stupid way

If the above method is not working for you - just go ahead and copy the symfony_data_path/web/sf/ directory to your_project_path/web/ (so in my case that would be copying C:\wamp\bin\php\php5.2.5\PEAR\data\symfony\web\sf to the C:\wamp\www\your_project\web directory). The drawback is that after updating Symfony you may have to recopy that folder again to all your projects and you may also experience some problems when freezing your projects (symfony freeze command - preparing a ready-to-deploy package out of your project).

Categories
Installation, Symfony
Tags
PHP, vhost, Symfony
Comments rss
Comments rss
Trackback
Trackback

« PHP Maximum execution time exceeded error workaround

2 responses

Oh, thank you. I had to resort to Method 2 (the

Mark | Wednesday October 8th, 2008

Oh, thank you.

I had to resort to Method 2 (the stupid way) but it did work.

I am a Mac convert (from Windows) since summer, 2007. When I initially set up my machine and struggled to get MySQL and PHP and PEAR working, my document root was set in a different folder from the default ‘Sites’ (don’t ask me how). AND, I do a number of prototypes, none prior to the latest are Symfony-based, each of which lives in a different folder. So changing httpd.conf to look at virtual hosts broke other things.

Someday I hope to get back to the standard OSX folder configuration for localhost, but thanks to your help I am running today!

mark

Thank you for the 15 minute guide to install Symfony

D. Zook | Thursday November 6th, 2008

Thank you for the 15 minute guide to install Symfony on a WAMP platform. It worked great. I am using PHP 5.2.6 and had the data access error described on this page. Method one did not work for me. I followed the directions exactly but did not quite understand the process so there was probably something I typed incorrectly.

The stupid way worked fine though.

Thanks for the help.

Leave a comment

You can use these tags : <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

Language

  • English
  • Polski


Navigation

  • css
  • PHP
  • Symfony
    • Installation

Blogroll

  • Symfony

Tags

css (1) eclipse (1) framework (1) PDT (1) PHP (4) Symfony (1) tips (1) vhost (1)

rss Comments rss valid xhtml 1.1 design by jide powered by Wordpress get firefox