• This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn more.

Nginx configuration preventing external scripts to run some Xenforo code?

#1
Hi everybody!

I've successfully installed Xenforo with Nginx + PHP-FPM.
I've used Xenforo's config snipet:

Code:
    location /forum {
            try_files $uri $uri/ /forum/index.php?$uri&$args;
        }

        location ~ /forum/(internal_data|library) {
            internal;
        }

    location /respostas {
            rewrite ^/respostas/([a-z\/]+)(\?.+)?$ /respostas/index.php?qa-rewrite=$1&$args last;
        }

        location ~ \.php$ {
        include fastcgi.conf;
        fastcgi_pass 127.0.0.1:9000;
            fastcgi_index  index.php;
            fastcgi_param  SCRIPT_FILENAME $document_root$fastcgi_script_name;
        }

    }
Now I'm trying to integrate Xenforo user login mechanism with Question2Answers. They make available an integration script in which I should fill some info in order to make both work along.

Some of the information needed is user's id, shown name and email. So I tried to use some Xenforo code to get this info:


PHP:
// Sets up XenForo App
define('XF_ROOT', '/home/victor/Workspace/candidatovaga/public/forum'); // set this (absolute path)!
define('TIMENOW', time());
define('SESSION_BYPASS', false); // if true: logged in user info and sessions are not needed

require_once(XF_ROOT . '/library/XenForo/Autoloader.php');

XenForo_Autoloader::getInstance()->setupAutoloader(XF_ROOT . '/library');

XenForo_Application::initialize(XF_ROOT . '/library', XF_ROOT);
XenForo_Application::set('page_start_time', TIMENOW);
XenForo_Application::disablePhpErrorHandler();
XenForo_Application::setDebugMode(false);

// The remaining of the file is Q2A code
// (...)
This file is in SITE_ROOT/respostas. Xenforo is installed under SITE_ROOT/forum.

When I try the script I get nothing printed and no error (in nginx error.log).

I guess somehow nginx.conf is blocking Xenforo's file to be imported to this script.
Code:
location ~ /forum/(internal_data|library) {
            internal;
        }
But if I comment these lines, I keep getting nothing printed.

I've commented each line from bottom to up and the problem ocours in:
PHP:
XenForo_Application::initialize(XF_ROOT . '/library', XF_ROOT);
Any ideas?

(Sorry about bad English... I'm no native speaker)
 
Last edited:

JulianD

Well-known member
#3
Start with simple tests:

1. Put a static file on /respostas. Can you access it?

If yes,

2. Put a simple php file (<?php phpinfo(); ?>) on /respostas. Does it run?