Using Nginx as a reverse proxy for Apache

We all know that Apache is a great software and it cannot be replaced every time. Also, Apache shown great performance serving dynamic php content whether it’s running mod_php or fastcgi. BoÅ¡tjan Å kufca made an excellent comparison between Apache + mod_php and Nginx + php-fpm.

So, Apache is very good serving dynamic content while nginx is the best on serving static content. But is it possible to have the best from both worlds? Is it possible to use all the apache features (like native .htaccess support) while serving the static content of the website with nginx? Luckily yes.

First of all let’s see the general structure of Apache web server and why it would be a good idea to use a reverse proxy:
1. Client initiates request to the Apache server.
2. His browser connects to the Apache server.
3. The Apache server creates new thread/process to handle the request.
4. If client requested dynamic content, web server spawns CGI process or executes dynamic content handling module (i.e. mod_php) and waits while request will be processed. When it receives resulted web-page, it sends it back to the client.
5. If client asked for some static file, web server sends this file to client
6. Client’s browser receives answer, closes connection to web server and displays content.

Read more

Linux Slackware + Apache2 + PHP + mod_fastcgi

This tutorial assumes that you are already familiar with Slackware Linux and Apache2.

Before you start, make sure you have a working httpd.conf of Apache2 because a detailed configuration is not included in this tutorial. Then, remove the installed packages of Apache2 and PHP using Slackware’s pkgtool.

Go to Apache website and get the latest version of Apache2. In this tutorial I’m using Apache-2.2.9:

cd /usr/local/src
wget http://www.eu.apache.org/dist/httpd/httpd-2.2.9.tar.gz

Go to PHP website and get the latest version of PHP5. In this tutorial I’m using PHP-5.2.6

wget http://www.php.net/get/php-5.2.6.tar.gz/from/de.php.net/mirror

Read more