Whether you want to run OwnCloud, Baikal or WordPress on the Banana Pi - you will need a web server, MySQL and PHP. I have decided to use Nginx as web server, since it is very resource-friendly compared to Apache. And it is also known for its performance and stability.

This combination is known as LEMP: L inux + nginx(pronounced "engine x") + MySQL + PHP.

1. install Nginx

 apt-get install nginx 

Now start the server with

/etc/init.d/nginx start

and test whether it works. To test enter the address of the Banana Pi in the browser and if everything went right, you should see the following screen:

Startbild Nginx

2. install MySQL

 apt-get install mysql-server 

During installation you will be prompted to set the password for the MySQL user "root". It is recommended to do that.

3. install PHP

To get PHP running under Nginx, PHP-FPM needs to be installed, an alternative FastCGI implementation (FPM = FastCGI Process Manager).
PHP-FPM starts a FastCGI server on the socket /var/run/php5-fpm.sock.

 apt-get install php5-fpm 

To make PHP working with MySQL, the package

 apt-get install php5-mysql 

must be installed

To speed up PHP, it is recommended to set up a cache, where already compiled PHP pages are stored and made available when required. For this the package

 apt-get install php-apc 

is installed.

To make PHP pages running with Nginx, a few settings need to be adjusted.

4. configure Nginx
For this, the file /etc/nginx/sites-available/default needs to be be adjusted.
The use of PHP is already prepared there and the corresponding lines only need to be commented out.

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

.....

	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:
		try_files $uri $uri/ /index.php?$uri&$args;
		fastcgi_pass unix:/var/run/php5-fpm.sock;
		fastcgi_index index.php;
		include fastcgi_params;
	}

In the PHP-block the line try_files $uri $uri/ /index.php?q=$uri&$args; should be added.
And since PHP-FPM is installed, make sure that the line fastcgi_pass 127.0.0.1:9000; is commented out.

And as last thing, as it is recommended in "NOTE", set the "cgi.fix_pathinfo" parameter to 0 in the php.ini file.

nano /etc/php5/fpm/php.ini

....

; cgi.fix_pathinfo provides *real* PATH_INFO/PATH_TRANSLATED support for CGI.  PHP's
; previous behaviour was to set PATH_TRANSLATED to SCRIPT_FILENAME, and to not grok
; what PATH_INFO is.  For more information on PATH_INFO, see the cgi specs.  Setting
; this to 1 will cause PHP CGI to fix its paths to conform to the spec.  A setting
; of zero causes PHP to behave as before.  Default is 1.  You should fix your scripts
; to use SCRIPT_FILENAME rather than PATH_TRANSLATED.
; http://php.net/cgi.fix-pathinfo
cgi.fix_pathinfo=0

To make NginX work with the new settings it needs to be restartet with

/etc/init.d/nginx restart 

( Thanks to Jos Poortvliet for pointing this out )

If you want to test whether PHP is running correctly, you can create a file in the document root of Nginx that provides all information about the PHP configuration when called.

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

The contents of the file is.

<?php
phpinfo();
?>

If you call this file with the browser, the following output should appear:
Ausgabe phpinfo

Add comment

Please insert your mail adress. Your mail address will not be displayed.