How to use phpBB, phpMyAdmin with Unicorn and nginx?

Posted October 30, 2014 3.7k views

I used the 1-Click Ruby on Rails on Ubuntu 14.04 Image and this guide to setup my rails app: . Then, I used the the PHP guide to install PHP.

On my previous shared host, I ran the phpBB forum from inside the rials public directory. The Apache .htaccess file had an entry to turn off the rails rewrite rule.

How can I achieve this with nginx? Right now when I go to , rails returns a 404 error. How can I tell nginx to server php inside my /home/myrailsapp/public/forum ? Is there a better way? Below is my nginx config file.

server {
        listen   80;
        root /home/myrailsapp/public;
        server_name my_ip;
        index index.htm index.html index.php;

        location / {
                try_files $uri/index.html $uri.html $uri @app;

        location ~* ^.+\.(jpg|jpeg|gif|png|ico|zip|tgz|gz|rar|bz2|doc|xls|exe|pdf|ppt|txt|tar|mid|midi|wav|bmp|rtf|mp3|flv|mpeg|avi)$ {
                        try_files $uri @app;

        location @app {
                proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
                proxy_set_header Host $http_host;
                proxy_redirect off;
                proxy_pass http://app_server;
        # pass the PHP scripts to FastCGI server listening on the php-fpm socket
        location ~ \.php$ {
                try_files $uri =404;
                fastcgi_pass unix:/var/run/php5-fpm.sock;
                fastcgi_index index.php;
                fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
                include fastcgi_params;

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Submit an Answer
1 answer

You’ll want to set up a location directive for the forum that will not direct requests to the proxy pass. It would look something like:

        location /forum {
            root /path/to/phpmybb;
            index index.php index.html index.htm;
            try_files $uri $uri/ =404;

Let us know how it goes!