When you finally need to install PHP5 on nginx.
August 23rd, 2008 by admin | Filed under django, nginx, php-fcgi, ubuntu.Unfortunately, I’m not large enough to delegate my IT tasks to a team. This leaves me playing server administrator as well as developer. Everything I’ve deployed in the last year or so has been Django-FCGI based so I managed to fall out of touch with setting up a production PHP environment. I finally needed a PHP application, so I decided to do some research. I’ve been using nginx religiously for sometime now and it turned out I couldn’t just do the typical `mod_php5, AddHandler` etcetc that you can do with Apache 2. There was tons of misinformation being spread around and plenty of bad guides.
For my own archival purposes and perhaps your curiosity, this is my optimal server configuration for my image host site.
1) aot-get install mysql-server
2) apt-get install nginx (Alternatively, you can install from source.)
3) apt-get install subversion
4) apt-get install python-mysqldb
5) Install django:
python -c “from distutils.sysconfig import get_python_lib; print get_python_lib()”
svn co http://code.djangoproject.com/svn/django/trunk/ django-trunk
ln -s /home/andrew/django-trunk/django /usr/lib/python2.5/site-packages/django
ln -s /home/andrew/django-trunk/django/bin/django-admin.py /usr/local/bin
6) apt-get install python-imaging
7) apt-get install make gcc autoconf automake
The more difficult part is getting php installed with a fastcgi initiator. This was the best guide I ultimately managed to find. It fit my purposes because it compiled lighttpd, but didn’t make install it (which would have subsequently cluttered up my /usr/bin and /etc/init.d/, and more importantly raced with nginx to see which would first bind to :80).
If you have to install fcgi-php5 on Ubuntu with nginx, I highly suggest setting it first up in a test VMware environment a few times before actually installing on your prod server. (This is a good rule of thumb anyways, but sometimes configurations are so simple you don’t need to have a testbed. This is not the case in my experience).
