RubyPDF Blog tutorial GNURoot in Action–A Real Web Server On Android

GNURoot in Action–A Real Web Server On Android

In this tutorial, I will show you how to install nginx and enable PHP on nginx.

Install php5-fpm and nginx

apt-get install php5-fpm php5-cli php5-mysql
apt-get install nginx

edit configure(/etc/nginx/sites-available/default)

change listen port to 8080(or any number >1024)

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

add index.php to index

index index.php index.html index.htm;

uncomment some lines to enable PHP on nginx

# pass the PHP scripts to FastCGI server listening on
location ~ \.php$ {
fastcgi_split_path_info ^(.+\.php)(/.+)$;
# # NOTE: You should have "cgi.fix_pathinfo = 0;" in php.ini
# # With php5-cgi alone:
# # With php5-fpm:
fastcgi_pass unix:/var/run/php5-fpm.sock;
fastcgi_index index.php;
include fastcgi_params;

start service,

service php5-fpm restart 
service nginx restart

then visit http://localhost:8080 on your phone, or http://ip-of-your-android:8080

and by default, the root is,

 root /usr/share/nginx/www;

you can change it in your configure.


Let’s create a PHP example, /usr/share/nginx/www/info.php with the content,


then visit http://localhost:8080/info.php

Feel free to have a look the output from my phone,info.php.pdf( created with wkhtmltopdf 0.12.1 on gnuroot).


I tried Apache before nginx, when restart apache, I always got this error,

STDOUT: * Starting web server apache2
/var/lock/apache2 already exists but is not a directory owned by www-data.
Please fix manually. Aborting.

I tried to

chown www-data:www-data /var/lock/apache2

but does not work.


nginx [engine x] is an HTTP and reverse proxy server, a mail proxy server, and a generic TCP proxy server, originally written by Igor Sysoev.

1 thought on “GNURoot in Action–A Real Web Server On Android”

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.