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.


  • Incognito Psytrancer

    Super - puper!

  • Incognito Psytrancer

    Thank You! It's better than lighttpd. Tell me, do you plan to write a manual installation mysql + phpmyadmin on the router under Debian? Or it does not differ from the standard procedure to install on any Debian?

    • Use any tutorial related to debian, you only need to add services name from /opt/debian/etc/init.d/* to /opt/etc/chroot-services-list to start with S99debian script


To be notified by email when a new tutorial is posted :)

Thanks for Subscribing! I'll keeping you up-to-date with latest tutorials!

Something went wrong, try again...