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
1 2 |
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)
1 2 |
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
1 |
index index.php index.html index.htm; |
uncomment some lines to enable PHP on nginx
1 2 3 4 5 6 7 8 9 10 11 12 13 |
# 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,
1 2 |
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,
1 |
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,
1 2 3 |
<?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,
1 2 3 |
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
1 |
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.
Leave a Reply
You must be logged in to post a comment.