(ve):Install Cherokee LAMP on Ubuntu 9.10
- This page was last modified on November 22, 2010, at 10:44.
From (mt) Community Wiki
Contents |
Definition
LAMP stands for Linux, Apache, MySQL and PHP/Python/Perl systems.
In this case we are going to use Cherokee instead of Apache.
Requirements
- Linux, Ubuntu 9.10.
- Cherokee.
- MySQL.
- PHP5.
Installation
- Log in to your (ve) with root or sudo access:
ssh root@example.comWindows users should use software like PuTTy.
- Make sure your server is up to date:
# apt-get update # apt-get upgrade
Cherokee
- Follow this guide. The process is pretty straightforward.
MySQL
- Install MySQL through repositories:
# apt-get install mysql-server mysql-client
- During installation you'll be prompted for a password. Use a strong one and note it somewhere.
- Now the latest stable version of MySQL will be installed. If you want to check the version:
mysql -V
You'll get something like this:
mysql Ver 14.14 Distrib 5.1.37, for debian-linux-gnu (x86_64) using EditLine wrapper
That's it!
PHP 5
- Install PHP through repositories:
# apt-get install php5-cgi php5-mysql (*)
You can also install additional modules like php5-curl, php5-json, etc.. If you want a complete list of available php modules type:# aptitude search php5
- Check your PHP version:
php-cgi -v
You should see something like this:
PHP 5.2.10-2ubuntu6.4 with Suhosin-Patch 0.9.7 (cgi-fcgi) (built: Jan 6 2010 22:50:54) Copyright (c) 1997-2009 The PHP Group Zend Engine v2.2.0, Copyright (c) 1998-2009 Zend Technologies
- Now, go to your cherokee-admin, click the Virtual Servers tab and create a new virtual server, or use the default one if you haven't set any before. For this example, we'll be using the default one.
- Click the Wizards button, select Languages and run the PHP Wizard. It'll create a new rule like this:
This rule will be applied to all the requested files that have the extension .php (Don't worry about url rewriting.).
- Click on the new rule, then on its Handler tab.
The wizard has created a new information source for us:
- Click on it. We need to edit some values here. By default it will listen to localhost in a random port, usually higher than 45000. You can also use linux sockets; that's up to you.
Note: If you are unable to launch this automatically with the Interpreter line, leave it blank.
- Click the Wizards button, select Languages and run the PHP Wizard. It'll create a new rule like this:
- Now, create a simple phpinfo page in your virtual server's root directory:
nano /var/www/info.php
/var/www/info.php<?php phpinfo(); ?>
- We're not quite done. http://yourdomain.com will give you a "503 Service Unavailable" message because PHP is not handling your request.
So, now we will spawn a FastCGI handler. It's as easy as typing:
spawn-fcgi -u www-data -f /usr/bin/php-cgi -a 127.0.0.1 -p 47990 -P /var/run/spawn-fcgi.pid
- Change the port number 47990 to fit your needs.
- This will launch a single process which will work until you stop/kill it, or your server reboots (from a crash, etc.).
- Now visit http://yourdomain.com in your browser. You'll see the PHP info page displaying nicely and with the FastCGI handler.
- To launch FastCGI automatically on startup, create the following init.d script:
I called the file /etc/init.d/spawn-fcgi-php; the -php can help if you have multiple interpreters (php and python, php and perl, etc.).
- Create this file on your server:
/etc/init.d/spawn-fcgi-php
#! /bin/sh ### BEGIN INIT INFO # Provides: spawn-fcgi-php # Required-Start: $all # Required-Stop: $all # Default-Start: 2 3 4 5 # Default-Stop: 0 1 6 # Short-Description: starts FastCGI for PHP # Description: starts FastCGI for PHP using start-stop-daemon ### END INIT INFO PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin NAME=spawn-fcgi-php PID=/var/run/spawn-fcgi-php.pid DAEMON=/usr/bin/spawn-fcgi DAEMON_OPTS="-f /usr/bin/php-cgi -a 127.0.0.1 -p 47990 -u www-data -P $PID" test -x $DAEMON || exit 0 set -e case "$1" in start) echo "Starting $NAME: " start-stop-daemon --start --pidfile $PID --exec $DAEMON -- $DAEMON_OPTS echo "done." ;; stop) echo "Stopping $NAME: " start-stop-daemon --stop --pidfile $PID --retry 5 rm -f $PID echo "done." ;; restart) echo "Stopping $NAME: " start-stop-daemon --stop --pidfile $PID --retry 5 rm -f $PID echo "done..." sleep 1 echo "Starting $NAME: " start-stop-daemon --start --pidfile $PID --exec $DAEMON -- $DAEMON_OPTS echo "done." ;; *) echo "Usage: /etc/init.d/$NAME {start|stop|restart}" >&2 exit 1 ;; esac exit 0- Copy/paste this text into a plain text file on your local machine, then upload the file via FTP to /var/www, then move it to /etc/init.d/spawn-fcgi-php. Don't forget to add execution permissions to it:
chmod +x /etc/init.d/spawn-fcgi-php
- Be sure to modify line 17, DAEMON_OPTS, with your own address ( -a ) and port ( -p ). The address will be localhost by default. The port is up you.
- Add this init.d script to the boot sequence:
# update-rc.d spawn-fcgi-php defaults
Restart the server or launch the spawner to start working with PHP.
- Create this file on your server:
FastCGI with sockets
- Go to your source information. Change the Connection to your socket path, for example, /tmp/cherokee-source1.sock.
- Now, edit line 17 of your /etc/init.d/spawn-fcgi-php file from:
DAEMON_OPTS="-f /usr/bin/php-cgi -a 127.0.0.1 -p 47990 -u www-data -P $PID"
To:
DAEMON_OPTS="-f /usr/bin/php-cgi -s /path/to/your/socket.socket -u www-data -P $PID"


