Tuesday, February 5, 2013

Http server with PHP on RaspberryPI

Totally awesome guide is at http://rasberrypibeginnersguide.tumblr.com/post/27283563130/nginx-php5-on-raspberry-pi-debian-wheezy
But instead using provided silex site config file, you should configure root folder of web server to serve php scripts. To do so please rm symlink to silex file and edit

/etc/nginx/sites-available/default

Set root folder to /var/www


#       root /usr/share/nginx/www;
        root /var/www;

Add index.php as a index file

index index.html index.htm index.php;

And configure all php files to be parsed by fastCGI php bridge set up on port 9000. Just put all below somewhere in default file

 ## Parse all .php file in the /var/www directory
            location ~ \.php$ {
                    fastcgi_split_path_info ^(.+\.php)(.*)$;
                    fastcgi_pass   127.0.0.1:9000;
                    fastcgi_index  index.php;
                    fastcgi_param  SCRIPT_FILENAME  /var/www/silex$fastcgi_script_name;
                    include fastcgi_params;
                    fastcgi_param  QUERY_STRING     $query_string;
                    fastcgi_param  REQUEST_METHOD   $request_method;
                    fastcgi_param  CONTENT_TYPE     $content_type;
                    fastcgi_param  CONTENT_LENGTH   $content_length;
                    fastcgi_intercept_errors        on;
                    fastcgi_ignore_client_abort     off;
                    fastcgi_connect_timeout 60;
                    fastcgi_send_timeout 180;
                    fastcgi_read_timeout 180;
                    fastcgi_buffer_size 128k;
                    fastcgi_buffers 4 256k;
                    fastcgi_busy_buffers_size 256k;
                    fastcgi_temp_file_write_size 256k;
            }

Now restart ngix as mentioned in original article and enjoy PHP on RPi!

1 comment: