Ningx is a great web server, working with static content, it is a great option to serve .css .js and .html files.

If you need to run scripts, like php or perl, you can always send those requirements to Apache, and make Nginx work as a reverse proxy server.

Why Slackware Linux?. Because it is small, stable and fast, I like to have Nginx running on a small VPS alone, and sending script requirement to an Apache server behind, running in another VPS.

If you do not like Slackware, you may also use this guide, but install nginx using your distribution package manager, or also compiling from sources, as I am going to do here.


This article will cover:

  • Installing Nginx on Slackware Linux in a VPS server
  • Configure Nginx as reverse proxy for Apache Server

Installing Nginx

* Slackware specific *

If you plan to use Slackware on a VPS, you first need to find a VPS provider that offers Slackware as an option.

I have found Linode (Please follow the link, and help me pay the hosting bill.)

Once you have your Slackware Linux running on the VPS, you will to install the necessary tools to be able to compile Nginx from sources.

Install development tools for Slackware, Now you can download Nginx and proceed.

If you are not on slackware, this may help.

I am going to install Nginx with the gzip-static module option, so I will need zlib

 slackpkg install zlib

slackpkg is a slackware package manager, you may try any of this methods to install software on Slackware

Relevant to any distribution and / or hosting

Download the latest stable version of Nginx and save it to your server, /usr/src/ could be a good place and the one I will be using.

Uncompress the tarbal.

 sudo tar xvzf nginx[version].tar.gz

Enter the directory of Nginx

 cd nginx[version]

Finally configure and install it on your system

./configure --prefix=/usr /
--pid-path=/var/run/ \
--conf-path=/etc/nginx/nginx.conf --sbin-path=/usr/local/sbin \
--with-http_ssl_module \
--http-log-path=/var/log/nginx/access.log --error-log-path=/var/log/nginx/error.log \
sudo make
sudo make install

Configuring Nginx

Now that Nginx is installed, we will configure it to serve static content, and pass the PHP to an Apache server.

   worker_processes  4; # Default 1

        events {
            worker_connections  512; # Default 1024

        http {
                include       mime.types;
                default_type  application/octet-stream;

                keepalive_timeout  65;

                ## Compression
                gzip              on;
                gzip_buffers      16 8k;
                gzip_comp_level   9;
                gzip_http_version 1.1;
                gzip_min_length   10;
                gzip_types        text/plain text/css application/x-javascript text/xml;
                gzip_vary         on;
                gzip_static       on; #Needs compilation with gzip_static support
                gzip_proxied      any;
                gzip_disable      "MSIE [1-6]\.";

        ## Server configuration 
                server {
                        listen       80;
                        access_log      logs/access.log;
                        client_body_buffer_size 1m;
                        proxy_buffering on;
                        proxy_buffer_size 4k;
                        proxy_buffers 8 32k;

        ## proxy the PHP scripts to Apache listening on
            location ~ \.php$ {
               proxy_pass   http://[Apache IP]:8080;

Now Nginx is configured, now you need to configure the Apache and PHP on the other server. Be sure to configure Apache to listen to 8080.

You may want to read this