<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Poetry of Programming &#187; vhost</title>
	<atom:link href="http://www.poetryofprogramming.com/tag/vhost/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.poetryofprogramming.com</link>
	<description>Because coding is art</description>
	<lastBuildDate>Wed, 15 Apr 2009 15:05:23 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.1</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Setting the web server to gain access to symfony_data/web/sf/ directory</title>
		<link>http://www.poetryofprogramming.com/symfony/setting-the-web-server-to-gain-access-to-symfony_datawebsf-directory/</link>
		<comments>http://www.poetryofprogramming.com/symfony/setting-the-web-server-to-gain-access-to-symfony_datawebsf-directory/#comments</comments>
		<pubDate>Mon, 08 Dec 2008 16:56:29 +0000</pubDate>
		<dc:creator>Krzysztof Karolczak</dc:creator>
				<category><![CDATA[Installation]]></category>
		<category><![CDATA[Symfony]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Symfony 1.0]]></category>
		<category><![CDATA[Symfony 1.1]]></category>
		<category><![CDATA[Symfony 1.2]]></category>
		<category><![CDATA[vhost]]></category>

		<guid isPermaLink="false">http://www.poetryofprogramming.com/?p=25</guid>
		<description><![CDATA[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 [...]]]></description>
			<content:encoded><![CDATA[<p style="text-align: justify;"><span class="MsgBodyText">The happiness of running the first Symfony project is very often spoiled by a message displayed on the first Symfony-based web page:</span></p>
<p style="padding-left: 30px; text-align: justify;"><em>Congratulations! You have successfully created your symfony project.</em></p>
<p style="padding-left: 30px; text-align: justify;"><em>Project setup successful</em></p>
<p style="padding-left: 30px; text-align: justify;"><em>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.</em></p>
<p style="text-align: justify;">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 three of them from the perspective of an Apache web server user.<span id="more-25"></span></p>
<p style="text-align: justify;">I&#8217;m assuming that you have Symfony already properly installed (if not &#8211; the <strong><a href="http://www.poetryofprogramming.com/symfony/install-symfony-framework-xp-vista-wamp/" target="_blank">installation guide is here</a></strong>). I&#8217;m working on a <strong><a href="http://www.wampserver.com/en/" target="_blank">WAMP</a> installation</strong> of Apache+MySQL+PHP, so the directory paths in my examples will reflect that (but the guide should work for any Apache based configuration).</p>
<p><strong>Method 1 &#8211; setting a virtual host</strong></p>
<p style="text-align: justify;">This is the most recommended method of setting up your working environment (in fact it is the only <em><strong>real</strong></em> method out there &#8211; the other described below are just workarounds ) &#8211; you should always create a virtual host for every application. This guide will teach you how to configure your web server to cope with one project (a multi-application <em>vhost </em> example is coming up soon <img src='http://www.poetryofprogramming.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' />  ).</p>
<p style="text-align: justify;">First &#8211; find your apache config directory (in my WAMP install it&#8217;s <em>C:\wamp\bin\apache\apache2.2.6\conf\</em>) and open the <em>httpd-vhosts.conf</em> (which is in the sub-directory <em>extra</em> &#8211; <em>C:\wamp\bin\apache\apache2.2.6\conf\extra</em>). Delete or comment out all the lines  (by adding &#8216;#&#8217; at the beginning of each one) if you&#8217;re not sure what they do (if you haven&#8217;t written them they are probably just examples of <em>vhost </em>configuration).</p>
<p class="note" style="text-align: justify;">In Symfony 1.2 (1.1 also?) a sample <em>vhost</em> config file is created automatically for every project you generate. It can be found in <em>config/vhost.sample</em> &#8211; feel free to copy/paste that code instead of the below example.</p>
<p style="text-align: justify;">Now add at the end of the file your virtual host config which should look similar to this (it&#8217;s just one of possible ways of configuring  a <em>vhost</em> &#8211; you may find other configurations that achieve the same thing but look different &#8211; they all are correct as long as they work, right? <img src='http://www.poetryofprogramming.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' />  ):</p>
<p style="padding-left: 30px;"><em>NameVirtualHost *:80</em></p>
<p style="padding-left: 30px;"><em>Listen 127.0.0.2:80</em></p>
<p style="padding-left: 30px;"><em>&lt;VirtualHost 127.0.0.2:80&gt;</em></p>
<p style="padding-left: 60px;"><em>ServerName your_application_name<br />
 DocumentRoot &#8220;c:\wamp\www\your_project\web&#8221;<br />
 </em><em>DirectoryIndex index.php</em></p>
<p><em> </em></p>
<p style="padding-left: 60px;"><em>&lt;Directory &#8220;c:\wamp\www\</em><em>your_project\</em><em>web&#8221;&gt;</em></p>
<p style="padding-left: 90px;"><em>AllowOverride All<br />
 Allow from All</em></p>
<p style="padding-left: 60px;"><em>&lt;/Directory&gt;</em></p>
<p style="padding-left: 60px;"><em>Alias /sf &#8220;c:\wamp\bin\php\php5.2.5\PEAR\data\symfony\web\sf&#8221;</em></p>
<p style="padding-left: 60px;"><em>&lt;Directory &#8220;c:\wamp\bin\php\php5.2.5\PEAR\data\symfony\web\sf&#8221;&gt;</em></p>
<p style="padding-left: 90px;"><em>AllowOverride All<br />
 Allow from All</em></p>
<p style="padding-left: 60px;"><em>&lt;/Directory&gt;</em></p>
<p style="padding-left: 30px;"><em>&lt;/VirtualHost&gt;</em></p>
<p style="text-align: center;"><script type="text/javascript"><!--
google_ad_client = "pub-5856107143683355";
google_ad_slot = "0824560404";
google_ad_width = 468;
google_ad_height = 60;
//--></script>
<script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></script>
</p>
<p style="text-align: justify;">In lines <em>&#8216;</em><em> Alias /sf &#8220;c:\wamp\bin\php\php5.2.5\PEAR\data\symfony\web\sf&#8221; </em><em>&#8216;</em> and <em>&#8216; </em><em>&lt;Directory &#8220;c:\wamp\bin\php\php5.2.5\PEAR\data\symfony\web\sf&#8221;&gt; </em><em>&#8216; </em>replace my path with the path to your <em>symfony/web/sf</em> dir. And do the same with lines <em>&#8216; </em><em>DocumentRoot &#8220;c:\wamp\www\your_project\web&#8221;</em><em> &#8216; </em>and<em> &#8216; &lt;Directory &#8220;c:\wamp\www\your_project\web&#8221;&gt;</em><em> &#8216; </em>changing the path to one that points to the <em>web </em>directory in your project.</p>
<p style="text-align: justify;">And you should also specify the name of your virtual server by modifying <em>&#8216;your_application_name&#8217;</em> in the <em>&#8216;ServerName your_application_name&#8217; </em>line.</p>
<p style="text-align: justify;">Make sure that in the <em>httpd.conf</em> file<em> </em>(main Apache config file located in a directory like <em>C:\wamp\bin\apache\apache2.2.6\conf) </em>the line &#8216;<em>Include conf/extra/httpd-vhosts.conf</em>&#8216; is uncommented (no &#8216;#&#8217; before it).</p>
<p style="text-align: justify;">Now we need to declare our own domain locally, by adding a line like &#8216;<em>127.0.0.2 </em><em>your_application_name&#8217;</em> to the <em>host</em> file (located in <em>C:\WINDOWS\system32\drivers\etc</em>). Just make sure that you add your line after &#8216;<em>127.0.0.1 localhost</em>&#8216; (which should be in fact the first line). You may also need admin privileges to modify that file.</p>
<p style="text-align: justify;">Now &#8211; after an Apache restart &#8211; if you type in your browser http://your_application_name/ your Symfony welcoming page should have all the graphics displayed correctly.</p>
<p style="text-align: center;"><script type="text/javascript"><!--
google_ad_client = "pub-5856107143683355";
google_ad_slot = "0824560404";
google_ad_width = 468;
google_ad_height = 60;
//--></script>
<script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></script>
</p>
<p><strong>Method 2 &#8211; project freezing</strong></p>
<p style="text-align: justify;">You can obtain a ready-to-deploy package from your Symfony project by using the <em>freeze</em> command. If you execute in the root of your project:</p>
<p style="padding-left: 30px;"><em>symfony freeze [c:/path/to/your/symfony/data/dir]</em></p>
<p style="text-align: justify;">All Symfony core files will be copied to the current project, including the ones that where missing in the <em>web/sf</em> directory. The freeze command also changes some paths in your project configuration so it will now address the Symfony libraries that were also copied to your project not the global ones. The main drawback is that if you want to upgrade Symfony you&#8217;ll have to <em>unfreeze</em> (command opposite to freeze) and <em>freeze</em> again all your projects or copy/overwrite files manually. And there may be some path issues if your project is not in the web root of your web server directory.</p>
<p style="text-align: center;"><script type="text/javascript"><!--
google_ad_client = "pub-5856107143683355";
google_ad_slot = "0824560404";
google_ad_width = 468;
google_ad_height = 60;
//--></script>
<script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></script>
</p>
<p><strong>Method 3 &#8211; the stupid way</strong></p>
<p style="text-align: justify;">If the above methods are not working for you &#8211; just go ahead and copy the <em>symfony_data_path/web/sf/ </em>directory to <em>your_project_path/web/</em> (so in my case that would be copying <em>C:\wamp\bin\php\php5.2.5\PEAR\data\symfony\web\sf </em>to the <em>C:\wamp\www\your_project\web</em> directory). As before the downside of this workaround is that after updating Symfony you will have to manually recopy that folder again to all your projects and there probably will be some path issues when accessing plugin assets or when using absolute paths in links (but you probably won&#8217;t even notice if you&#8217;ll always use symfony helpers for handling your links).</p>
<p style="text-align: center;"><script type="text/javascript"><!--
google_ad_client = "pub-5856107143683355";
google_ad_slot = "0824560404";
google_ad_width = 468;
google_ad_height = 60;
//--></script>
<script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></script>
</p>
<p><!--more--></p>
]]></content:encoded>
			<wfw:commentRss>http://www.poetryofprogramming.com/symfony/setting-the-web-server-to-gain-access-to-symfony_datawebsf-directory/feed/</wfw:commentRss>
		<slash:comments>15</slash:comments>
		</item>
	</channel>
</rss>
