Tutorial NGINX configuration sample

Discussion in 'Subrion Open Source CMS Core' started by Janur J., Aug 12, 2014.

  1. Janur_J.

    Janur_J. Staff Member

    The instruction below may be useful when setting up the Subrion CMS to Nginx powered servers.

    nginx.conf sample file
    Code (Text):
    server {
        # ... your existing instructions

        location / {
            try_files $uri $uri/ /index.php?q=$uri&$args;
        }
        location /install/ {
            rewrite ^/install/(.*)$ /install/index.php?_p=$1 break;
        }
    }
    Vasily B. and Andrew G. like this.
  2. Vasily_B.

    Vasily_B. Project Manager

    Hello,

    We've finally tested our software on nginx web server. Here is the working file to run Subrion free cms for nginx:

    Code (Text):
    server {
        listen      80; # make sure there is no conflict with apache server listening on port 80
        server_name subrion_domain.com; # your website domain name

        root        /var/www/subrion; # absolute path to your subrion core files
        index       index.php;

        location = /favicon.ico {
            log_not_found off;
            access_log off;
        }

        location = /robots.txt {
            allow all;
            log_not_found off;
            access_log off;
        }

        location / {
            try_files $uri $uri/ /index.php?q=$uri&$args;
        }

        error_page  404  /404.html;
        location = /404.html {
            root   /usr/share/nginx/html;
        }

        error_page   500 502 503 504  /50x.html;
        location = /50x.html {
            root   /usr/share/nginx/html;
        }

        # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
        location ~ \.php$ {
            fastcgi_pass   127.0.0.1:9000;
            fastcgi_index  index.php;
            fastcgi_param  SCRIPT_FILENAME   $document_root$fastcgi_script_name;
            include        fastcgi_params;
        }

        location /admin/ {
            rewrite ^/admin/(.*)$ /index.php?_p=admin/$1&$args;
        }

        location /install/ {
            rewrite ^/install/(.*)$ /install/index.php?_p=$1;
        }

        # deny access to apache .htaccess files
        location ~ /\.ht
        {
            deny all;
        }

        location ~* \.(js|css|png|jpg|jpeg|gif|ico|woff|ttf)$ {
            expires max;
            log_not_found off;
        }
    }
    Do let us know if you need any assistance. Thanks!
    Dayir_A. and Andrew_G. like this.
  3. movement

    movement New Member

    It doesn't work with nginx. Admin page can not be accessed.

    Fatal error: Class 'iaAbstractControllerBackend' not found in /var/www/chartisticsweb/public_html_test3/admin/index.php on line 28

  4. Vasily_B.

    Vasily_B. Project Manager

    Hi,

    This is a known issue for index page only. You need to change default admin URL to something else. You can do this easily in phpMyAdmin. Find config table, 'admin_page' config key and change its value to 'dashboard' for example.
    The issue will disappear. New version of Subrion will have another URL instead of admin by default.

    Let us know the results please.
  5. movement

    movement New Member

    Same error. It doesn't wotk. And when accessing the old url, I got Smarty's error.
  6. skred

    skred New Member

    This tip does not help solve the problem.
  7. Greg

    Greg Super Moderator

    Just a guess guys - Maybe after doing this delete all the files in tmp/ folder
    Vasily_B. likes this.
  8. Vasily_B.

    Vasily_B. Project Manager

    If anyone still has any issues with Subrion + nginx, please submit a ticket as there could be a private issue. Nginx is good, but requires some tiny setup. If we find a common solution, we will post it here.

    Anyhow, the config posted above works on two different servers. Though we also have issues with admin dashboard, so it should be changed from admin/ to anything else. Once you make these changes in database, you need to clear your tmp/ folder.

    Thanks
  9. skred

    skred New Member

    The new version is constantly throws installation.
    And do not give or what to do once not played with configs. And the problem is only on nginx.
  10. Andrew_G.

    Andrew_G. Staff Member

    Greetings @skred ,

    Seems to be a bit obsolete reply, anyhow.

    As I remember your problem has been resolved via HelpDesk system.
  11. wapmorgan

    wapmorgan New Member

    Right now I'm using Subrion 4.0.5 and this nginx config:
    Code (Text):
    server {

        ............................................

        index index.html index.htm index.php;

       location ~* \.(js|css|png|jpg|jpeg|gif|ico|ttf)$ {
            expires max;
            log_not_found off;
        }
     
        location = /favicon.ico {
            log_not_found off;
            access_log off;
        }

        location = /robots.txt {
            allow all;
            log_not_found off;
            access_log off;
        }

        error_page  404 /404.html;
        location = /404.html {
            root   /usr/share/nginx/html;
        }

        error_page   500 502 503 504  /50x.html;
        location = /50x.html {
            root   /usr/share/nginx/html;
        }

        location /install/ {
            rewrite ^/install/(.*)$ /install/index.php?_p=$1;
        }

        # deny access to apache .htaccess files
        location ~ /\.ht {
            deny all;
        }

        location /admin/ {
            rewrite ^/admin/(.*)$ /index.php?_p=admin/$1&$args;
        }

        location / {
            try_files $uri $uri/ /index.php?_p=$uri&$args;
        }

        location ~ \.php$ {
            try_files $uri = 404;
            include fastcgi_params;
            fastcgi_pass  unix:/run/php/php7.0-fpm.sock;
            fastcgi_index index.php;
            fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
        }
    }
    Vasily_B. likes this.
  12. Vasily_B.

    Vasily_B. Project Manager

    Thanks for sharing, @wapmorgan . As mentioned via github, this will work fine but Subrion 4.0.x does not support PHP7 version.
  13. tom121

    tom121 New Member

    OMG, I wish I saw this post sooner
  14. phd2020

    phd2020 New Member

  15. magicescort

    magicescort New Member

Share This Page