<?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>Void And Any &#187; web</title>
	<atom:link href="http://voidandany.free.fr/index.php/tag/web/feed/" rel="self" type="application/rss+xml" />
	<link>http://voidandany.free.fr</link>
	<description>mon bazar...</description>
	<lastBuildDate>Sat, 09 Dec 2017 09:24:06 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.1</generator>
		<item>
		<title>Restreindre l&#8217;accès d&#8217;un site, d&#8217;un répertoire avec Nginx</title>
		<link>http://voidandany.free.fr/index.php/restreindre-lacces-dun-site-dun-repertoire-avec-nginx/</link>
		<comments>http://voidandany.free.fr/index.php/restreindre-lacces-dun-site-dun-repertoire-avec-nginx/#comments</comments>
		<pubDate>Thu, 07 Apr 2011 15:00:58 +0000</pubDate>
		<dc:creator>voidAndAny</dc:creator>
				<category><![CDATA[linux]]></category>
		<category><![CDATA[software]]></category>
		<category><![CDATA[nginx]]></category>
		<category><![CDATA[sécurité]]></category>
		<category><![CDATA[web]]></category>

		<guid isPermaLink="false">http://voidandany.free.fr/?p=3537</guid>
		<description><![CDATA[La plupart des sites Web que je vais héberger sur mon Dockstar sont privés. Par exemple je ne souhaite pas que mes photos de familles soient visible par tous le monde&#8230;. Pour restreindre l&#8217;accès à ces applications/sites web, j&#8217;aurais pu &#8230; <a href="http://voidandany.free.fr/index.php/restreindre-lacces-dun-site-dun-repertoire-avec-nginx/">Continuer la lecture <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>La plupart des <strong>sites Web</strong> que je vais héberger sur mon <a title="Marques-pages : Un mini serveur le Seagate Dockstar" href="http://voidandany.free.fr/index.php/marques-pages-un-mini-serveur-le-seagate-dockstar/">Dockstar</a> sont <strong>privés</strong>. Par exemple je ne souhaite pas que mes photos de familles soient visible par tous le monde&#8230;.</p>
<p>Pour restreindre l&#8217;accès à ces applications/sites web, j&#8217;aurais pu choisir des scripts php qui intégraient une gestion utilisateurs. Mais il est déjà difficile de trouver un script php qui fasse ce que l&#8217;on veut et qui soit léger donc si il faut en plus qu&#8217;il intègre une gestion complète et sécurisée des accès utilisateurs cela devient mission impossible&#8230;.</p>
<p>Surtout qu&#8217;il existe une alternative : <strong>déléguer l&#8217;accès à un site au serveur web.</strong></p>
<p><strong><br />
 </strong></p>
<h2>Authentification par mot de passe</h2>
<p>Avec Apache cela se fait avec les fichiers .htacces, sous <a title="Installer un serveur web (nginx) sur le Seagate Dockstar" href="http://voidandany.free.fr/index.php/installer-un-serveur-web-nginx-sur-le-seagate-dockstar/">Nginx</a> cela se fait dans le fichier de configuration du site avec le module <a href="http://wiki.nginx.org/HttpAuthBasicModule">HttpAuthBasicModule</a>.</p>
<p>La configuration d&#8217;un site se fait via la création d&#8217;un fichier dans le répertoire /etc/nginx/sites-enabled/, pour restreindre l&#8217;accès à un répertoire d&#8217;un site il suffit d&#8217;ajouter les directives <a href="http://wiki.nginx.org/HttpAuthBasicModule#auth_basic">auth_basic</a> et <a href="http://wiki.nginx.org/HttpAuthBasicModule#auth_basic_user_file">auth_basic_user_file</a> dans le fichier du site.</p>
<ul>
<li>La directive <a href="http://wiki.nginx.org/HttpAuthBasicModule#auth_basic">auth_basic</a> indique que l&#8217;on utilise une authentification, les texte après sera affiché dans la boite de dialogue d&#8217;authentification :</li>
<li>La directive <a href="http://wiki.nginx.org/HttpAuthBasicModule#auth_basic_user_file">auth_basic_user_file</a> indique le chemin vers le fichier contenant les couple login / mot de passe (crypté) autorisé à accéder au répertoire.</li>
</ul>
<p>Voici ma configuration :</p>

<div class="wp_syntax"><div class="code"><pre class="text" style="font-family:monospace;">server {
	listen       80;
	server_name  localhost;
	root         /var/www;
&nbsp;
	# Security
	location ~ /\.ht {
		deny  all;
	}
&nbsp;
	location /Repertoire_protege/ {
		auth_basic            &quot;Qui va là&quot;;
		auth_basic_user_file  /$document_root/Repertoire_protege/.htpasswd;
&nbsp;
		index  index.html index.htm index.php;
&nbsp;
		location ~ \.php$ {
			include /etc/nginx/fastcgi_params;
			fastcgi_param   SCRIPT_FILENAME  $document_root$fastcgi_script_name;
			fastcgi_pass    127.0.0.1:9000;
		}
	}
}</pre></div></div>

<p>J&#8217;ai personnellement choisi de stocker le fichier contenant les login/mots de passe dans le répertoire à protéger lui même mais on peut le mettre où l&#8217;on souhaite (/etc/nginx, etc&#8230;), de même le nom est par convention/ habitude .htpasswd (héritage d&#8217;Apache) mais on peut choisir le nom que l&#8217;on veut.</p>
<p>Par sécurité (indispensable) dès lors que l&#8217;on stock ce fichier dans un répertoire accessible par Nginx, il convient d&#8217;<strong>interdire son accès</strong> (sinon il pourra être affiché/télécharger). Dans mon cas il s&#8217;agit de la directive &laquo;&nbsp;location ~ /\.ht&nbsp;&raquo; qui interdit l&#8217;accès à tous fichier commençant par .ht</p>
<p>&nbsp;</p>
<h3>Création du fichier des login / mot de passe</h3>
<p>Pour créer le fichier .htpasswd contenant les login et le mot de passe crypté, il est communément conseillé d&#8217;utiliser le programme htpasswd du package apache2-utils.</p>
<p>Lorsque l&#8217;on utilise Nginx, il est toujours un peu dérangeant d&#8217;installer un package apache (même si ce dernier est petit : 1.3Mo), il existe donc des alternative sous forme de script perl par exemple.</p>
<p>Le premier que j&#8217;ai trouvé/testé est basique  :</p>

<div class="wp_syntax"><div class="code"><pre class="perl" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">#!/usr/bin/perl</span>
 <span style="color: #000000; font-weight: bold;">use</span> strict<span style="color: #339933;">;</span>
 <span style="color: #000066;">chomp</span><span style="color: #009900;">&#40;</span><span style="color: #b1b100;">my</span> <span style="color: #0000ff;">$username</span><span style="color: #339933;">=</span><span style="color: #0000ff;">$ARGV</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">0</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
 <span style="color: #000066;">chomp</span><span style="color: #009900;">&#40;</span><span style="color: #b1b100;">my</span> <span style="color: #0000ff;">$password</span><span style="color: #339933;">=</span><span style="color: #0000ff;">$ARGV</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">1</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
 <span style="color: #000066;">print</span> <span style="color: #0000ff;">$username</span><span style="color: #339933;">.</span><span style="color: #ff0000;">&quot;:&quot;</span><span style="color: #339933;">.</span><span style="color: #000066;">crypt</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">$password</span><span style="color: #339933;">,</span><span style="color: #0000ff;">$username</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">.</span><span style="color: #ff0000;">&quot;<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">;</span></pre></div></div>

<p>Il prend en paramètre le login et le mot de passe (en clair), crypte le mot de passe et écrit sur la sortie standard le couple login / mot de passe crypté avec la format attendu d&#8217;un ficheir .htpasswd.</p>
<p>&nbsp;</p>
<p>Le second (que j&#8217;ai gardé) est plus ressemblant à htpasswd d&#8217;Apache <a href="http://www.intuitive.com/wicked/examples/htpasswd-b.html">htpasswd-b: a smart replacement for the Apache htpasswd utility</a></p>

<div class="wp_syntax"><div class="code"><pre class="perl" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">#!/usr/bin/perl</span>
&nbsp;
<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span> <span style="color: #000066;">scalar</span> <span style="color: #339933;">@</span><span style="color: #000000; font-weight: bold;">ARGV</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
	<span style="color: #000066;">print</span> <span style="color: #ff0000;">&quot;Usage: htpasswd-b passwordfile user password<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">;</span>
	<span style="color: #000066;">print</span> <span style="color: #ff0000;">&quot;(this program automatically creates the pw file if needed.)<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">;</span>
	<span style="color: #000066;">exit</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #0000ff;">@saltsource</span> <span style="color: #339933;">=</span> <span style="color: #009900;">&#40;</span><span style="color: #ff0000;">'a'</span><span style="color: #339933;">..</span><span style="color: #ff0000;">'z'</span><span style="color: #339933;">,</span> <span style="color: #ff0000;">'A'</span><span style="color: #339933;">..</span><span style="color: #ff0000;">'Z'</span><span style="color: #339933;">,</span> <span style="color: #ff0000;">'0'</span><span style="color: #339933;">..</span><span style="color: #ff0000;">'9'</span><span style="color: #339933;">,</span><span style="color: #ff0000;">'.'</span><span style="color: #339933;">,</span><span style="color: #ff0000;">'/'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #0000ff;">$randum_num</span> <span style="color: #339933;">=</span> <span style="color: #000066;">int</span><span style="color: #009900;">&#40;</span><span style="color: #000066;">rand</span><span style="color: #009900;">&#40;</span><span style="color: #000066;">scalar</span> <span style="color: #0000ff;">@saltsource</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #0000ff;">$salt</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">$saltsource</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">$randum_num</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
<span style="color: #0000ff;">$randum_num</span> <span style="color: #339933;">=</span> <span style="color: #000066;">int</span><span style="color: #009900;">&#40;</span><span style="color: #000066;">rand</span><span style="color: #009900;">&#40;</span><span style="color: #000066;">scalar</span> <span style="color: #0000ff;">@saltsource</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #0000ff;">$salt</span> <span style="color: #339933;">.=</span> <span style="color: #0000ff;">$saltsource</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">$randum_num</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #0000ff;">$outf</span><span style="color: #339933;">=</span><span style="color: #0000ff;">$ARGV</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">0</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
<span style="color: #0000ff;">$user</span><span style="color: #339933;">=</span><span style="color: #0000ff;">$ARGV</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">1</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
<span style="color: #0000ff;">$passwd</span><span style="color: #339933;">=</span><span style="color: #0000ff;">$ARGV</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">2</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #0000ff;">$user</span> <span style="color: #339933;">&amp;&amp;</span> <span style="color: #0000ff;">$passwd</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
	<span style="color: #0000ff;">$encrypted</span> <span style="color: #339933;">=</span> <span style="color: #000066;">crypt</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">$passwd</span><span style="color: #339933;">,</span> <span style="color: #ff0000;">&quot;$salt&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #339933;">-</span>f <span style="color: #0000ff;">$outf</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		<span style="color: #000066;">open</span><span style="color: #009900;">&#40;</span>OUT<span style="color: #339933;">,</span> <span style="color: #ff0000;">&quot;&gt;&gt;$outf&quot;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">||</span> <span style="color: #000066;">die</span> <span style="color: #ff0000;">&quot;htpasswd-b error: $!<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span> <span style="color: #b1b100;">else</span> <span style="color: #009900;">&#123;</span>
		<span style="color: #000066;">open</span><span style="color: #009900;">&#40;</span>OUT<span style="color: #339933;">,</span> <span style="color: #ff0000;">&quot;&gt;$outf&quot;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">||</span> <span style="color: #000066;">die</span> <span style="color: #ff0000;">&quot;htpasswd-b error: $!<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
	<span style="color: #000066;">print</span> OUT <span style="color: #ff0000;">&quot;$user:$encrypted<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">;</span>
	<span style="color: #000066;">close</span><span style="color: #009900;">&#40;</span>OUT<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #000066;">exit</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>Créer un fichier (par exemple htpasswd-perl.pl), y copier le texte ci-dessus, le rendre exécutable (chmod). Il suffit ensuite d’appeler ce script avec le nom du fichier à créer / compléter, le login et le mot de passe en clair.</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">.<span style="color: #000000; font-weight: bold;">/</span>htpasswd-perl.pl <span style="color: #000000; font-weight: bold;">/</span>var<span style="color: #000000; font-weight: bold;">/</span>www<span style="color: #000000; font-weight: bold;">/</span>Repertoire_protege<span style="color: #000000; font-weight: bold;">/</span>.htpasswd utilisateur mot_de_passe</pre></div></div>

<p>Enfin j&#8217;ai trouvé mais non testé un troisième script qui semble très complet :</p>
<p><a href="http://blog.shk-desktop.com/749-htpasswd-perl-mon-replacement-de-htpasswd">htpasswd-perl: mon replacement de htpasswd | Shtark.fr</a></p>
<p>&nbsp;</p>
<h3>Authentification par mot de passe et php</h3>
<p>Si votre site doit servir des pages php vous aurez surement une directive du type &laquo;&nbsp;location ~ \.php$&nbsp;&raquo; indiquant le paramétrage fastCGI. Il est très important de mettre cette directive dans le bloc location protégé (cf ma configuration ci-dessus) sinon l&#8217;accès au répertoire sera protégé :</p>

<div class="wp_syntax"><div class="code"><pre class="text" style="font-family:monospace;">http:/localhost/Repertoire_protege</pre></div></div>

<p><a href="http://voidandany.free.fr/wp-content/uploads/2011-04-04_174936.png"><img class="aligncenter size-full wp-image-3685" title="2011-04-04_174936" src="http://voidandany.free.fr/wp-content/uploads/2011-04-04_174936.png" alt="" width="600" height="209" /></a>Mais pas l&#8217;accès directe à une page php sur le même site :</p>

<div class="wp_syntax"><div class="code"><pre class="text" style="font-family:monospace;">http:/localhost/Repertoire_protege/index.php</pre></div></div>

<p><a href="http://voidandany.free.fr/wp-content/uploads/2011-04-04_175002.png"><img class="aligncenter size-full wp-image-3686" title="2011-04-04_175002" src="http://voidandany.free.fr/wp-content/uploads/2011-04-04_175002.png" alt="" width="600" height="223" /></a></p>
<h2>Restriction d&#8217;accès par IP</h2>
<p>Pour être encore plus sécurisé on peut carrément restreindre l&#8217;accès d&#8217;un site ou d&#8217;un répertoire à une liste fini d&#8217;adresse IP avec les directives <a href="http://wiki.nginx.org/HttpAccessModule#allow">allow</a> et <a href="http://wiki.nginx.org/HttpAccessModule#deny">deny</a> :</p>

<div class="wp_syntax"><div class="code"><pre class="text" style="font-family:monospace;">	location /Repertoire_protege/ {
		auth_basic            &quot;Qui va là&quot;;
		auth_basic_user_file  /$document_root/Repertoire_protege/.htpasswd;
&nbsp;
		allow 127.0.0.1;
		deny all;
&nbsp;
		index  index.html index.htm index.php;
&nbsp;
		location ~ \.php$ {
			include /etc/nginx/fastcgi_params;
			fastcgi_param   SCRIPT_FILENAME  $document_root$fastcgi_script_name;
			fastcgi_pass    127.0.0.1:9000;
		}
	}</pre></div></div>

<p>Allow liste les IP autorisés et deny celle qui sont interdites, dans l&#8217;exemple ci-dessus toutes les IP sont interdites sauf l&#8217;IP locale (127.0.0.1)</p>
<p>Enfin on peut affiner le comportement de la restriction par IP avec la restriction par mot de passe avec la directive <a href="http://wiki.nginx.org/HttpCoreModule#satisfy">satisfy</a> qui indique si les 2 restrictions (IP + mot de passe) doivent être remplies (satisfy all) ou 1 seule d&#8217;entre elle (satisfy any) :</p>
<p>Exemple si on a une restriction par mot de passe + la restriction suivante :</p>

<div class="wp_syntax"><div class="code"><pre class="text" style="font-family:monospace;">allow 192.168.1.100;
deny all;</pre></div></div>

<p>Voici les résultats en fonction de la machine accédant au site/répertoire :</p>
<table border="0">
<tbody>
<tr>
<td style="text-align: center;"><strong>Accès depuis</strong></td>
<td><strong>satisfy any</strong></td>
<td><strong>satisfy all</strong></td>
</tr>
<tr>
<td>192.168.1.100</td>
<td>accès direct au site
</td>
<td>prompt de connexion</td>
</tr>
<tr>
<td>autre</td>
<td>prompt de connexion</td>
<td>403 forbiden</td>
</tr>
</tbody>
</table>
<p>&nbsp;</p>
<p><span style="text-decoration: underline;"><em><strong>Sources :</strong></em></span></p>
<p><a title="Permanent Link to Password protect folders with NGINX the right way" rel="bookmark" href="http://cutfromthenorth.com/password-protect-folders-with-nginx-the-right-way/">Password protect folders with NGINX the right way</a> : Indique la &laquo;&nbsp;ruse&nbsp;&raquo; de protection d&#8217;un répertoire avec php</p>
<p><a title="Permanent Link: Restriction of the access with the help of Nginx" rel="bookmark" href="http://www.alrond.com/en/2007/apr/12/restriction-access-with-nginx/">Restriction of the access with the help of Nginx</a> : voir restriction sur IP</p>
<p><a href="http://nginx.org/en/docs/http/request_processing.html#simple_php_site_configuration">How nginx processes a request</a></p>
<p><a href="http://serverfault.com/questions/228031/nginx-auth-password-or-ip">nginx auth password or ip &#8211; Server Fault</a></p>
]]></content:encoded>
			<wfw:commentRss>http://voidandany.free.fr/index.php/restreindre-lacces-dun-site-dun-repertoire-avec-nginx/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Ajouter le support SQLite à php</title>
		<link>http://voidandany.free.fr/index.php/ajouter-le-support-sqlite-a-php/</link>
		<comments>http://voidandany.free.fr/index.php/ajouter-le-support-sqlite-a-php/#comments</comments>
		<pubDate>Fri, 25 Mar 2011 15:32:22 +0000</pubDate>
		<dc:creator>voidAndAny</dc:creator>
				<category><![CDATA[software]]></category>
		<category><![CDATA[web]]></category>

		<guid isPermaLink="false">http://voidandany.free.fr/?p=3528</guid>
		<description><![CDATA[Comme indiqué dans l&#8217;article Installer et configurer Mysql sur le Dockstar, MySQL est un peut trop gourmand en ressource pour un plug computer tel que le Dockstar. Cependant pour certains usages (description à venir) du Dockstar j&#8217;ai besoin d&#8217;une base &#8230; <a href="http://voidandany.free.fr/index.php/ajouter-le-support-sqlite-a-php/">Continuer la lecture <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p><a href="http://voidandany.free.fr/wp-content/uploads/SQLite_Logo-3e5453f0a4c3e6f5.gif"><img class="alignleft size-full wp-image-3567" title="SQLite" src="http://voidandany.free.fr/wp-content/uploads/SQLite_Logo-3e5453f0a4c3e6f5.gif" alt="" width="200" height="89" /></a>Comme indiqué dans l&#8217;article <a title="Installer et configurer Mysql sur le Dockstar" href="http://voidandany.free.fr/index.php/installer-et-configurer-mysql-sur-le-dockstar/">Installer et configurer Mysql sur le Dockstar</a>, MySQL est un peut trop gourmand en ressource pour un plug computer tel que le <a title="Marques-pages : Un mini serveur le Seagate Dockstar" href="http://voidandany.free.fr/index.php/marques-pages-un-mini-serveur-le-seagate-dockstar/">Dockstar</a>.</p>
<p>Cependant pour certains usages (description à venir) du Dockstar j&#8217;ai besoin d&#8217;une base de donnée, c&#8217;est là qu&#8217;intervient <strong>SQLite</strong>, une base de donnée atypique puisque :</p>
<p>&laquo;&nbsp;Contrairement aux serveurs de bases de données traditionnels, comme MySQL ou PostgreSQL, sa particularité est de ne pas reproduire le schéma habituel client-serveur mais d&#8217;être directement intégrée aux programmes. L&#8217;intégralité de la base de données (déclarations, tables, index et données) est stockée dans un fichier indépendant de la plateforme.&nbsp;&raquo; (source <a href="http://fr.wikipedia.org/wiki/SQLite">Wikipedia</a>)</p>
<p>Voici comment <strong>installer </strong>la base SQLite et comment l&#8217;intégrer à php :</p>
<p>
<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">sudo</span> <span style="color: #c20cb9; font-weight: bold;">aptitude</span> <span style="color: #c20cb9; font-weight: bold;">install</span> libsqlite0 php5-sqlite</pre></div></div>

</p>
<p>(594 ko utilisés)</p>
<p>Voila pour l&#8217;installation pour la <strong>configuration </strong>ce n&#8217;est pas beaucoup plus compliqué, il faut éditer le fichier<strong> php.ini</strong> (qui sous ma <a title="Installer Debian sur le Seagate Dockstar" href="http://voidandany.free.fr/index.php/installer-debian-sur-le-seagate-dockstar/">Debian Squeeze</a> se trouve dans /etc/php5/cgi/).</p>
<p>Trouver la section suivante :</p>
<p>
<div class="wp_syntax"><div class="code"><pre class="text" style="font-family:monospace;">;;;;;;;;;;;;;;;;;;;;;;
; Dynamic Extensions ;
;;;;;;;;;;;;;;;;;;;;;;</pre></div></div>

</p>
<p>Et y ajouter la ligne :</p>
<p>
<div class="wp_syntax"><div class="code"><pre class="text" style="font-family:monospace;">extension=sqlite.so</pre></div></div>

</p>
<p>Pour finir <strong>re-démarrer</strong> le serveur Web ou le serveur php (sudo /etc/init.d/php5-fcgi restart)</p>
]]></content:encoded>
			<wfw:commentRss>http://voidandany.free.fr/index.php/ajouter-le-support-sqlite-a-php/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Installer un serveur web (nginx) sur le Seagate Dockstar</title>
		<link>http://voidandany.free.fr/index.php/installer-un-serveur-web-nginx-sur-le-seagate-dockstar/</link>
		<comments>http://voidandany.free.fr/index.php/installer-un-serveur-web-nginx-sur-le-seagate-dockstar/#comments</comments>
		<pubDate>Mon, 21 Mar 2011 17:16:07 +0000</pubDate>
		<dc:creator>voidAndAny</dc:creator>
				<category><![CDATA[linux]]></category>
		<category><![CDATA[plug computer]]></category>
		<category><![CDATA[software]]></category>
		<category><![CDATA[dockstar]]></category>
		<category><![CDATA[nginx]]></category>
		<category><![CDATA[web]]></category>

		<guid isPermaLink="false">http://voidandany.free.fr/?p=3483</guid>
		<description><![CDATA[Après l&#8217;installation et la configuration de Debian sur le Seagate Dockstar, voici venu l&#8217;installation de ce qu&#8217;il faut pour qu&#8217;il remplisse son premier rôle : Serveur Web. J&#8217;ai déjà fait un article sur l&#8217;installation d&#8217;un serveur Web Cherokee et Lighttpd, &#8230; <a href="http://voidandany.free.fr/index.php/installer-un-serveur-web-nginx-sur-le-seagate-dockstar/">Continuer la lecture <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p><a href="http://voidandany.free.fr/wp-content/uploads/Nginx-Logo.png"><img class="alignleft size-medium wp-image-3541" title="Nginx" src="http://voidandany.free.fr/wp-content/uploads/Nginx-Logo-300x83.png" alt="" width="300" height="83" /></a>Après l&#8217;<a title="Installer Debian sur le Seagate Dockstar" href="http://voidandany.free.fr/index.php/installer-debian-sur-le-seagate-dockstar/">installation</a> et la <a title="Configuration de « base » du Dockstar" href="http://voidandany.free.fr/index.php/configuration-de-base-du-dockstar/">configuration</a> de Debian sur le Seagate Dockstar, voici venu l&#8217;installation de ce qu&#8217;il faut pour qu&#8217;il remplisse son premier rôle : <strong>Serveur Web</strong>.</p>
<p>J&#8217;ai déjà fait un article sur l&#8217;installation d&#8217;un serveur Web <a title="Installation d’un serveur Web avec Cherokee" href="http://voidandany.free.fr/index.php/installation-dun-serveur-web-avec-cherokee/">Cherokee</a> et <a title="Installation d’un serveur Web avec Lighttpd" href="http://voidandany.free.fr/index.php/installation-dun-serveur-web-avec-lighttpd/">Lighttpd</a>, mais ces 2 serveurs web sont soit trop gourmand en ressource soit trop gros.</p>
<p>Il reste un autre challenger à Apache, il s&#8217;agit de<strong> <a href="http://nginx.org/en/"><em>nginx</em></a> </strong>(se prononce engine X).</p>
<p>Ce serveur web en plus d&#8217;être incroyablement <strong>performant </strong>est incroyablement <strong>sobre en ressources</strong>, il est quasiment systématiquement installé sur les machines de faible puissance que sont les plug computer.</p>
<p>Contrairement aux articles précédemment cités sur l&#8217;installation de Cherokee et Lihttpd je ne détaillerais pas l&#8217;installation de MySQL ici, pour la simple et bonne raison que je ne l&#8217;ai pas installé sur mon Dockstar (cf. <a title="Installer et configurer Mysql sur le Dockstar" href="http://voidandany.free.fr/index.php/installer-et-configurer-mysql-sur-le-dockstar/">Installer et configurer Mysql sur le Dockstar</a>)</p>
<p>&nbsp;</p>
<h2>Installation de nginx</h2>
<p>L&#8217;installation peut se faire simplement avec aptitude/apt-get car il existe un paquet nginx mais ce dernier est en version 0.7.x dans les dépôt Debian Squeeze, c&#8217;est à dire la version &laquo;&nbsp;legacy&nbsp;&raquo; (que l&#8217;on peut traduire par dépassé).</p>
<p>Un paquet de la version 0.8.54 est disponible sur <a href="http://www.dotdeb.org/2011/03/12/nginx-now-on-dotdeb/">dotdeb</a> mais ce dernier est disponible que pour les <a href="http://packages.dotdeb.org/dists/squeeze/nginx/">architectures i386 et amd64</a> mais pas pour l&#8217;architecture <a href="http://fr.wikipedia.org/wiki/Architecture_ARM">ARM</a></p>
<p>On va donc <strong>installer </strong>la <strong>version 0.8.54 à partir des sources</strong>, ce qui est tout de même un peu &laquo;&nbsp;touchy&nbsp;&raquo;.</p>
<p>Heureusement pour nous / moi <a href="http://blog.nicolargo.com/2011/01/installation-automatique-de-nginx-php-fpm-memcached-sous-debian.html">Nicolargo a publié un <strong>script</strong></a><strong> automatisant le process</strong>. Ce script installe nginx depuis les sources, le configure et installe php 5.x en mode <a href="http://php-fpm.org/">FPM</a> depuis les dépôts dotdeb, il faut donc l&#8217;adapter pour supprimer toute la partie installation de php-fpm qui n&#8217;est pas disponible non plus sur dotdeb pour les machines ARM.</p>
<p>Voici le script modifié :</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">#!/bin/bash</span>
<span style="color: #666666; font-style: italic;"># Mon script d'installation automatique de NGinx (depuis les sources)</span>
<span style="color: #666666; font-style: italic;">#</span>
<span style="color: #666666; font-style: italic;"># Nicolargo - 01/2011</span>
<span style="color: #666666; font-style: italic;"># Modifié VoidAndAny - 03/2011</span>
<span style="color: #666666; font-style: italic;"># GPL</span>
<span style="color: #666666; font-style: italic;">#</span>
<span style="color: #666666; font-style: italic;"># Syntaxe: # su - -c &quot;./nginxautoinstall.sh&quot;</span>
<span style="color: #666666; font-style: italic;"># Syntaxe: or # sudo ./nginxautoinstall.sh</span>
<span style="color: #007800;">VERSION</span>=<span style="color: #ff0000;">&quot;2.0&quot;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">##############################</span>
<span style="color: #666666; font-style: italic;"># Version de NGinx a installer</span>
&nbsp;
<span style="color: #007800;">NGINX_VERSION</span>=<span style="color: #ff0000;">&quot;0.8.54&quot;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">##############################</span>
<span style="color: #666666; font-style: italic;"># Debut de l'installation</span>
&nbsp;
<span style="color: #666666; font-style: italic;"># Test que le script est lance en root</span>
<span style="color: #000000; font-weight: bold;">if</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #007800;">$EUID</span> <span style="color: #660033;">-ne</span> <span style="color: #000000;">0</span> <span style="color: #7a0874; font-weight: bold;">&#93;</span>; <span style="color: #000000; font-weight: bold;">then</span>
<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;Le script doit être lancé en root: # sudo $0&quot;</span> <span style="color: #000000;">1</span><span style="color: #000000; font-weight: bold;">&gt;&amp;</span><span style="color: #000000;">2</span>
<span style="color: #7a0874; font-weight: bold;">exit</span> <span style="color: #000000;">1</span>
<span style="color: #000000; font-weight: bold;">fi</span>
&nbsp;
<span style="color: #666666; font-style: italic;"># Pre-requis</span>
<span style="color: #c20cb9; font-weight: bold;">aptitude</span> <span style="color: #c20cb9; font-weight: bold;">install</span> build-essential libpcre3-dev libssl-dev zlib1g-dev
&nbsp;
<span style="color: #666666; font-style: italic;"># Telechargement des fichiers</span>
<span style="color: #c20cb9; font-weight: bold;">wget</span> http:<span style="color: #000000; font-weight: bold;">//</span>sysoev.ru<span style="color: #000000; font-weight: bold;">/</span>nginx<span style="color: #000000; font-weight: bold;">/</span>nginx-<span style="color: #007800;">$NGINX_VERSION</span>.tar.gz
&nbsp;
<span style="color: #666666; font-style: italic;"># Extract</span>
<span style="color: #c20cb9; font-weight: bold;">tar</span> zxvf nginx-<span style="color: #007800;">$NGINX_VERSION</span>.tar.gz
&nbsp;
<span style="color: #666666; font-style: italic;"># Configure</span>
<span style="color: #7a0874; font-weight: bold;">cd</span> nginx-<span style="color: #007800;">$NGINX_VERSION</span>
.<span style="color: #000000; font-weight: bold;">/</span>configure   <span style="color: #660033;">--conf-path</span>=<span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>nginx<span style="color: #000000; font-weight: bold;">/</span>nginx.conf   <span style="color: #660033;">--error-log-path</span>=<span style="color: #000000; font-weight: bold;">/</span>var<span style="color: #000000; font-weight: bold;">/</span>log<span style="color: #000000; font-weight: bold;">/</span>nginx<span style="color: #000000; font-weight: bold;">/</span>error.log   <span style="color: #660033;">--pid-path</span>=<span style="color: #000000; font-weight: bold;">/</span>var<span style="color: #000000; font-weight: bold;">/</span>run<span style="color: #000000; font-weight: bold;">/</span>nginx.pid   <span style="color: #660033;">--lock-path</span>=<span style="color: #000000; font-weight: bold;">/</span>var<span style="color: #000000; font-weight: bold;">/</span>lock<span style="color: #000000; font-weight: bold;">/</span>nginx.lock   <span style="color: #660033;">--http-log-path</span>=<span style="color: #000000; font-weight: bold;">/</span>var<span style="color: #000000; font-weight: bold;">/</span>log<span style="color: #000000; font-weight: bold;">/</span>nginx<span style="color: #000000; font-weight: bold;">/</span>access.log   --with-http_dav_module   <span style="color: #660033;">--http-client-body-temp-path</span>=<span style="color: #000000; font-weight: bold;">/</span>var<span style="color: #000000; font-weight: bold;">/</span>lib<span style="color: #000000; font-weight: bold;">/</span>nginx<span style="color: #000000; font-weight: bold;">/</span>body   --with-http_ssl_module   <span style="color: #660033;">--http-proxy-temp-path</span>=<span style="color: #000000; font-weight: bold;">/</span>var<span style="color: #000000; font-weight: bold;">/</span>lib<span style="color: #000000; font-weight: bold;">/</span>nginx<span style="color: #000000; font-weight: bold;">/</span>proxy   --with-http_stub_status_module   <span style="color: #660033;">--http-fastcgi-temp-path</span>=<span style="color: #000000; font-weight: bold;">/</span>var<span style="color: #000000; font-weight: bold;">/</span>lib<span style="color: #000000; font-weight: bold;">/</span>nginx<span style="color: #000000; font-weight: bold;">/</span>fastcgi   <span style="color: #660033;">--with-debug</span>   --with-http_flv_module
&nbsp;
<span style="color: #666666; font-style: italic;"># Compile</span>
<span style="color: #c20cb9; font-weight: bold;">make</span>
&nbsp;
<span style="color: #666666; font-style: italic;"># Install</span>
<span style="color: #c20cb9; font-weight: bold;">make</span> <span style="color: #c20cb9; font-weight: bold;">install</span>
&nbsp;
<span style="color: #666666; font-style: italic;"># Post installation</span>
<span style="color: #7a0874; font-weight: bold;">cd</span> ..
<span style="color: #c20cb9; font-weight: bold;">mkdir</span> <span style="color: #000000; font-weight: bold;">/</span>var<span style="color: #000000; font-weight: bold;">/</span>lib<span style="color: #000000; font-weight: bold;">/</span>nginx
<span style="color: #c20cb9; font-weight: bold;">mkdir</span> <span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>nginx<span style="color: #000000; font-weight: bold;">/</span>conf.d
<span style="color: #c20cb9; font-weight: bold;">mkdir</span> <span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>nginx<span style="color: #000000; font-weight: bold;">/</span>sites-enabled
<span style="color: #c20cb9; font-weight: bold;">mkdir</span> <span style="color: #000000; font-weight: bold;">/</span>var<span style="color: #000000; font-weight: bold;">/</span>www
<span style="color: #c20cb9; font-weight: bold;">chown</span> <span style="color: #660033;">-R</span> www-data:www-data <span style="color: #000000; font-weight: bold;">/</span>var<span style="color: #000000; font-weight: bold;">/</span>www
&nbsp;
<span style="color: #666666; font-style: italic;"># Download the init script</span>
<span style="color: #c20cb9; font-weight: bold;">wget</span> http:<span style="color: #000000; font-weight: bold;">//</span>svn.nicolargo.com<span style="color: #000000; font-weight: bold;">/</span>debianpostinstall<span style="color: #000000; font-weight: bold;">/</span>trunk<span style="color: #000000; font-weight: bold;">/</span>nginx
<span style="color: #c20cb9; font-weight: bold;">mv</span> nginx <span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>init.d<span style="color: #000000; font-weight: bold;">/</span>
<span style="color: #c20cb9; font-weight: bold;">chmod</span> <span style="color: #000000;">755</span> <span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>init.d<span style="color: #000000; font-weight: bold;">/</span>nginx
<span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>sbin<span style="color: #000000; font-weight: bold;">/</span>update-rc.d <span style="color: #660033;">-f</span> nginx defaults
&nbsp;
<span style="color: #666666; font-style: italic;"># Download the default configuration file</span>
<span style="color: #666666; font-style: italic;"># Nginx + default site</span>
<span style="color: #c20cb9; font-weight: bold;">wget</span> http:<span style="color: #000000; font-weight: bold;">//</span>svn.nicolargo.com<span style="color: #000000; font-weight: bold;">/</span>debianpostinstall<span style="color: #000000; font-weight: bold;">/</span>trunk<span style="color: #000000; font-weight: bold;">/</span>nginx.conf
<span style="color: #c20cb9; font-weight: bold;">wget</span> http:<span style="color: #000000; font-weight: bold;">//</span>svn.nicolargo.com<span style="color: #000000; font-weight: bold;">/</span>debianpostinstall<span style="color: #000000; font-weight: bold;">/</span>trunk<span style="color: #000000; font-weight: bold;">/</span>default-site
<span style="color: #c20cb9; font-weight: bold;">mv</span> nginx.conf <span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>nginx<span style="color: #000000; font-weight: bold;">/</span>
<span style="color: #c20cb9; font-weight: bold;">mv</span> default-site <span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>nginx<span style="color: #000000; font-weight: bold;">/</span>sites-enabled<span style="color: #000000; font-weight: bold;">/</span>
&nbsp;
<span style="color: #666666; font-style: italic;"># Start NGinx</span>
<span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>init.d<span style="color: #000000; font-weight: bold;">/</span>nginx start
&nbsp;
<span style="color: #666666; font-style: italic;"># Summary</span>
<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;&quot;</span>
<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;--------------------------------------&quot;</span>
<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;NGinx installation finished&quot;</span>
<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;--------------------------------------&quot;</span>
<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;NGinx configuration folder:       /etc/nginx&quot;</span>
<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;NGinx default site configuration: /etc/nginx/sites-enabled/default-site&quot;</span>
<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;NGinx default HTML root:          /var/www&quot;</span>
<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;&quot;</span>
<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;If you use IpTables add the following rules:&quot;</span>
<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;iptables -A INPUT -i lo -s localhost -d localhost -j ACCEPT&quot;</span>
<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;iptables -A OUTPUT -o lo -s localhost -d localhost -j ACCEPT&quot;</span>
<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;iptables -A OUTPUT -m state --state RELATED,ESTABLISHED -j ACCEPT&quot;</span>
<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;iptables -A INPUT  -p tcp --dport http -j ACCEPT&quot;</span>
<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;--------------------------------------&quot;</span>
<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;&quot;</span>
&nbsp;
<span style="color: #666666; font-style: italic;"># Fin du script</span></pre></div></div>

<p>&nbsp;</p>
<p>A l&#8217;issu de ce script si on va à l&#8217;adresse IP du Dockstar avec un navigateur web, on doit avoir la page suivante qui s&#8217;affiche :</p>
<p><a href="http://voidandany.free.fr/wp-content/uploads/Sélection_0078.png"><img class="aligncenter size-medium wp-image-3484" title="Nginx" src="http://voidandany.free.fr/wp-content/uploads/Sélection_0078-300x111.png" alt="" width="300" height="111" /></a></p>
<p>Pour être sûr que nginx peut nous restituer une page HTML on peut lancer les commandes suivante (sur la Dockstar)</p>
<p lang="bash">&nbsp;</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;test&quot;</span> <span style="color: #000000; font-weight: bold;">&gt;</span> index.html
<span style="color: #c20cb9; font-weight: bold;">sudo</span> <span style="color: #c20cb9; font-weight: bold;">chown</span> www-data:www-data index.html
<span style="color: #c20cb9; font-weight: bold;">sudo</span> <span style="color: #c20cb9; font-weight: bold;">mv</span> index.html <span style="color: #000000; font-weight: bold;">/</span>var<span style="color: #000000; font-weight: bold;">/</span>www</pre></div></div>

<p>&nbsp;</p>
<p>En allant sur l&#8217;adresse IP du Dockstar, on devrait désormais avoir test qui s&#8217;affiche.</p>
<p>&nbsp;</p>
<h2>Installation de PHP</h2>
<p>Il existe de plusieurs façon pour un serveur web d&#8217;interagir avec le &laquo;&nbsp;moteur&nbsp;&raquo; d&#8217;interprétation de php  :</p>
<ul>
<li>module  : php est interprété directement par le serveur Web (<a href="http://php.net/manual/en/security.apache.php">avec apache par exemple</a>)</li>
<li><a href="http://fr.wikipedia.org/wiki/Common_Gateway_Interface">CGI</a> : le serveur Web laisse l&#8217;interprétation de php au module cgi php</li>
<li> <a href="http://www.fastcgi.com/drupal/node/2">fastCGI</a> : évolution de CGI pour le rendre plus performant </li>
<li><a href="http://redmine.lighttpd.net/projects/spawn-fcgi">spawn-fcgi</a> : une implémentation de fastCGI initialement faite pour le serveur web lighttpd</li>
<li><a href="http://php-fpm.org/">FPM</a> : implémentation de fastCGI remplaçant de spawn-fcgi <a href="http://vpsbible.com/php/php-benchmarking-phpfpm-fastcgi-spawnfcgi/">plus rapide et stable</a></li>
</ul>
<p>Malheureusement il n&#8217;existe pas de paquet Debian de l&#8217;implémentation FPM de fastCGI (php-fpm) pour l&#8217;architecture ARM, donc à moins de vouloir le compiler depuis les sources on <strong>utilisera l&#8217;implémentation spawn-fcgi de php</strong>.</p>
<p>Pour l&#8217;installation on fera :</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">sudo</span> <span style="color: #c20cb9; font-weight: bold;">aptitude</span> <span style="color: #c20cb9; font-weight: bold;">install</span> php5-cgi spawn-fcgi</pre></div></div>

<p>(20,3 Mo utilisés)</p>
<p>&nbsp;</p>
<p>Il faut ensuite faire un script init.d (/etc/init.d/php5-fcgi) pour que le serveur php démarre :</p>
<p>&nbsp;</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">#!/bin/sh</span>
&nbsp;
<span style="color: #666666; font-style: italic;">### BEGIN INIT INFO</span>
<span style="color: #666666; font-style: italic;"># Provides:       php5-fcgi</span>
<span style="color: #666666; font-style: italic;"># Required-Start: $remote_fs $syslog</span>
<span style="color: #666666; font-style: italic;"># Required-Stop:  $remote_fs $syslog</span>
<span style="color: #666666; font-style: italic;"># Default-Start:  2 3 4 5</span>
<span style="color: #666666; font-style: italic;"># Default-Stop:   0 1 6</span>
<span style="color: #666666; font-style: italic;"># Short-Description: PHP5 FastCgi Spawned processes</span>
<span style="color: #666666; font-style: italic;">### END INIT INFO</span>
&nbsp;
<span style="color: #007800;">COMMAND</span>=<span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>bin<span style="color: #000000; font-weight: bold;">/</span>spawn-fcgi
<span style="color: #007800;">ADDRESS</span>=127.0.0.1
<span style="color: #007800;">PORT</span>=<span style="color: #000000;">9000</span>
<span style="color: #007800;">USER</span>=www-data
<span style="color: #007800;">GROUP</span>=www-data
<span style="color: #007800;">PHPCGI</span>=<span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>bin<span style="color: #000000; font-weight: bold;">/</span>php5-cgi
<span style="color: #007800;">PIDFILE</span>=<span style="color: #000000; font-weight: bold;">/</span>var<span style="color: #000000; font-weight: bold;">/</span>run<span style="color: #000000; font-weight: bold;">/</span>fastcgi-php.pid
<span style="color: #007800;">RETVAL</span>=<span style="color: #000000;">0</span>
&nbsp;
<span style="color: #007800;">PHP_FCGI_MAX_REQUESTS</span>=<span style="color: #000000;">500</span>
<span style="color: #007800;">PHP_FCGI_CHILDREN</span>=<span style="color: #000000;">2</span>
&nbsp;
start<span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #7a0874; font-weight: bold;">&#41;</span> <span style="color: #7a0874; font-weight: bold;">&#123;</span>
 <span style="color: #7a0874; font-weight: bold;">export</span> PHP_FCGI_MAX_REQUESTS PHP_FCGI_CHILDREN
 <span style="color: #007800;">$COMMAND</span> <span style="color: #660033;">-a</span> <span style="color: #007800;">$ADDRESS</span> <span style="color: #660033;">-p</span> <span style="color: #007800;">$PORT</span> <span style="color: #660033;">-u</span> <span style="color: #007800;">$USER</span> <span style="color: #660033;">-g</span> <span style="color: #007800;">$GROUP</span> <span style="color: #660033;">-f</span> <span style="color: #007800;">$PHPCGI</span> <span style="color: #660033;">-P</span> <span style="color: #007800;">$PIDFILE</span>
<span style="color: #7a0874; font-weight: bold;">&#125;</span>
&nbsp;
stop<span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #7a0874; font-weight: bold;">&#41;</span> <span style="color: #7a0874; font-weight: bold;">&#123;</span>
 <span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>bin<span style="color: #000000; font-weight: bold;">/</span><span style="color: #c20cb9; font-weight: bold;">killall</span> <span style="color: #660033;">-9</span> php5-cgi
<span style="color: #7a0874; font-weight: bold;">&#125;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">case</span> <span style="color: #ff0000;">&quot;$1&quot;</span> <span style="color: #000000; font-weight: bold;">in</span>
 start<span style="color: #7a0874; font-weight: bold;">&#41;</span>
 start
 <span style="color: #007800;">RETVAL</span>=<span style="color: #007800;">$?</span>
 <span style="color: #000000; font-weight: bold;">;;</span>
 stop<span style="color: #7a0874; font-weight: bold;">&#41;</span>
 stop
 <span style="color: #007800;">RETVAL</span>=<span style="color: #007800;">$?</span>
 <span style="color: #000000; font-weight: bold;">;;</span>
 restart<span style="color: #000000; font-weight: bold;">|</span>reload<span style="color: #7a0874; font-weight: bold;">&#41;</span>
 stop
 start
 <span style="color: #007800;">RETVAL</span>=<span style="color: #007800;">$?</span>
 <span style="color: #000000; font-weight: bold;">;;</span>
 <span style="color: #000000; font-weight: bold;">*</span><span style="color: #7a0874; font-weight: bold;">&#41;</span>
 <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;Usage: fastcgi {start|stop|restart}&quot;</span>
 <span style="color: #7a0874; font-weight: bold;">exit</span> <span style="color: #000000;">1</span>
 <span style="color: #000000; font-weight: bold;">;;</span>
<span style="color: #000000; font-weight: bold;">esac</span>
<span style="color: #7a0874; font-weight: bold;">exit</span> <span style="color: #007800;">$RETVAL</span></pre></div></div>

<p>&nbsp;</p>
<p>Et on le démarre :</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">sudo</span> <span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>init.d<span style="color: #000000; font-weight: bold;">/</span>php5-fcgi start</pre></div></div>

<p>Il faut ensuite en théorie indiquer à nginx comment interpréter les fichiers php en ajouter ce genre de directives dans le fichier /etc/nginx/sites-enabled/default-site</p>
<p>&nbsp;</p>

<div class="wp_syntax"><div class="code"><pre class="text" style="font-family:monospace;">location ~ \.php$ {
 include /etc/nginx/fastcgi_params;
 fastcgi_param   SCRIPT_FILENAME  $document_root$fastcgi_script_name;
 fastcgi_pass    127.0.0.1:9000;
 }</pre></div></div>

<p>&nbsp;</p>
<p>J&#8217;ai marqué en théorie car l&#8217;installation de nginx faite par le script de Nicolargo créé un fichier default-site qui contient déjà cette directive.</p>
<p>&nbsp;</p>
<p>Pour tester php, on crée un fichier php contenant la directive phpinfo :</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;&lt;?php phpinfo(); ?&gt;&quot;</span> <span style="color: #000000; font-weight: bold;">&gt;</span> phpinfo.php
<span style="color: #c20cb9; font-weight: bold;">sudo</span> <span style="color: #c20cb9; font-weight: bold;">chown</span> www-data:www-data phpinfo.php
<span style="color: #c20cb9; font-weight: bold;">sudo</span> <span style="color: #c20cb9; font-weight: bold;">mv</span> phpinfo.php <span style="color: #000000; font-weight: bold;">/</span>var<span style="color: #000000; font-weight: bold;">/</span>www</pre></div></div>

<p>&nbsp;</p>
<p>Et en allant sur l&#8217;adresse IP du Dockstar, sur la page phpinfo.php on doit voir cette page s&#8217;afficher :</p>
<p><a href="http://voidandany.free.fr/wp-content/uploads/Sélection_0089.png"><img class="aligncenter" title="Sélection_008" src="http://voidandany.free.fr/wp-content/uploads/Sélection_0089-263x300.png" alt="" width="263" height="300" /></a></p>
<p>&nbsp;</p>
<p><span style="text-decoration: underline;"><strong>PS :</strong></span> Quelques information concernant l&#8217;espace disque utilisé par les différents serveur web (sur une Debian de base)</p>
<ul>
<li>nginx : 1.6 MB</li>
<li>apache2 : 44.4 MB </li>
<li>lighttpd : 35.8 MB</li>
</ul>
<p>&nbsp;</p>
<p><span style="text-decoration: underline;"><em><strong>Sources : </strong></em></span></p>
<p><a title="Installation automatique de NGinx, PHP-FPM, MemCached sous Debian" href="http://blog.nicolargo.com/2011/01/installation-automatique-de-nginx-php-fpm-memcached-sous-debian.html">Nicolargo : Installation automatique de NGinx, PHP-FPM, MemCached sous Debian</a></p>
<p><a href="http://www.it-wars.com/article176/seagate-dockstar-un-plug-computer-green">IT Wars : Seagate DockStar un plug computer green</a></p>
<p><a title="blog:nginx-php-install" href="http://blog.slucas.fr/blog/nginx-php-install">Blog slucas : Installation de nginx sous Debian</a></p>
<p><a href="http://neokraft.net/2010/03/20/serveur-web-nginx-php-mysql">Ici &amp; Ailleurs : Un serveur web avec Nginx, PHP et MySQL</a></p>
<p><a href="http://library.linode.com/web-servers/nginx/php-fastcgi/debian-5-lenny">Linode library : Nginx and PHP-FastCGI on Debian 5 (Lenny)</a></p>
<p><a href="http://library.linode.com/web-servers/nginx/configuration/basic">Linode library : Basic Nginx Configuration</a></p>
<p><a href="http://library.linode.com/web-servers/nginx/configuration/">Linode Library : Nginx Configuration</a></p>
<p><a title="Permanent Link to Optimiser son serveur Web avec Nginx" rel="bookmark" href="http://www.papygeek.com/software/optimiser-son-serveur-web-avec-nginx/">Papy Geek : Optimiser son serveur Web avec Nginx</a></p>
]]></content:encoded>
			<wfw:commentRss>http://voidandany.free.fr/index.php/installer-un-serveur-web-nginx-sur-le-seagate-dockstar/feed/</wfw:commentRss>
		<slash:comments>31</slash:comments>
		</item>
		<item>
		<title>Installer et configurer Mysql sur le Dockstar</title>
		<link>http://voidandany.free.fr/index.php/installer-et-configurer-mysql-sur-le-dockstar/</link>
		<comments>http://voidandany.free.fr/index.php/installer-et-configurer-mysql-sur-le-dockstar/#comments</comments>
		<pubDate>Wed, 16 Mar 2011 17:41:35 +0000</pubDate>
		<dc:creator>voidAndAny</dc:creator>
				<category><![CDATA[Brèves]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[plug computer]]></category>
		<category><![CDATA[dockstar]]></category>
		<category><![CDATA[web]]></category>

		<guid isPermaLink="false">http://voidandany.free.fr/?p=3468</guid>
		<description><![CDATA[Un des usages de mon Seagate Dockstar est de monter un serveur Web afin de mettre en ligne une galerie photo. La galerie photo que j&#8217;avais sélectionné était Zenphoto qui nécessite une base de données MySQL or j&#8217;ai trouvé un &#8230; <a href="http://voidandany.free.fr/index.php/installer-et-configurer-mysql-sur-le-dockstar/">Continuer la lecture <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>Un des usages de mon <a title="Lien permanent vers Marques-pages : Un mini serveur le Seagate Dockstar" rel="bookmark" href="../index.php/marques-pages-un-mini-serveur-le-seagate-dockstar/">Seagate Dockstar</a> est de monter un serveur Web afin de mettre en ligne une galerie photo.</p>
<p>La galerie photo que j&#8217;avais sélectionné était <a href="http://www.zenphoto.org/"><em><em>Zenphoto</em></em></a> qui nécessite une base de données MySQL or j&#8217;ai trouvé un <a href="http://projets.kd2.org/p/fotoo-gallery/">nouveau script de galerie photo</a> plus léger / simple et qui ne nécessite &laquo;&nbsp;que&nbsp;&raquo; SQLite (beaucoup plus léger que MySQL).</p>
<p>Voici donc brièvement mes <strong>notes d&#8217;installation et de configuration de MySQL</strong> (pour ne pas les perdre)</p>
<p>J&#8217;ai déjà traité cette installation <a href="http://voidandany.free.fr/index.php/installation-dun-serveur-web-avec-lighttpd/">ici</a> et <a href="http://voidandany.free.fr/index.php/installation-dun-serveur-web-avec-cherokee/">ici</a> (pas sur le Dockstar)</p>
<p>&nbsp;</p>
<p>L&#8217;installation est simplissime :</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">sudo</span> <span style="color: #c20cb9; font-weight: bold;">aptitude</span> <span style="color: #c20cb9; font-weight: bold;">install</span> mysql-server mysql-client</pre></div></div>

<p>Cela installe les paquets suivants :</p>
<p>libdbd-mysql-perl{a} libdbi-perl{a} libmysqlclient16{a} libnet-daemon-perl{a} libplrpc-perl{a} mysql-client mysql-client-5.1{a} mysql-common{a} mysql-server mysql-server-5.1{a} mysql-server-core-5.1{a} psmisc{a}</p>
<p>(54Mo sur le disque)</p>
<p>Lors de l&#8217;installation le mot de passe root est demandé :</p>

<div class="wp_syntax"><div class="code"><pre class="text" style="font-family:monospace;">Configuration de mysql-server-5.1
---------------------------------
Il est très fortement recommandé d'établir un mot de passe pour le compte d'administration de MySQL (« root »).
Si ce champ est laissé vide, le mot de passe ne sera pas changé.
Nouveau mot de passe du superutilisateur de MySQL :
Confirmation du mot de passe du superutilisateur de MySQL :</pre></div></div>

<p>&nbsp;</p>
<p>En l&#8217;état MySQL prend <strong>14.5% de la mémoire du Dockstar</strong> (pas léger l&#8217;animal), on trouvera <a href="http://chrisjohnston.org/2008/configuring-a-lightweight-apache-mysql-install-on-debian-ubuntu">ici</a> et <a href="http://brian.moonspot.net/2008/05/06/example-mycnf-files/">là</a> des <strong>optimisations </strong>pour MySQL, mais le plus simple est encore de prendre le fichier de configuration fournis par MySQL pour les petites machines :</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">sudo</span> <span style="color: #c20cb9; font-weight: bold;">cp</span>  <span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>mysql<span style="color: #000000; font-weight: bold;">/</span>my.cnf <span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>mysql<span style="color: #000000; font-weight: bold;">/</span>my.cnf.orig
<span style="color: #c20cb9; font-weight: bold;">sudo</span> <span style="color: #c20cb9; font-weight: bold;">cp</span>  <span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>share<span style="color: #000000; font-weight: bold;">/</span>doc<span style="color: #000000; font-weight: bold;">/</span>mysql-server-<span style="color: #000000;">5.1</span><span style="color: #000000; font-weight: bold;">/</span>examples<span style="color: #000000; font-weight: bold;">/</span>my-small.cnf <span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>mysql<span style="color: #000000; font-weight: bold;">/</span>my.cnf
<span style="color: #c20cb9; font-weight: bold;">sudo</span> <span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>init.d<span style="color: #000000; font-weight: bold;">/</span>mysql restart</pre></div></div>

<p>&nbsp;</p>
<p>Avec cette configuration MySQL prend toujours <strong>12.8% de la mémoire</strong>, d&#8217;où mon exploration pour trouver une alternative à zenphoto pour ne pas avoir à installer ce glouton de MySQL</p>
]]></content:encoded>
			<wfw:commentRss>http://voidandany.free.fr/index.php/installer-et-configurer-mysql-sur-le-dockstar/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Installation d&#8217;un serveur Web avec Lighttpd</title>
		<link>http://voidandany.free.fr/index.php/installation-dun-serveur-web-avec-lighttpd/</link>
		<comments>http://voidandany.free.fr/index.php/installation-dun-serveur-web-avec-lighttpd/#comments</comments>
		<pubDate>Mon, 10 Jan 2011 18:58:58 +0000</pubDate>
		<dc:creator>voidAndAny</dc:creator>
				<category><![CDATA[linux]]></category>
		<category><![CDATA[lamp]]></category>
		<category><![CDATA[web]]></category>

		<guid isPermaLink="false">http://voidandany.free.fr/?p=3247</guid>
		<description><![CDATA[J&#8217;ai déjà décrit Comment installer un serveur Web avec Cherokee, mais ce serveur Web est un peu trop confidentiel à mon gout. J&#8217;avais donc la possibilité d&#8217;installer apache2, la référence en la matière mais les souvenir que j&#8217;en ai sont &#8230; <a href="http://voidandany.free.fr/index.php/installation-dun-serveur-web-avec-lighttpd/">Continuer la lecture <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>J&#8217;ai déjà décrit <a title="Installation d’un serveur Web avec Cherokee" rel="bookmark" href="../index.php/installation-dun-serveur-web-avec-cherokee/">Comment installer un serveur Web avec Cherokee</a>, mais ce serveur Web est un peu trop confidentiel à mon gout.</p>
<p>J&#8217;avais donc la possibilité d&#8217;installer apache2, la référence en la matière mais les souvenir que j&#8217;en ai sont peu probants (configuration pas super simple), j&#8217;ai donc choisi lighttpd.</p>
<p>Comme l&#8217;article précédemment cité on installera MySQL, Lighttpd et php.</p>
<p><br class="spacer_" /></p>
<h3>Installation de MySQL</h3>
<p>Comme dans l&#8217;article précédent (pas de changement) :</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">sudo</span> <span style="color: #c20cb9; font-weight: bold;">aptitude</span> <span style="color: #c20cb9; font-weight: bold;">install</span> mysql-server mysql-client</pre></div></div>

<p>Ce qui installe :</p>

<div class="wp_syntax"><div class="code"><pre class="text" style="font-family:monospace;"> libdbd-mysql-perl{a} libdbi-perl{a} libhtml-template-perl{a} libnet-daemon-perl{a}
 libplrpc-perl{a} mysql-client mysql-client-5.1{a} mysql-client-core-5.1{a} mysql-server
 mysql-server-5.1{a} mysql-server-core-5.1{a}</pre></div></div>

<p><br class="spacer_" /></p>
<p>Il faudra renseigner le mot de passe du super-utilisateur root.</p>
<p><br class="spacer_" /></p>
<h3>Installation de Lighttpd</h3>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">sudo</span> <span style="color: #c20cb9; font-weight: bold;">aptitude</span> <span style="color: #c20cb9; font-weight: bold;">install</span>  lighttpd</pre></div></div>

<p>Ce qui installe :</p>

<div class="wp_syntax"><div class="code"><pre class="text" style="font-family:monospace;">libterm-readline-perl-perl{a} lighttpd spawn-fcgi{a}</pre></div></div>

<p>Si on test en allant sur l&#8217;adresse du serveur en http (http://ip_server), on aura alors la page suivante si tout fonctionne correctement :</p>
<p><a href="../wp-content/uploads/S%C3%A9lection_0019.png"><img class="aligncenter size-full wp-image-3248" title="Lighttpd Welcome" src="http://voidandany.free.fr/wp-content/uploads/Sélection_00114.png" alt="" width="532" height="455" /></a></p>
<h3>Installation de PHP</h3>
<p>Là encore aucune modification par rapport à Cherokee :</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">sudo</span> <span style="color: #c20cb9; font-weight: bold;">aptitude</span> <span style="color: #c20cb9; font-weight: bold;">install</span> php5-cgi php5-mysql</pre></div></div>

<p>Qui installe :</p>

<div class="wp_syntax"><div class="code"><pre class="text" style="font-family:monospace;">php5-cgi php5-common{a} php5-mysql</pre></div></div>

<p><br class="spacer_" /></p>
<h3>Ajout du support php à Lighttpd</h3>
<p>Contrairement à Cherokee cela se fait en ligne de commande (ce qui ma foi est plus simple) :</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">sudo</span> lighty-enable-mod fastcgi-php
<span style="color: #c20cb9; font-weight: bold;">sudo</span> lighty-enable-mod fastcgi
<span style="color: #c20cb9; font-weight: bold;">sudo</span> <span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>init.d<span style="color: #000000; font-weight: bold;">/</span>lighttpd force-reload</pre></div></div>

<p><br class="spacer_" /></p>
<h3>Test de php</h3>
<p>Tout comme pour Cherokee on crée un fichier php contenant l&#8217;instruction phpinfo() dans /var/www  (racine du site web)</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span>
   <span style="color: #b1b100;">echo</span> <span style="color: #990000;">phpinfo</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">?&gt;</span></pre></div></div>

<p>Si on va sur l&#8217;URL correspondante on devrait avoir :</p>
<p><a href="http://voidandany.free.fr/wp-content/uploads/Sélection_00212.png"><img class="aligncenter size-large wp-image-3250" title="phpInfo" src="http://voidandany.free.fr/wp-content/uploads/Sélection_00212-557x700.png" alt="" width="557" height="700" /></a></p>
<p><span style="text-decoration: underline;"><em><strong><br />
 </strong></em></span></p>
<p><span style="text-decoration: underline;"><em><strong>Sources :</strong></em></span><a href="http://doc.ubuntu-fr.org/lighttpd"><em> </em></a></p>
<p><a href="http://doc.ubuntu-fr.org/lighttpd"><em>lighttpd</em> &#8211; Documentation Ubuntu Francophone</a><a href="http://throka.org/linux_debian_lighttpd"></a></p>
<p><a href="http://throka.org/linux_debian_lighttpd">Installer un serveur web <em>Lighttpd</em> | throka.org</a></p>
]]></content:encoded>
			<wfw:commentRss>http://voidandany.free.fr/index.php/installation-dun-serveur-web-avec-lighttpd/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Installation d&#8217;un serveur Web avec Cherokee</title>
		<link>http://voidandany.free.fr/index.php/installation-dun-serveur-web-avec-cherokee/</link>
		<comments>http://voidandany.free.fr/index.php/installation-dun-serveur-web-avec-cherokee/#comments</comments>
		<pubDate>Wed, 03 Nov 2010 19:43:14 +0000</pubDate>
		<dc:creator>voidAndAny</dc:creator>
				<category><![CDATA[linux]]></category>
		<category><![CDATA[cherokee]]></category>
		<category><![CDATA[lamp]]></category>
		<category><![CDATA[web]]></category>

		<guid isPermaLink="false">http://voidandany.free.fr/?p=1979</guid>
		<description><![CDATA[Afin de mettre à disposition de ma famille mes photos numériques, je souhaite monter un serveur Web qui hébergera une galerie (script php). En effet compte tenu de la volumétrie (plusieurs gigas de photos) et du caractère personnel des photos &#8230; <a href="http://voidandany.free.fr/index.php/installation-dun-serveur-web-avec-cherokee/">Continuer la lecture <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>Afin de mettre à disposition de ma famille mes photos numériques, je souhaite monter un serveur Web qui hébergera une galerie (script php).</p>
<p>En effet compte tenu de la volumétrie (plusieurs gigas de photos) et du caractère personnel des photos je ne souhaite pas faire héberger cette gallerie (sur Free.fr par exemple).</p>
<p>Un serveur web est un ensemble de briques logiciel :</p>
<ul>
<li>une base de données : MySQL le plus souvent</li>
<li>un moteur de scripts : c&#8217;est ce qui permet de faire un site dynamique le plus courant est php</li>
<li>un serveur web proprement dit : le plus souvent Apache, mais il existe des prétendants et notamment Cheroke qui serait plus rapide qu&#8217;Apache et surtout plus facile à administrer.</li>
</ul>
<p><br class="spacer_" /></p>
<h3>Installation de MySQL</h3>
<p>Cela se fait par un simple :</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">sudo</span> <span style="color: #c20cb9; font-weight: bold;">aptitude</span> <span style="color: #c20cb9; font-weight: bold;">install</span> mysql-server mysql-client</pre></div></div>

<p><br class="spacer_" /></p>
<p>Qui installe les paquets suivant (par le jeu des dépendances et des méta-paquets) :</p>

<div class="wp_syntax"><div class="code"><pre class="text" style="font-family:monospace;">libdbd-mysql-perl{a} libdbi-perl{a} libhtml-template-perl{a} libnet-daemon-perl{a}
 libplrpc-perl{a} mysql-client mysql-client-5.1{a} mysql-client-core-5.1{a} mysql-server
 mysql-server-5.1{a} mysql-server-core-5.1{a}</pre></div></div>

<p><br class="spacer_" /></p>
<p>Lors de l&#8217;installation on nous demande le mot de passe du super-utilisateur de MySQL (root) :</p>
<p style="text-align: center;"><a href="http://voidandany.free.fr/wp-content/uploads/Sélection_0036.png"><img class="size-medium wp-image-3013 aligncenter" title="Sélection_003" src="http://voidandany.free.fr/wp-content/uploads/Sélection_0036-300x191.png" alt="" width="300" height="191" /></a></p>
<p><br class="spacer_" /></p>
<p>Au terme de l&#8217;installation on peut s&#8217;assurer que le service MySQL tourne par :<br class="spacer_" /></p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">sudo</span> service mysql status</pre></div></div>

<p><br class="spacer_" /></p>
<p>Qui renvoi :</p>

<div class="wp_syntax"><div class="code"><pre class="text" style="font-family:monospace;">mysql start/running, process 25769</pre></div></div>

<p><br class="spacer_" /></p>
<h3>Installation de Cherokee</h3>
<p>Là encore l&#8217;installation est simplissime :</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">sudo</span> <span style="color: #c20cb9; font-weight: bold;">aptitude</span> <span style="color: #c20cb9; font-weight: bold;">install</span> cherokee</pre></div></div>

<p><br class="spacer_" /></p>
<p>Qui installe :</p>

<div class="wp_syntax"><div class="code"><pre class="text" style="font-family:monospace;">cherokee libcherokee-base0{a} libcherokee-client0{a} libcherokee-config0{a}
 libcherokee-mod-admin{a} libcherokee-server0{a} spawn-fcgi{a}</pre></div></div>

<p><br class="spacer_" /></p>
<p>Au terme de l&#8217;installation on à un serveur Web statique c&#8217;est à dire capable de servir aux navigateurs de simples pages HTML, pour s&#8217;en assurer il suffit d&#8217;aller sur l&#8217;adresse de votre serveur en http :</p>
<p><a href="http://ip_server">http://ip_server</a></p>
<p>ip_server : est l&#8217;adresse IP de la machine sur laquelle vous avez installé Cherokee, si il s&#8217;agit de la machine locale, on pourra utiliser localhost.</p>
<p>Cherokee vous sert alors la page d&#8217;accueil du serveur :</p>
<p style="text-align: center;"><a href="http://voidandany.free.fr/wp-content/uploads/Sélection_0026.png"><img class="size-medium wp-image-2966 aligncenter" title="Cherokee" src="http://voidandany.free.fr/wp-content/uploads/Sélection_0026-256x300.png" alt="" width="256" height="300" /></a></p>
<p><br class="spacer_" /></p>
<h3>Administration Cherokee</h3>
<p>Le gros point fort de Cherokee est sont interface d&#8217;administration web, pas besoin d&#8217;éditer des fichiers de configuration.</p>
<p>Par défaut l&#8217;interface d&#8217;administration n&#8217;est pas accessible, il au préalable lancer sur le serveur contenant Cherokee la commande suivante :</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">sudo</span> cherokee-admin <span style="color: #660033;">-b</span></pre></div></div>

<p><br class="spacer_" /></p>
<p>Qui renvoi le login et le mot passe unique pour cette session de connexion à l&#8217;interface d&#8217;administration :</p>

<div class="wp_syntax"><div class="code"><pre class="text" style="font-family:monospace;">Login:
 User:              admin
 One-time Password: yDRmCWliaUxnM480
&nbsp;
Web Interface:
 URL:               http://localhost:9090/
&nbsp;
Cherokee Web Server 1.0.8 (Aug 11 2010): Listening on port ALL:9090, TLS
 disabled, IPv6 enabled, using epoll, 4096 fds system limit, max. 2041
 connections, caching I/O, single thread</pre></div></div>

<p><br class="spacer_" /></p>
<p><strong>Rque : </strong>si vous ne lancez pas cette commande avec sudo vous aurez le messages suivant</p>

<div class="wp_syntax"><div class="code"><pre class="text" style="font-family:monospace;">Unable to raise file descriptor limit to 4096
Configuration file is not writable
The configuration file &lt;code&gt;/etc/cherokee/cherokee.conf&lt;/code&gt; cannot be modified</pre></div></div>

<p><br class="spacer_" /></p>
<p>Il suffit alors d&#8217;aller à l&#8217;URL <a href="http://ip_server/">http://ip_server:9090</a> pour accéder à l&#8217;interface d&#8217;administration (après avoir renseigné le login, mot de passe indiqué par la commande cherokee-admin)<br class="spacer_" /></p>
<p style="text-align: center;"><a href="http://voidandany.free.fr/wp-content/uploads/Sélection_0018.png"><img class="size-medium wp-image-2965 aligncenter" title="Cherokee Admin" src="http://voidandany.free.fr/wp-content/uploads/Sélection_0018-300x177.png" alt="" width="300" height="177" /></a></p>
<p style="text-align: left;"><strong>Rque : </strong>les copie d&#8217;écran de cherokee sont réalisées avec la version 1.0.4-1 (version par défaut sous Ubuntu 10.10)</p>
<p style="text-align: left;"> </p>
<h3>PHP</h3>
<p>Pour avoir un site dynamique, on a besoin d&#8217;un moteur de script, le plus courant étant php</p>
<p>Pour l&#8217;installer</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">sudo</span> <span style="color: #c20cb9; font-weight: bold;">aptitude</span> <span style="color: #c20cb9; font-weight: bold;">install</span> php5-cgi php5-mysql</pre></div></div>

<p><br class="spacer_" /></p>
<p><strong>Rque</strong> : php5-mysql installe les modules autorisant la connexion à MySQL depuis php</p>
<p><br class="spacer_" /></p>
<p>Ce qui installe :</p>

<div class="wp_syntax"><div class="code"><pre class="text" style="font-family:monospace;">php5-cgi php5-common{a} php5-mysql</pre></div></div>

<p><br class="spacer_" /></p>
<p><br class="spacer_" /></p>
<h3>Ajout du support php à Cherokee</h3>
<p><strong>Rque : </strong>les copie d&#8217;écran de cherokee sont réalisées avec la version 1.0.4-1 (version par défaut sous Ubuntu 10.10)</p>
<p><br class="spacer_" /></p>
<p>Dans l&#8217;administration de cherokee cliquer sur vServers dans le bandeau haut :</p>
<p style="text-align: center;"><a href="http://voidandany.free.fr/wp-content/uploads/Sélection_0046.png"><img class="size-medium wp-image-3016 aligncenter" title="Sélection_004" src="http://voidandany.free.fr/wp-content/uploads/Sélection_0046-300x44.png" alt="" width="300" height="44" /></a></p>
<p>Par défaut il n&#8217;y a qu&#8217;un seul site de configuré &laquo;&nbsp;default&nbsp;&raquo;, cliquer dans l&#8217;onglet &laquo;&nbsp;Behavior&nbsp;&raquo; :</p>
<p style="text-align: center;"><a href="http://voidandany.free.fr/wp-content/uploads/Sélection_0065.png"><img class="size-medium wp-image-3017 aligncenter" title="Default site behavior" src="http://voidandany.free.fr/wp-content/uploads/Sélection_0055-300x123.png" alt="" width="300" height="123" /></a></p>
<p><br class="spacer_" /></p>
<p>Cliquer sur le bouton &laquo;&nbsp;Rule management&nbsp;&raquo; pour afficher les caractéristique du serveur virtuel :</p>
<p style="text-align: center;"><a href="http://voidandany.free.fr/wp-content/uploads/Sélection_0065.png"><img class="size-medium wp-image-3018 aligncenter" title="Sélection_006" src="http://voidandany.free.fr/wp-content/uploads/Sélection_0065-300x114.png" alt="" width="300" height="114" /></a></p>
<p>Cliquer sur le bouton + à gauche (à côté de &laquo;&nbsp;Behavior&nbsp;&raquo;) pour ajouter un rôle à notre serveur, un wizard apparait :</p>
<p style="text-align: center;"><a href="http://voidandany.free.fr/wp-content/uploads/Sélection_0072.png"><img class="size-medium wp-image-3019 aligncenter" title="Add Behavior wizard" src="http://voidandany.free.fr/wp-content/uploads/Sélection_0072-300x186.png" alt="" width="300" height="186" /></a></p>
<p>Sélectionner Langues, puis php et enfin appuyer sur ajouter :</p>
<p style="text-align: center;"><a href="http://voidandany.free.fr/wp-content/uploads/Sélection_0083.png"><img class="size-medium wp-image-3020 aligncenter" title="php wizard" src="http://voidandany.free.fr/wp-content/uploads/Sélection_0083-300x119.png" alt="" width="300" height="119" /></a></p>
<p>Cliquer sur Créer</p>
<p>Le rôle php est ajouté à notre serveur :</p>
<p style="text-align: center;"><a href="http://voidandany.free.fr/wp-content/uploads/Sélection_0093.png"><img class="size-medium wp-image-3021 aligncenter" title="Sélection_009" src="http://voidandany.free.fr/wp-content/uploads/Sélection_0093-200x300.png" alt="" width="200" height="300" /></a></p>
<p><br class="spacer_" /></p>
<p>Cliquer sur Sauvegarder (dans le bandeau haut) puis sur &laquo;&nbsp;redémarrage gracieux&nbsp;&raquo; dans la boite de dialogue qui apparait.</p>
<p><br class="spacer_" /></p>
<h3>Test de php</h3>
<p>Pour tester php, il suffit de copier le code suivant dans un fichier portant l&#8217;extension php (par exemple info.php) et placé dans /var/www (racine du site web)</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span>
   <span style="color: #b1b100;">echo</span> <span style="color: #990000;">phpinfo</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">?&gt;</span></pre></div></div>

<p><br class="spacer_" /></p>
<p>Puis ensuite d&#8217;aller à l&#8217;url :</p>
<p>http://ip_serveur/info.php</p>
<p><br class="spacer_" /></p>
<p>Une page comme celle-ci doit apparaitre :</p>
<p style="text-align: center;"><a href="http://voidandany.free.fr/wp-content/uploads/Sélection_0102.png"><img class="size-medium wp-image-3022 aligncenter" title="phpinfo" src="http://voidandany.free.fr/wp-content/uploads/Sélection_0102-214x300.png" alt="" width="214" height="300" /></a></p>
<h3>Problème rencontré</h3>
<p>Lors de mes premier essai, sur mon serveur (Ubuntu minimal 10.04), le php n&#8217;était pas reconnu par Cherokee, dès que j&#8217;allais sur une page php, mon navigateur me proposait de télécharger le fichier php, comme si l&#8217;ajout du support php à Cherokee n&#8217;était pas configuré.</p>
<p style="text-align: center;"><a href="http://voidandany.free.fr/wp-content/uploads/Sélection_0037.png"><img class="size-medium wp-image-3015 aligncenter" title="Download php" src="http://voidandany.free.fr/wp-content/uploads/Sélection_0037-300x204.png" alt="" width="300" height="204" /></a></p>
<p>J&#8217;ai essayé de nombreuses choses sans succès à tel point que j&#8217;ai renoncé à Cherokee pour Apache et au moment de rédiger cet article j&#8217;ai ré-essayé Cherokee et là miracle ca marche.</p>
<p>Je me suis dit que ça venait du fait que j&#8217;avais installé Apache et d&#8217;autres modules php (php5 et libapache2-mod-php5 au lieu de php5-cgi) j&#8217;ai donc refait une installation de zéro de Cherokee sur une machine virtuelle et là aussi ça marche&#8230;..</p>
<p><br class="spacer_" /></p>
<p><span style="text-decoration: underline;"><em><strong>Sources : </strong></em></span></p>
<p><a href="http://www.webdevonlinux.fr/2009/08/ubuntu-installation-de-cherokee-serveur-web-simple-et-performant/">Ubuntu – Installation de Cherokee : Serveur Web simple et Performant</a></p>
<p><a title="Installing Cherokee With PHP5 And MySQL Support On Ubuntu 10.04" href="http://www.howtoforge.com/installing-cherokee-with-php5-and-mysql-support-on-ubuntu-10.04">Installing Cherokee With PHP5 And MySQL Support On Ubuntu 10.04</a></p>
<p><a title="Installation et configuration de Cherokee sous Ubuntu" href="http://blog.nicolargo.com/2010/03/installation-et-configuration-de-cherokee-sous-ubuntu.html">Installation et configuration de Cherokee sous Ubuntu</a></p>
]]></content:encoded>
			<wfw:commentRss>http://voidandany.free.fr/index.php/installation-dun-serveur-web-avec-cherokee/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>
