<?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>Blog Symfony2 - Lexik Montpellier &#187; virtual hosts</title>
	<atom:link href="http://www.lexik.fr/blog/symfony/tag/virtual-hosts/feed" rel="self" type="application/rss+xml" />
	<link>http://www.lexik.fr/blog/symfony</link>
	<description>Blog sur le développement Web PHP avec Symfony 2</description>
	<lastBuildDate>Thu, 02 Feb 2012 14:00:26 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3</generator>
		<item>
		<title>Utilisation de VHost pour l&#8217;accès au backend</title>
		<link>http://www.lexik.fr/blog/symfony/symfony/utilisation-de-vhost-pour-lacces-au-backend-1307</link>
		<comments>http://www.lexik.fr/blog/symfony/symfony/utilisation-de-vhost-pour-lacces-au-backend-1307#comments</comments>
		<pubDate>Wed, 27 Oct 2010 07:54:59 +0000</pubDate>
		<dc:creator>cedric</dc:creator>
				<category><![CDATA[Apache]]></category>
		<category><![CDATA[Symfony]]></category>
		<category><![CDATA[backend]]></category>
		<category><![CDATA[virtual hosts]]></category>

		<guid isPermaLink="false">http://www.lexik.fr/blog/symfony/?p=1307</guid>
		<description><![CDATA[L&#8217;idée est de ne plus accéder au backend de notre site web en utilisant backend.php dans l&#8217;url, mais de passer par un sous domaine. http://www.super-website.com &#8594; frontend http://admin.super-website.com &#8594; backend Supposons que mon projet Symfony se trouve dans /home/public_html/. Commençons &#8230;<p class="more aright"><a href="http://www.lexik.fr/blog/symfony/symfony/utilisation-de-vhost-pour-lacces-au-backend-1307">...</a></p>]]></description>
			<content:encoded><![CDATA[<p>L&#8217;idée est de ne plus accéder au backend de notre site web en utilisant backend.php dans l&#8217;url, mais de passer par un sous domaine.</p>
<ul>
<li>http://www.super-website.com &rarr; frontend</li>
<li>http://admin.super-website.com &rarr; backend</li>
</ul>
<p>Supposons que mon projet Symfony se trouve dans /home/public_html/.<br />
Commençons par ajouter un vhost pour définir le sous domaine dans Apache. On précise au sous domaine que le fichier index pour ce sous domaine sera backend.php à l&#8217;aide de la directive DirectoryIndex.</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p1307code4'); return false;">View Code</a> CONSOLE</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p13074"><td class="code" id="p1307code4"><pre class="console" style="font-family:monospace;">&lt;VirtualHost *:80&gt;
  ServerName admin.super-website.fr
  DocumentRoot &quot;/home/public_html/web&quot;
  DirectoryIndex backend.php
&nbsp;
  &lt;Directory &quot;/home/public_html/web&quot;&gt;
    AllowOverride All
    Allow from All
  &lt;/Directory&gt;
&nbsp;
  Alias /sf /home/public_html/lib/vendor/symfony/data/web/sf
  &lt;Directory &quot;/home/public_html/lib/vendor/symfony/data/web/sf&quot;&gt;
    AllowOverride All
    Allow from All
  &lt;/Directory&gt;
&lt;/VirtualHost&gt;</pre></td></tr></table></div>

<p>Ensuite il faut modifier le .htaccess de Symfony afin qu&#8217;il redirige les requêtes http du sous domaine vers le fichier backend.php.</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p1307code5'); return false;">View Code</a> CONSOLE</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p13075"><td class="code" id="p1307code5"><pre class="console" style="font-family:monospace;">Options +FollowSymLinks +ExecCGI
&nbsp;
&lt;IfModule mod_rewrite.c&gt;
  RewriteEngine On
&nbsp;
  # uncomment the following line, if you are having trouble
  # getting no_script_name to work
  #RewriteBase /
&nbsp;
  # we skip all files with .something
  #RewriteCond %{REQUEST_URI} \..+$
  #RewriteCond %{REQUEST_URI} !\.html$
  #RewriteRule .* - [L]
&nbsp;
  # we check if the .html version is here (caching)
  RewriteRule ^$ index.html [QSA]
  RewriteRule ^([^.]+)$ $1.html [QSA]
&nbsp;
  # redirect to the backend web controller
  RewriteCond %{REQUEST_FILENAME} !-f
  RewriteCond %{HTTP_HOST}  ^admin.*
  RewriteRule ^(.*)$ backend.php [QSA,L]
&nbsp;
  # no, so we redirect to our front web controller
  RewriteCond %{REQUEST_FILENAME} !-f
  RewriteRule ^(.*)$ index.php [QSA,L]
&lt;/IfModule&gt;</pre></td></tr></table></div>

<p>Au niveau de la config Symfony, nous pouvons maintenant masquer le nom du script dans les urls du backend:</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p1307code6'); return false;">View Code</a> CONSOLE</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p13076"><td class="code" id="p1307code6"><pre class="console" style="font-family:monospace;"># apps/backend/config/settings.yml
prod:
  .settings:
    no_script_name:    true
    ...</pre></td></tr></table></div>

<p>Et pour finir ne pas oublier de vider le cache =), le backend est maintenant accessible sur http://admin.super-website.com.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.lexik.fr/blog/symfony/symfony/utilisation-de-vhost-pour-lacces-au-backend-1307/feed</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>Virtual hosts dans Wamp pour Symfony</title>
		<link>http://www.lexik.fr/blog/symfony/symfony/wamp-virtual-host-109</link>
		<comments>http://www.lexik.fr/blog/symfony/symfony/wamp-virtual-host-109#comments</comments>
		<pubDate>Sun, 22 Feb 2009 18:33:48 +0000</pubDate>
		<dc:creator>Samuel Breton</dc:creator>
				<category><![CDATA[Symfony]]></category>
		<category><![CDATA[host]]></category>
		<category><![CDATA[httpd]]></category>
		<category><![CDATA[httpd-vhosts.conf]]></category>
		<category><![CDATA[virtual hosts]]></category>
		<category><![CDATA[wamp]]></category>

		<guid isPermaLink="false">http://www.lexik.fr/sfblog/?p=109</guid>
		<description><![CDATA[Configuration des &#171;&#160;vitual hosts&#160;&#187; dans Wamp pour pouvoir gérer plusieurs projets Symfony. Dans cet exemple nous allons configurer 2 sites : Site A : Emplacement : c:\wamp\www\sf_projects\siteA Host : siteA.local Site B : Emplacement : c:\wamp\www\sf_projects\siteB Host : siteB.local httpd-vhosts.conf &#8230;<p class="more aright"><a href="http://www.lexik.fr/blog/symfony/symfony/wamp-virtual-host-109">...</a></p>]]></description>
			<content:encoded><![CDATA[<p>Configuration des &laquo;&nbsp;vitual hosts&nbsp;&raquo; dans Wamp pour pouvoir gérer plusieurs projets Symfony.<br />
<span id="more-109"></span><br />
Dans cet exemple nous allons configurer 2 sites :</p>
<ul>
<li>Site A :<br />
Emplacement : c:\wamp\www\sf_projects\siteA<br />
Host : siteA.local</li>
<li>Site B :<br />
Emplacement : c:\wamp\www\sf_projects\siteB<br />
Host : siteB.local</li>
</ul>
<h2>httpd-vhosts.conf</h2>
<ul>
<li>Editer le fichier :<br />
<blockquote><p>C:\wamp\bin\apache\Apache2.2.11\conf\extra\httpd-vhosts.conf</p></blockquote>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p109code8'); return false;">View Code</a> TEXT</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p1098"><td class="code" id="p109code8"><pre class="text" style="font-family:monospace;">NameVirtualHost *:80
#Site A
&lt;VirtualHost *:80&gt;
    ServerAdmin admin@siteA.com
    DocumentRoot &quot;C:\wamp\www\sf_projects\siteA\web&quot;
    ServerName siteA.local
    ServerAlias siteA.local
    ErrorLog &quot;logs/siteA.localhost-error.log&quot;
    CustomLog &quot;logs/siteA.localhost-access.log&quot; common
    Alias /sf C:\wamp\www\sf_projects\siteA\lib\vendor\symfony\data\web\sf
&lt;/VirtualHost&gt;
#Site B
&lt;VirtualHost *:80&gt;
    ServerAdmin admin@siteB.com
    DocumentRoot &quot;C:\wamp\www\sf_projects\siteB\web&quot;
    ServerName siteB.local
    ServerAlias siteB.local
    ErrorLog &quot;logs/siteB.localhost-error.log&quot;
    CustomLog &quot;logs/siteB.localhost-access.log&quot; common
    Alias /sf C:\wamp\www\sf_projects\siteB\lib\vendor\symfony\data\web\sf
&lt;/VirtualHost&gt;
#Pour garder son localhost opérationnel
&lt;VirtualHost *:80&gt;
    DocumentRoot &quot;C:\wamp\www&quot;
    ServerName localhost
    ServerAlias localhost
&lt;/VirtualHost&gt;</pre></td></tr></table></div>

</li>
</ul>
<h2>httpd.conf</h2>
<ul>
<li>Editer le fichier :<br />
<blockquote><p>C:\wamp\bin\apache\Apache2.2.11\conf\httpd.conf</p></blockquote>
</li>
<li> Décommenter la ligne :<br />
<blockquote><p>#Include conf/extra/httpd-vhosts.conf</p></blockquote>
</li>
</ul>
<h2>hosts</h2>
<ul>
<li>Editer le fichier :<br />
<blockquote><p>C:\WINDOWS\system32\drivers\etc\hosts</p></blockquote>
</li>
<li>Ajouter ces 2 lignes :<br />
<blockquote><p>127.0.0.1       localhost siteA.local<br />
127.0.0.1       localhost siteB.local</p></blockquote>
</li>
</ul>
<p>Voilà, redémarrez Wamp, et vos sites  sont accessibles aux adresses suivantes :</p>
<blockquote><p>http://siteA.local/</p>
<p>http://siteB.local/</p></blockquote>
]]></content:encoded>
			<wfw:commentRss>http://www.lexik.fr/blog/symfony/symfony/wamp-virtual-host-109/feed</wfw:commentRss>
		<slash:comments>9</slash:comments>
		</item>
	</channel>
</rss>

