Install Nginx and php-fpm in Slackware 14.1 via Slackbuilds method

Nginx (pronounced “engine-x”) is an open source reverse proxy server for HTTP, HTTPS, SMTP, POP3, and IMAP protocols, as well as a load balancer, HTTP cache, and a web server (origin server). The nginx project started with a strong focus on high concurrency, high performance and low memory usage. It is licensed under the 2-clause BSD-like license and it runs on Linux, BSD variants, Mac OS X, Solaris, AIX, HP-UX, as well as on other *nix flavors. It also has a proof of concept port for Microsoft Windows.

Info about the system:

root@slackwar14:~# cat   /etc/slackware-version
 Slackware 14.1
root@slackwar14:~# uname   -a
 Linux slackwar14 3.10.17-smp #2 SMP Wed Oct 23 17:13:14 CDT 2013 i686 Intel(R) Core(TM) i7-3740QM CPU @ 2.70GHz GenuineIntel GNU/Linux

Dowload nginx Slackbuild:

root@slackwar14:~# wget  http://slackbuilds.org/slackbuilds/14.1/network/nginx.tar.gz
 --2014-07-04 11:50:27--  http://slackbuilds.org/slackbuilds/14.1/network/nginx.tar.gz
 Resolving slackbuilds.org (slackbuilds.org)... 208.94.238.115
 Connecting to slackbuilds.org (slackbuilds.org)|208.94.238.115|:80... connected.
 HTTP request sent, awaiting response... 200 OK
 Length: 4660 (4.6K) [application/x-gzip]
 Saving to: 'nginx.tar.gz'
 100%[===================================================================================================================================================================================================>] 4,660       --.-K/s   in 0s
 2014-07-04 11:50:27 (618 MB/s) - 'nginx.tar.gz' saved [4660/4660]

Extract with:

tar -zxvf nginx.tar.gz

Download Lastest nginx tarball inside the  nginx folder

cd nginx
root@slackwar14:~# wget http://nginx.org/download/nginx-1.7.2.tar.gz
 --2014-07-04 11:53:32--  http://nginx.org/download/nginx-1.7.2.tar.gz
 Resolving nginx.org (nginx.org)... 206.251.255.63
 Connecting to nginx.org (nginx.org)|206.251.255.63|:80... connected.
 HTTP request sent, awaiting response... 200 OK
 Length: 814079 (795K) [application/octet-stream]
 Saving to: 'nginx-1.7.2.tar.gz'
100%[===================================================================================================================================================================================================>] 814,079      193KB/s   in 4.4s
2014-07-04 11:53:36 (182 KB/s) - 'nginx-1.7.2.tar.gz' saved [814079/814079]

 The Output is like this:

root@slackwar14:~/nginx# ls -altr
total 836
-rw-r--r-- 1 1016 users    762 Nov 26  2013 slack-desc
-rw-r--r-- 1 1016 users   1684 Nov 26  2013 rc.nginx
-rw-r--r-- 1 1016 users    178 Nov 26  2013 nginx.logrotate
-rw-r--r-- 1 1016 users    931 Apr 14 13:49 doinst.sh
-rw-r--r-- 1 1016 users    833 Apr 14 13:49 README
-rw-r--r-- 1 1016 users    267 Apr 27 19:23 nginx.info
-rwxr-xr-x 1 1016 users   5683 May 20 18:58 nginx.SlackBuild*
-rw-r--r-- 1 root root  814079 Jun 17 15:35 nginx-1.7.2.tar.gz
drwx--x--- 3 root root    4096 Jul  4 11:57 ../
drwxr-xr-x 2 1016 users   4096 Jul  4 11:57 ./

Edit nginx.SlackBuild: 

PRGNAM=nginx
VERSION=${VERSION:-1.6.0}
BUILD=${BUILD:-2}
TAG=${TAG:-_SBo}

to
PRGNAM=nginx
VERSION=${VERSION:-1.7.2}
BUILD=${BUILD:-2}
TAG=${TAG:-_SBo}

Now you are ready to build the Nginx with this command:

 root@slackwar14:~/nginx# ./nginx.SlackBuild
...............................
............................
...................................
usr/lib/perl5/vendor_perl/
usr/lib/perl5/vendor_perl/nginx.pm
usr/lib/perl5/vendor_perl/auto/
usr/lib/perl5/vendor_perl/auto/nginx/
usr/lib/perl5/vendor_perl/auto/nginx/nginx.so
usr/doc/
usr/doc/nginx-1.7.2/
usr/doc/nginx-1.7.2/README
usr/doc/nginx-1.7.2/CHANGES.ru
usr/doc/nginx-1.7.2/CHANGES
usr/doc/nginx-1.7.2/LICENSE
usr/doc/nginx-1.7.2/nginx.SlackBuild

Slackware package /tmp/nginx-1.7.2-i486-2_SBo.tgz created.

Install the package generated under /tmp directory:

 root@slackwar14:~/nginx# installpkg   /tmp/nginx-1.7.2-i486-2_SBo.tgz
Verifying package nginx-1.7.2-i486-2_SBo.tgz.
Installing package nginx-1.7.2-i486-2_SBo.tgz:
PACKAGE DESCRIPTION:
# nginx (http/imap/pop3 proxy)
#
# Nginx [engine x] is a high-performance HTTP server and reverse proxy,
# as well as an IMAP/POP3 proxy server.
#
# Nginx was written by Igor Sysoev.
#
# Homepage: http://nginx.net/
#
Executing install script for nginx-1.7.2-i486-2_SBo.tgz.
Package nginx-1.7.2-i486-2_SBo.tgz installed.

root@slackwar14:~/nginx#

Configure Nginx

Remove or disable Apache if existing:

Enable nginx and php-fm to start on boot:

chmod +x /etc/rc.d/rc.php-fpm
chmod +x /etc/rc.d/rc.nginx

Edit the Root Web directory (default is /var/www/html) in my case changed  html to unixmen.

Configure PHP

vi /etc/nginx/nginx.conf

and

        location / {
            root   /var/www/unixmen;
            index  index.php index.html index.htm;
        }

        #error_page  404              /404.html;

        # redirect server error pages to the static page /50x.html
        #
        error_page   500 502 503 504  /50x.html;
        location = /50x.html {
            root   /var/www/unixmen;
        }

        # proxy the PHP scripts to Apache listening on 127.0.0.1:80
        #
        #location ~ \.php$ {
        #    proxy_pass   http://127.0.0.1;
        #}

        # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
        #

        location ~ .php$ {
        root /var/www/unixmen;
        fastcgi_split_path_info ^(.+\.php)(.*)$;
        fastcgi_pass   127.0.0.1:9000;
        fastcgi_index  index.php;
        fastcgi_param  SCRIPT_FILENAME  /var/www/unixmen$fastcgi_script_name;
        include fastcgi_params;
    }
}



save and exit.

Make Index.html on /var/www/unixmen.

cp /var/www/jtml/index /var/www/unixmen

Make phpinfo page:

vi /var/www/unixmen/info.php

and, add:

<?php
phpinfo();
?>

save and exit.

Restart The Deamons:

root@slackwar14:/etc/nginx# /etc/rc.d/rc.php-fpm restart
root@slackwar14:/etc/nginx# /etc/rc.d/rc.nginx restart

Now check the http page and php test page:

http://ip/info.php

slckwarenginx

php-slackware

Done.