Nginx Web Server with PHP Support through Debian

1a - For Arm devices setup Debian from here

1b - For Mipsel devices setup Debian from here

2 - Enter Chrooted Debian

debian enter

3 - Update Debian

apt-get update
apt-get upgrade

4 - Install necessary packages

apt-get install bzip2 nginx php5 php5-fpm

- Replace default configuration file

rm /etc/nginx/sites-available/default
nano /etc/nginx/sites-available/default

Paste this lines

 server {
        listen 82; ## listen for ipv4; this line is default and implied
        listen [::]:82 default_server ipv6only=on; ## listen for ipv6

        root /usr/share/nginx/html;
        index index.html index.htm;

        # Make site accessible from http://localhost/
        server_name localhost;
        # pass the PHP scripts to FastCGI server listening on /var/run/php5-fpm.sock
        location ~ .php$ {
        try_files $uri =404;
        fastcgi_pass unix:/var/run/php5-fpm.sock;
        fastcgi_index index.php;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        include fastcgi_params;

        location /doc/ {
        alias /usr/share/doc/;
        autoindex on;
        allow ::1;
        deny all;

Save with CTRL-O, press ENTER and exit nano with CTRL-X

6 - Reduce memory limit

sed -i 's/memory_limit = 128M/memory_limit = 16M/g' "/etc/php5/fpm/php.ini"

7 - Restart server

service php5-fpm restart
service nginx restart

8 - Go to and if you see this page, the nginx web server is configured correctly



9 - Create php info page

nano /usr/share/nginx/html/info.php

Paste this lines


Save with CTRL-O, press ENTER and exit nano with CTRL-X
10 - Go to and if you see this page, php is configured correctly

11 - To create startup script we need to exit debian


12- Add nginx to chrooted services list

echo "nginx" >>/opt/etc/chroot-services.list
echo "php5-fpm" >>/opt/etc/chroot-services.list

13 - Start nginx from outside debian together with mounted external folder

debian restart


nano /jffs/scripts/firewall-start

Paste this lines

iptables -I INPUT -p tcp --destination-port 82 -j ACCEPT

Save with CTRL-O / Enter / and exit with CTRL-X
Make script executable and apply rule
chmod a+rx /jffs/scripts/firewall-start
sh /jffs/scripts/firewall-start

Go to Port Forwarding page and redirect port 80 to 82, now you should have access from wan.