<?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>david winter &#187; nginx</title>
	<atom:link href="http://davidwinter.me.uk/articles/tag/nginx/feed/" rel="self" type="application/rss+xml" />
	<link>http://davidwinter.me.uk</link>
	<description>you were expecting someone else?</description>
	<lastBuildDate>Sun, 22 Aug 2010 20:51:42 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<item>
		<title>PHP and nginx on Ubuntu: the easy way</title>
		<link>http://davidwinter.me.uk/articles/2009/06/13/php-and-nginx-the-easy-way/</link>
		<comments>http://davidwinter.me.uk/articles/2009/06/13/php-and-nginx-the-easy-way/#comments</comments>
		<pubDate>Sat, 13 Jun 2009 19:31:08 +0000</pubDate>
		<dc:creator>David</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[howto]]></category>
		<category><![CDATA[nginx]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[ubuntu]]></category>

		<guid isPermaLink="false">http://davidwinter.me.uk/?p=139</guid>
		<description><![CDATA[I&#8217;ve now changed my slice from running lighttpd to nginx. Here&#8217;s the simplest way, in around 6 commands, to get PHP up and running via FastCGI. Install and setup Install PHP 5: sudo aptitude install php5-cgi Install nginx: sudo aptitude install nginx Create PHP 5 FastCGI start-up script: sudo nano /etc/init.d/php-fastcgi Inside, put: #!/bin/bash BIND=127.0.0.1:9000 [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve now changed my slice from running lighttpd to nginx. Here&#8217;s the simplest way, in around 6 commands, to get PHP up and running via FastCGI.</p>

<h2>Install and setup</h2>

<p>Install PHP 5:</p>

<pre><code>sudo aptitude install php5-cgi
</code></pre>

<p>Install nginx:</p>

<pre><code>sudo aptitude install nginx
</code></pre>

<p>Create PHP 5 FastCGI start-up script:</p>

<pre><code>sudo nano /etc/init.d/php-fastcgi
</code></pre>

<p>Inside, put:</p>

<pre><code>#!/bin/bash
BIND=127.0.0.1:9000
USER=www-data
PHP_FCGI_CHILDREN=15
PHP_FCGI_MAX_REQUESTS=1000

PHP_CGI=/usr/bin/php-cgi
PHP_CGI_NAME=`basename $PHP_CGI`
PHP_CGI_ARGS="- USER=$USER PATH=/usr/bin PHP_FCGI_CHILDREN=$PHP_FCGI_CHILDREN PHP_FCGI_MAX_REQUESTS=$PHP_FCGI_MAX_REQUESTS $PHP_CGI -b $BIND"
RETVAL=0

start() {
      echo -n "Starting PHP FastCGI: "
      start-stop-daemon --quiet --start --background --chuid "$USER" --exec /usr/bin/env -- $PHP_CGI_ARGS
      RETVAL=$?
      echo "$PHP_CGI_NAME."
}
stop() {
      echo -n "Stopping PHP FastCGI: "
      killall -q -w -u $USER $PHP_CGI
      RETVAL=$?
      echo "$PHP_CGI_NAME."
}

case "$1" in
    start)
      start
  ;;
    stop)
      stop
  ;;
    restart)
      stop
      start
  ;;
    *)
      echo "Usage: php-fastcgi {start|stop|restart}"
      exit 1
  ;;
esac
exit $RETVAL
</code></pre>

<p>Make start-up script executable:</p>

<pre><code>sudo chmod +x /etc/init.d/php-fastcgi
</code></pre>

<p>Launch PHP:</p>

<pre><code>sudo /etc/init.d/php-fastcgi start
</code></pre>

<p>Launch at start-up:</p>

<pre><code>sudo update-rc.d php-fastcgi defaults
</code></pre>

<p>That&#8217;s it. All installed and ready to go.</p>

<h2>Test</h2>

<p>In your server config, add the following:</p>

<pre><code>location ~ \.php$ {
    fastcgi_pass    127.0.0.1:9000;
    fastcgi_index   index.php;
    fastcgi_param   SCRIPT_FILENAME /var/www/nginx-default$fastcgi_script_name;
    include         fastcgi_params;
}
</code></pre>

<p>Restart nginx:</p>

<pre><code>sudo /etc/init.d/nginx restart
</code></pre>

<p>Create a file in your web root (in the example above, /var/www/nginx-default/test.php):</p>

<pre><code>&lt;?php

phpinfo();
</code></pre>

<p>Visit the page in your browser and you should see the standard PHP info page. And you&#8217;re done.</p>

<p>Source: <a href="http://tomasz.sterna.tv/2009/04/php-fastcgi-with-nginx-on-ubuntu/">Aberration</a></p>
]]></content:encoded>
			<wfw:commentRss>http://davidwinter.me.uk/articles/2009/06/13/php-and-nginx-the-easy-way/feed/</wfw:commentRss>
		<slash:comments>14</slash:comments>
		</item>
	</channel>
</rss>
