<?xml version="1.0" encoding="utf-8"?><?xml-stylesheet title="XSL formatting" type="text/xsl" href="http://blog.chty.org/feed/rss2/xslt" ?><rss version="2.0"
  xmlns:dc="http://purl.org/dc/elements/1.1/"
  xmlns:wfw="http://wellformedweb.org/CommentAPI/"
  xmlns:content="http://purl.org/rss/1.0/modules/content/"
  xmlns:atom="http://www.w3.org/2005/Atom">
<channel>
  <title>Chty blog - Tag - php</title>
  <link>http://blog.chty.org/</link>
  <atom:link href="http://blog.chty.org/feed/tag/php/rss2" rel="self" type="application/rss+xml"/>
  <description>A little somewhere else...</description>
  <language>en</language>
  <pubDate>Wed, 27 Aug 2008 12:28:11 +0200</pubDate>
  <copyright>Creative Commons</copyright>
  <docs>http://blogs.law.harvard.edu/tech/rss</docs>
  <generator>Dotclear</generator>
  
    
  <item>
    <title>Apache2 + mod_fastcgi + suexec on debian etch</title>
    <link>http://blog.chty.org/post/2007/10/28/Apache2-mod_fastcgi-suexec-on-debian-etch</link>
    <guid isPermaLink="false">urn:md5:451a38a518ef53081658f9bd988cf77e</guid>
    <pubDate>Mon, 29 Oct 2007 14:49:00 +0100</pubDate>
    <dc:creator>Chty</dc:creator>
        <category>Apache2</category><category>debian</category><category>fastcgi</category><category>howto</category><category>php</category><category>suexec</category>    
    <description>&lt;p&gt;I know it's difficult to find good documentation to configure &lt;a href=&quot;http://blog.chty.org/tag/Apache2&quot;&gt;apache2&lt;/a&gt; with &lt;a hreflang=&quot;en&quot; href=&quot;http://fastcgi.com&quot;&gt;mod_fastcgi&lt;/a&gt; and &lt;a hreflang=&quot;en&quot; href=&quot;http://httpd.apache.org&quot;&gt;suexec&lt;/a&gt; to make php websites works. This
