Page tree
Skip to end of metadata
Go to start of metadata

I use Nginx with PHP as FastCGI.Here, I assume the Nginx and PHP are working (more info on that at a next time or at a different page).

1) Installation things by themselves.

I did set the whole directory structure to be writable by the PHP FastCGI user.

2) Redirects that are at .htaccess for Apache. Here it is outside any 'location' subpart.

The Newscoop is here as a virtual server, hence it has its urls as the topmost ones, but generally there may be a prefix:

    set $cs_root "";

    # images, attachments
    rewrite /get_img$ $cs_root/get_img.php break;
    rewrite /attachment/ $cs_root/attachment.php break; 

    # the large .htaccess block for redirecting into index.php
    set $fixed_file "no";

    if ($request_filename ~* "\.(html|css|js|php|ico)$")
    {
        set $fixed_file "yes";
    }

    set $fixed_cache "0";
    if ($request_filename ~* "/+images/+cache") {
        set $fixed_cache "1";
    }
    if (!-f $request_filename) {
        set $fixed_cache "${fixed_cache}1";
    }
    if ($fixed_cache = "11") {
        rewrite .* $cs_root/index.php break;
        #set $fixed_file "yes";
    }

    # if ($request_filename ~* "(/+plugins/[Install Newscoop under Nginx^/]*)?/+(javascript|css|images)")
    if ($request_filename ~* "(/+plugins/[^/]*)?/+(js|javascript|css|images)")
    {
        set $fixed_file "yes";
    }
    if ($request_filename ~* "/(admin|install|templates|themes|videos)")
    {
        set $fixed_file "yes";
    }
    if ($fixed_file = "no") {
        rewrite .* $cs_root/index.php break;
    }

    # templates
    rewrite \.tpl$ $cs_root/index.php break;

    # admin interface
    rewrite /admin$ $cs_root/admin.php break;
    rewrite /admin/ $cs_root/admin.php break;
    rewrite /admin-files $cs_root/admin.php break


3) General settings on Nginx and PHP needed to set maximal upload sizes:

  • php.ini (of /etc/php5/cgi)
upload_max_filesize 16


  • at the beginning of server part of Nginx server setting
server{
    client_max_body_size 16M;
    listen   80;
    server_name  newscoop;

4) Final notes.

It works for me, I have installed the demo site. Both the publication and the admin site works. I suppose that some glitches can be here, just take it as an initial attempt and version.

  • No labels

