1. 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?

Discussion in 'Server Configuration and Hosting' started by victormarconi, Aug 14, 2013.

  1. victormarconi

    victormarconi New Member

    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: Aug 14, 2013
  2. Floren

    Floren Well-Known Member

    What is your forum link?
     
  3. JulianD

    JulianD Well-Known Member

    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?
     
  4. victormarconi

    victormarconi New Member

    I'm sorry for taking to long to reply.
    My forum is hosted at localhost. I've edited /etc/hosts and included www.candidatovagax.com.br (my domain will be www.canddiatovaga.com.br - no X before .com.br)

    I've managed to integrate Xenforo with Question2Answer using simple SQL queries, though I think that using Xenforo's libs would be more elegant.

    Thanks for the reply.
     

Share This Page