Web Apps with Cherokee and PHP-FastCGI on Ubuntu 10.04 LTS (Lucid)

Select distribution:
Traducciones al Español
Estamos traduciendo nuestros guías y tutoriales al Español. Es posible que usted esté viendo una traducción generada automáticamente. Estamos trabajando con traductores profesionales para verificar las traducciones de nuestro sitio web. Este proyecto es un trabajo en curso.
Deprecated

This guide has been deprecated and is no longer being maintained.

Cherokee is a fast, flexible web server for POSIX compliant operating systems such as Linux. It’s designed to be easy to administer, and includes support for a wide range of common web server functions.

This tutorial explains how to configure Cherokee to serve dynamic content with PHP via FastCGI on Ubuntu 10.04 LTS (Lucid). Please make sure you are logged into your Linode as root via SSH.

This document assumes that you already have a working and up to date Ubuntu 10.04 system. If you have not followed our Setting Up and Securing a Compute Instance guide, it is recommended that you do so prior to following these instructions.

Prerequisites

Make sure your repositories and packages are up to date by issuing the following commands:

apt-get update
apt-get upgrade

If you haven’t already installed Cherokee, please follow our Ubuntu 10.04 Cherokee installation guide before continuing with these instructions.

Install Required Packages

Issue the following commands to install support for PHP and FastCGI:

apt-get install php5-cli php5-cgi spawn-fcgi

Issue the following sequence of commands to create scripts to control spawn-fcgi and the PHP-FastCGI process, set the permissions for these scripts, ensure that PHP-FastCGI starts as part of the boot process, and start PHP-FastCGI For the first time:

cd /opt/
wget -O php-fastcgi-deb.sh http://www.linode.com/docs/assets/579-pp-php-fastcgi-deb.sh
wget -O php-fastcgi-init-deb.sh http://www.linode.com/docs/assets/580-php-fastcgi-init-deb.sh
mv /opt/php-fastcgi-deb.sh /usr/bin/php-fastcgi
mv /opt/php-fastcgi-init-deb.sh /etc/init.d/php-fastcgi
chmod 755 /usr/bin/php-fastcgi
chmod 755 /etc/init.d/php-fastcgi
update-rc.d php-fastcgi defaults
/etc/init.d/php-fastcgi start

Configure Your Site

Create directories for your site by issuing the following commands. Substitute your domain name for “mydomain.com” in these commands.

mkdir -p /srv/www/mydomain.com/www/public_html
mkdir /srv/www/mydomain.com/www/logs
chown -R www-data:www-data /srv/www/mydomain.com

If you haven’t already done so, start the Cherokee administration program by issuing the following command. Alternately, you may wish to follow our instructions for secure Cherokee admin access.

cherokee-admin -b &

Navigate to the “General” page in the admin interface. You may wish to enable SSL support, change the server tokens, or enable graphs.

General settings in Cherokee admin panel on Ubuntu 10.04 LTS

Click the “Add New Virtual Server” button on the “Virtual Servers” page.

Assign a nickname for your new virtual server and specify its document root:

Click on your new virtual server’s nickname in the server list. Specify which files you would like to consider directory indexes on the “Basic” tab.

Configuring directory indexes in Cherokee admin panel on Ubuntu 10.04 LTS

On the “Host Match” tab, enter your base domain name and the domain prefixed by “www”:

Configuring host matching in Cherokee admin panel on Ubuntu 10.04 LTS

On the “Behavior” tab, remove all rules except for the “Default” rule:

On the “Logging” tab, specify the location of your access and error logs:

Logging configuration in Cherokee admin panel on Ubuntu 10.04 LTS

Navigate to the “Information Source” page. Specify a new information source with the following settings:

Navigate back to the “Virtual Servers” page. Create an extensions rule for PHP files on the “Behavior” tab of your virtual server’s configuration page.

On the “Handler” tab, specify the following settings for PHP-FastCGI:

PHP-FastCGI handler settings in Cherokee admin panel on Ubuntu 10.04 LTS

On the “Encoding” tab, enable gzip/deflate compression:

PHP-FastCGI gzip/deflate compression settings in Cherokee admin panel on Ubuntu 10.04 LTS

Test Your Configuration

Restart Cherokee by clicking the “Save” button under the left page navigation list. Once Cherokee has restarted, create a test PHP script as follows:

File: /srv/www/mydomain.com/www/public\\_html/test.php
1
<?php phpinfo(); ?>

Visit “/test.php” on your site to verify PHP-FastCGI is operating correctly. You should see the standard phpinfo() page. Congratulations, you’ve successfully configured PHP-FastCGI for dynamic content using the Cherokee web server!

More Information

You may wish to consult the following resources for additional information on this topic. While these are provided in the hope that they will be useful, please note that we cannot vouch for the accuracy or timeliness of externally hosted materials.

This page was originally published on


Your Feedback Is Important

Let us know if this guide was helpful to you.


Join the conversation.
Read other comments or post your own below. Comments must be respectful, constructive, and relevant to the topic of the guide. Do not post external links or advertisements. Before posting, consider if your comment would be better addressed by contacting our Support team or asking on our Community Site.
The Disqus commenting system for Linode Docs requires the acceptance of Functional Cookies, which allow us to analyze site usage so we can measure and improve performance. To view and create comments for this article, please update your Cookie Preferences on this website and refresh this web page. Please note: You must have JavaScript enabled in your browser.