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 127.0.0.1:9000 # location ~ \.php$ { fastcgi_split_path_info ^(.+\.php)(/.+)$; # # NOTE: You should have "cgi.fix_pathinfo = 0;" in php.ini # # # With php5-cgi alone: #fastcgi_pass 127.0.0.1:9000; # # 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,
<?PHP phpinfo(); ?>
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).
P.S.
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”