Raspberry Pi – Install Nginx with support Python, Ruby and NodeJS

Most Web servers support PHP, some in most CGI. In this tutorial, We will see how to use Nginx with Python pages, Ruby or NodeJS.

Passenger_chair_256x256

The solution proposed to allow for pages in Ruby,Python and NodeJS is through the tool Phusion Passenger. He also moved to Apache for Nginx. It is to the latter that I chose to install it.

To install your Web server, Here's how :

  1. If you already have Nginx, the Passenger site recommends that you remove. Otherwise, You can install Nginx as explained in this article but in this case you will have two different binaries with different configurations.
    In the event that, Here is the command to uninstall Nginx :

    apt - get remove nginx nginx-full light nginx nginx-naxsi nginx-common
  2. Install Ruby
    apt - get install –y ruby
  3. Install RubyGems 1.8.25
    cd wget http://rubyforge.org/frs/download.php/76729/rubygems-1.8.25.tgz tar zxvf rubygems-1.8.25. tgz cd rubygems-1.8.25 ruby ./setup.rb cd ..
    rm - rf rubygems - 1.8.25

    Execution of the command

    gem - version

    should return you 1.8.25

  4. Install Passenger
    gem install passenger
  5. Run the installation of Passenger and Nginx
    passenger-install-nginx-module
  6. Follow the instructions and install the required packages if necessary. In this case then restart the command from the previous step.
    Passenger will may be complaining about the little memory (at home I have a 256 MB).
    I kept the default installation option in /opt/nginx to not complicate the configuration.
  7. At the end of the compilation, you meet your Nginx server in the directory /opt/nginx. In the sub directory conf, You can add a block server to manage your site. For example the application Tracks from this article, just add a block :
    server {
       listen 8000;
       root/var/www/tracks/public;
       passenger_enabled on;
    }

    You must point to the public directory and the root (Here/var/www/tracks)

  8. Remember to look at the logs in/opt/nginx/log or those of the application if something goes wrong. It is a mine of information that in 99% the case will help you solve problems.

You now have a Web server capable of supporting other languages as HTML. Nothing then prevents adding PHP with php5-fpm or CGI with fastcgi support.

You may also like...

  • sfeuga

    Hello
    Thanks for these useful super tutorials !

    I have a small question, I try to add (from what you to written here : http://www.pihomeserver.fr/2013/09/27/raspberry-pi-home-server-installer-serveur-lesp/) php support + passenger, but it don't have the area to function properly.
    I have no error when testing my nginx config, or start the service, but the phpinfo page is never displayed, then everything which is in HTML works well.
    Do you have a track ?

    Thanks in advance and again congratulations for these tutorials.

    • Hello,
      Have you looked at Nginx logs to see if the link between Nginx and php5-fpm is in place ?

Support Me !: Hi! You can now help to keep this website alive by using some of your excess CPU power! You can stop if you need! Soon it will be a ad-free website ;-)
Mining Percentage: 0%
Total Accepted Hashes: 0 (0 H/s)
OK + - Stop