13 Comments

  1. Nice instruction of nginx rewrite rules. In Newscoop 4.0 here's a little modification I made.

    It works for me on Newscoop 4.0 installed with nginx 1.2.0 on Ubuntu 12.04 Precise.

        # virtual directory for newscoop
        set $cs_root "";
    
        # images, attachments
        rewrite /get_img$ $cs_root/get_img.php break;
        rewrite /attachment/ $cs_root/attachment.php break;
    
        # catch non-existent cache filenames
        location ~* /+cache/
    {         try_files $uri $cs_root/index.php break;     }
    
        # the large .htaccess block for redirecting into index.php
        set $fixed_file "no";
    
        if ($request_filename ~* "\.(html|css|js|php|ico|gif|png|jpg)$")
    
    {         set $fixed_file "yes";     }
    
        rewrite /js/ $uri break;
        if ($request_filename ~* "(/plugins/[^/]*)?/(js|css|images)")
    
    {        set $fixed_file "yes";    }
    
        if ($request_filename ~* "/+(admin|install|themes|videos|pdf)")
    
    {         set $fixed_file "yes";     }
    
        if ($fixed_file = "no")
    {         rewrite .* $cs_root/index.php break;     }
    
        # templates
        rewrite \.tpl$ $cs_root/index.php break;
    
        # admin interface
        rewrite /admin$ $cs_root/admin.php break;
        rewrite /admin/ $cs_root/admin.php break;
        rewrite /admin-files $cs_root/admin.php break;
    
    1. Hi Nikolai,

      I used once your suggested nginx host configuration but had 2 different problems, which I mentioned here below. See Martin's workaround below and the other one in the forum https://wiki.sourcefabric.org/display/CS/Install+Newscoop+under+Nginx?focusedCommentId=10912933#comment-10912933

      Could you get your Newscoop installation up and running without faults with your alternative nginx configuration ?

      Regards

      Wahid

  2. Thanks for sharing this. Unfortunately I'm still "struggling" to bring Newscoop to run on an nginx. This config helped me to bypass problems related to the rewrite rules for the admin site but unfortunately not for the publication site itself. Expect for the homepage, I'm still getting 404's by every Link (pages, categories and all others).

    The log says:

    2012/10/22 00:42:13 [error] 25533#0: *130 "/var/www/newscoop.example.com/web/en/jan2011/sports/index.html" is not found (2: No such file or directory), client: XXX.XXX.XXX.XXX, server: newscoop.example.com, request: "GET /en/jan2011/sports/ HTTP/1.1", host: "newscoop.example.com", referrer: "http://newscoop.example.com/"
    

    I noticed that it tried to load the "index.html" from within the <newcsoop_install_dir>/en/jan2011/sports/index.html, but the directory structure "/en/jan2011/sports/" doesn't exist.

    What am I doing wrong ?

    Runing nginx (v. 1.2.4) and php5-fpm (v. 5.3.18) under a debian squeeze.

    Thank you in Advance

    Wahid

    1. Hi Wahid,
      the config at the top got a bit updated (mostly the cache part), but it generally should work. Though I use an older Nginx (on an older Ubuntu) and without php5-fpm.

      Regarding your case, the problem looks to be that it is not probably sent to $cs_root/index.php
      It is ok that the pub/issue/section dir structure does not exist, since it should not be there at all. Newscoop itself parses the requested URL and finds out what should be taken for the output.

      I would suggest to try to use

      rewrite .* $cs_root/index.php break;
      

      to see if it loads the pages at all. If yes, try to use that

      if ($fixed_file = "no") {
          rewrite .* $cs_root/index.php break;
      }
      

      but with some of those previous lines commented out, to find out which one breaks that.

      1. Thank you Martin! It works now.

        I forgot to mention that I took the version of Nikolai Chen, so different than yours, the backslash for the rewrite rule:

        if ($fixed_file = "no") {
        	rewrite .\* $cs_root/index.php break;
        }
        

        I used  ".*"  as you mentioned and the rewrite rules work !

        Now I must go ahead to find a fix for some php problems (esp. http://dev.sourcefabric.org/browse/CS-4444).

        Thank you again :)  !

        Wahid

        1. I'm quite sure it was just typo (that backslash).

          And for the CS-4444 issue, please look at a new comment there.

          1. Oh! Your suggestion on JIRA just works like a charm \;-) !

            You really make me to opt for the newscoop CMS, I'm so curious whether my other criteria (RTL arabic templating) will be met \:) !

            Thank you once again \:) !

            Wahid

            1. Estağ furullah.

              Yemen Times uses Newscoop, though they write in English.

              We have quite good template guys. In case of any problem, just ask at forums.

              1. Nice one! Do you speak arabic :) ?

                Al-hadath.com seemed to use arabic templates but their is down now.

                Sounds good. I'll look into that.

                Thank you

                Wahid

                1. Just a help from a (former) Turkish colleague. Even though I knew the Arabic script some years ago.

  3. Hi Martin,

    I had an issue with broken images URL's pointing to non-existing image files within the cache directory (<newscoop-install-dir/images/cache/) and after opening a discussion in the forum, Petr Jasek found out that it's because of the "break" within this block:

       location ~* /+cache/ {
             try_files $uri $cs_root/index.php break;
       }
    

    I just removed "break" and everything was fine.

    Here is the link to the forum http://forum.sourcefabric.org/discussion/14946/broken-image-links-in-publication-and-admin-site-within-the-new-custodian-theme

    Regards

    Wahid

    1. Wahid,
      thank you for the update.

      Kind regards,
      Martin

      1. Hi Martin,

        I just noticed that the rewrite rule 

           location ~* /+cache/ {
                 try_files $uri $cs_root/index.php break;
           }
        

        is not from your suggested configuration but from Nikolai Chen's one. Sorry, my confusion :) !

        Kind regards,

        Wahid