Users running a non-download version of Vanilla (pulled from github), on branch release/2019.016 or master from the last 2 weeks should upgrade to release/2019.017 or latest master for security reasons. Downloaded official open sources releases are not affected.
Please upgrade here. These earlier versions are no longer being updated and have security issues.

installing in subfolder (nginx)

Hello.

i am trying to install this script step-by-step but have problem.

  1. Need to install into subdirectory, http://domain.com/vanilla/
  2. I get the last version vanilla-core-2-2-1.zip, unzip it in folder
  3. Create rules, like in example: http://docs.vanillaforums.com/developer/backend/
  4. open URL http://domain.com/vanilla/
  5. and it redirects me to root http://domain.com/index.php?p=/dashboard/setup
  6. trying to change url to http://domain.com/vanilla/index.php?p=/dashboard/setup and get page without graphics (wrong pathes)

... <link rel="stylesheet" type="text/css" href="/applications/dashboard/design/setup.css?v=2.2.1" media="all" /> <link rel="canonical" href="http://domain.com/index.php?p=/setup" /> ...etc

when i trying enter from subdomain, like http://vanilla.domain.com/ it works good.

What i am doing wrong? Thanks.

Comments

  • whu606whu606 I'm not a SuperHero; I just like wearing tights... Moderator

    @gimcnuk

    Welcome to the community.

    The issue is, I believe, that pretty (nice) urls are not enabled in your nginx conf file.

    Have a look at this thread to see if it helps:

    https://vanillaforums.org/discussion/30390/cant-access-categories-nginx-nice-urls

    or this site:

    http://www.geektalks.org/vanilla-forum-simple-way-to-get-friendly-urlurls-rewriting-work-in-nginx/

    hgtonight
  • i used rules from official site - point 3.

    Trying to create config.php with
    $Configuration['Garden']['RewriteUrls'] = true;
    now it redirects to http://domain.com/dashboard/setup

  • whu606whu606 I'm not a SuperHero; I just like wearing tights... Moderator

    @gimcnuk

    That isn't enough.

    You will need to edit your nginx config file.

    I have a site in a subdomain on nginx, and I followed the conf set up in the post I gave you, and my site works.

    If you don't edit your nginx conf file I don't think you will resole your issue.

    hgtonight
  • @whu606 said:
    I have a site in a subdomain on nginx, and I followed the conf set up in the post I gave you, and my site works.

    nginx config edited and reloaded.
    But i talking about subfolder, not subdomain.

  • hmm, tested on other server. Now works.
    Very strange

    hgtonight
  • Found problem by myself.

    I have special nginx config with non-standard path_info
    then php_self contains wrong data.

    Now add $_SERVER['PHP_SELF'] = $_SERVER['SCRIPT_NAME']; in conf/config.php
    It works.

    whu606vrijvlinder
  • ShadowdareShadowdare Moderator
    edited July 2016

    Many nginx guides will state that in order for many other PHP scripts to get the correct the PATH_INFO variable, your PHP-FPM config should have this setting cgi.fix_pathinfo = 0 so that the scripts can rewrite URLs. On the other hand, I believe that Vanilla can handle routes regardless of how cgi.fix_pathinfo is set with the following nginx server config since I just tried toggling this setting and Vanilla URLs worked fine in either case, but this is not a definite answer on if setting it to that is required or not.

    Some history behind this setting is that earlier versions of PHP didn't exactly support PATH_INFO as its own variable and basically combined that information into the SCRIPT_FILENAME variable. With the default setting of cgi.fix_pathinfo = 1, newer PHP applications, including the upcoming Vanilla 2.3 release, can support the proper usage of PATH_INFO as its own variable.

    Here are some basic examples of nginx location blocks you can use with the rewrites from the Vanilla Forums Documentation in your nginx server blocks.

    The fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; line should fix the main issue with PATH_INFO.

    location / {
        try_files $uri @vanilla;
    }
    
    location @vanilla {
        rewrite ^ /index.php?p=$uri&$args last;
    }
    
    location ~ \.php$ {
        try_files $uri =404;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
    
        fastcgi_pass 127.0.0.1:9000;
        fastcgi_index index.php;
        include fastcgi_params;
    }
    

    If your Vanilla is installed in a subfolder, you should replace the two main location blocks with this (replacing subfolder with the correct name):

    location /subfolder {
        try_files $uri @vanilla;
    }
    
    location @vanilla {
        rewrite ^/subfolder(/.*) /subfolder/index.php?p=$1&$args last;
    }
    

    For scripts that work with cgi.fix_pathinfo = 1, you could replace that PHP location block with the following, which currently doesn't work with Vanilla 2.2 and earlier.

    location ~ [^/]\.php(/|$) {
        fastcgi_split_path_info ^(.+?\.php)(/.*)$;
        if (!-f $document_root$fastcgi_script_name) {
            return 404;
        }
    
        fastcgi_pass 127.0.0.1:9000;
        fastcgi_index index.php;
        include fastcgi_params;
    }
    

    Read this page on the nginx wiki and the notes below it for more info, including an explanation for the necessity of handling 404 for security reasons.

    Other good informational resources with examples is the nginx page on the WordPress Codex and this Server Fault post.

    Add Pages to Vanilla with the Basic Pages app

Sign In or Register to comment.