configuration works well with Debian Etch (4.0).&lt;br /&gt;Here an example of configuration.&lt;/p&gt;    The following suppose that your web data are in /var/www/ (there are good reason for this as we'll see later).&lt;br /&gt;/var/www/toto/: the web account of toto&lt;br /&gt;/var/www/toto/web/: the web dir of the toto's account&lt;br /&gt;/var/www/toto/conf/php.ini: you own php.ini file&lt;br /&gt;/var/www/toto/cgi-bin/php.fcgi: the fcgi file which allow to run &lt;a hreflang=&quot;en&quot; href=&quot;http://php.net/&quot;&gt;php5-cgi&lt;/a&gt; with a specific php.ini file for each virtual host&lt;br /&gt;&lt;br /&gt;First of all don't forget that mod_fastcgi and mod_fcgid are different. Difference between &lt;a title=&quot;mod_fastcgi&quot; href=&quot;http://fastcgi.com/&quot;&gt;mod_fastcgi&lt;/a&gt; and &lt;a title=&quot;mod_fcgid&quot; href=&quot;http://fastcgi.coremail.cn/&quot;&gt;mod_fcgid&lt;/a&gt; is mostly at license level, since some might consider mod_fastcgi not to be totally free.&lt;br /&gt;&lt;br /&gt;Enable fastcgi and suexec:&lt;br /&gt;&lt;code&gt;#a2enmod fastcgi&lt;br /&gt;#a2enmod suexec&lt;/code&gt;&lt;br /&gt;&lt;br /&gt;Suexec has no configuration file, because every parameter is hardcoded. Therefore, if you need to configure suexec, do it at apache2 compile time.&lt;br /&gt;Let's see how...&lt;br /&gt;&lt;br /&gt;&lt;code&gt;#/usr/lib/apache2/suexec -V &lt;br /&gt;&amp;nbsp;-D AP_DOC_ROOT=&quot;/var/www&quot;&lt;br /&gt;&amp;nbsp;-D AP_GID_MIN=100&lt;br /&gt;&amp;nbsp;-D AP_HTTPD_USER=&quot;www-data&quot;&lt;br /&gt;&amp;nbsp;-D AP_LOG_EXEC=&quot;/var/log/apache2/suexec.log&quot;&lt;br /&gt;&amp;nbsp;-D AP_SAFE_PATH=&quot;/usr/local/bin:/usr/bin:/bin&quot;&lt;br /&gt;&amp;nbsp;-D AP_UID_MIN=100&lt;br /&gt;&amp;nbsp;-D AP_USERDIR_SUFFIX=&quot;public_html&quot;&lt;/code&gt;&lt;br /&gt;&lt;br /&gt;AP_DOC_ROOT is set to &quot;/var/www&quot;, which is the reason you would want to put your files in /var/www/. You cannot just ignore this fact; if this directory is inconsistently set, it just won't work. If you want to change this directory, you must recompile apache2 with your own configuration.&lt;br /&gt;&lt;br /&gt;/var/www/toto/cgi-bin/php.fcgi:&lt;br /&gt;&lt;code&gt;#!/bin/sh&lt;br /&gt;PHPRC=&quot;/var/www/toto/conf/&quot;&lt;br /&gt;export PHPRC&lt;br /&gt;PHP_FCGI_CHILDREN=4&lt;br /&gt;export PHP_FCGI_CHILDREN&lt;br /&gt;PHP_FCGI_MAX_REQUESTS=200&lt;br /&gt;export PHP_FCGI_MAX_REQUESTS&lt;br /&gt;exec /usr/bin/php5-cgi&lt;/code&gt;&lt;br /&gt;&lt;br /&gt;fastcgi.conf: (in /etc/apache2/mods-available/ for Debian)&lt;br /&gt;
&lt;code&gt;&amp;lt;IfModule mod_fastcgi.c&amp;gt;&lt;br /&gt;&amp;nbsp;AddHandler fastcgi-script .fcgi&lt;br /&gt;&amp;nbsp;FastCgiWrapper /usr/lib/apache2/suexec&lt;br /&gt;&amp;nbsp;FastCgiIpcDir /var/lib/apache2/fastcgi&lt;br /&gt;&amp;nbsp;FastCgiConfig -singleThreshold 1 -autoUpdate -idle-timeout 240 -pass-header HTTP_AUTHORIZATION&lt;br /&gt;&amp;lt;/IfModule&amp;gt;&lt;br /&gt;&lt;br /&gt;
&lt;/code&gt;
See &lt;a hreflang=&quot;en&quot; href=&quot;http://www.fastcgi.com/&quot;&gt;http://www.fastcgi.com/&lt;/a&gt; if you want to know about all the options possible in fastcgi.conf.&lt;br /&gt;&lt;br /&gt;Let's configure (in /etc/apache2/sites-available/  for debian etch) a virtual host for toto:&lt;code&gt;&lt;br /&gt;
&amp;lt;VirtualHost xxx.xxx.xxx.xxx:80&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ServerAdmin webmaster@toto.org&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ServerName toto.org&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; DocumentRoot /var/www/toto/web/&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; SuexecUserGroup UserName GroupName&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;Directory /&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Options FollowSymLinks&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; AllowOverride None&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/Directory&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;Directory /var/www/toto/web/&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Options -Indexes FollowSymLinks -MultiViews&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; AllowOverride all&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Order allow,deny&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Allow from all&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/Directory&amp;gt;&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ScriptAlias /cgi-bin/ /var/www/toto/cgi-bin/&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;Directory &quot;/var/www/toto/cgi-bin/&quot;&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; AllowOverride None&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Options ExecCGI -MultiViews +SymLinksIfOwnerMatch&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Order allow,deny&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Allow from all&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/Directory&amp;gt;&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; AddHandler php-fastcgi .php&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; AddType application/x-httpd-php .php&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; DirectoryIndex index.html index.php&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Action php-fastcgi /cgi-bin/php.fcgi&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ServerSignature On&lt;br /&gt;&amp;lt;/VirtualHost&amp;gt;&lt;br /&gt;
&lt;/code&gt;&lt;span class=&quot;q&quot; id=&quot;q_115e6f9f561c4168_16&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;div style=&quot;direction: ltr;&quot;&gt;This virtual host can be enabled in /etc/apache2/sites-enabled/ by creating a symbolic link.&lt;br /&gt;Make sure to set appropriate rights for /var/www/toto/ you set in the virtual host (SuexecUserGroup), since &lt;a href=&quot;http://blog.chty.org/tag/php&quot;&gt;php5-cgi&lt;/a&gt; will be executed with these rights.&lt;/div&gt;&lt;br /&gt;restart apache2 :&lt;br /&gt;&lt;code&gt;#/etc/init.d/apache2 restart&lt;/code&gt;&lt;br /&gt;&lt;br /&gt;A maximum of four php5-cgi will be launched when the first visitor will visit the website. They would be killed after a timeout of 240 seconds of inactivity, as set in fastcgi.conf.&lt;br /&gt;It should work.&lt;br /&gt;Please tell me know if you are aware of issue that may arise with such a configuration.&lt;br /&gt;</description>
    
    
    
      </item>
    
</channel>
</rss>