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

Nginx Assistance

Discussion in 'Server Configuration and Hosting' started by lostincable, Mar 4, 2013.

  1. lostincable

    lostincable Active Member

    Hi all, I am running Nginx with PHP-FPM from centminmod and about to move my forum to Xenforo but just have a bit of trouble with the configuration.

    My forum is in my document root and I added what was said is required for NGINX friendly URL's from here -

    http://xenforo.com/help/friendly-urls/

    Now this section when added to the configuration file for the NGINX site causes NGINX /PHP-FPM to make all URL's download a file and it does not execute them. I have looked in all the logs and nothing is around. If I remove this section and restart NGINX the site works fine including friendly URL's.

    Code:
    location ~ \.php$ {
        try_files $uri /xf/index.php
        fastcgi_pass    127.0.0.1:9000;
        fastcgi_param  SCRIPT_FILENAME $document_root$fastcgi_script_name;
        include        fastcgi_params;
    }
    
    Centminmod creates the Nginx config files for you and at the bottom of the config file it has added these comments -

    Code:
    include /usr/local/nginx/conf/staticfiles.conf;
      include /usr/local/nginx/conf/php.conf;
      include /usr/local/nginx/conf/drop.conf;
      #include /usr/local/nginx/conf/errorpage.conf;
    }
    
    So I looked at my "php.conf " file and it shows the fast CGI parameters and it also has this in there -

    Code:
    location ~ \.php$ {
        try_files $uri =404;
        fastcgi_split_path_info ^(.+\.php)(/.+)$;
        fastcgi_pass  127.0.0.1:9000;
        #fastcgi_pass  unix:/tmp/php5-fpm.sock;
        fastcgi_index  index.php;
        fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
    }
    So do I need to add the fastcgi option into my conf to make it work or is it already taken care of?

    And I am guessing but could this be cuasing my files to download vs execute?

    My fulle NGINX config file is here -

    Code:
    server {
      server_name xxxxx localhost www.localhost;
     
      # limit_conn limit_per_ip 16;
      # ssi  on;
     
    access_log /xxxxxx/access.log combined buffer=32k;
    error_log /xxxxx/error.log;
     
    root /xxxxxx/public;
     
    location / {
        try_files $uri $uri/ /index.php?$uri&$args;
        index index.php index.html;
    }
     
    location /internal_data/ {
        internal;
    }
    location /library/ {
          internal;
    }
     
    #location ~ \.php$ {
    #    try_files $uri /index.php
    #    fastcgi_pass    127.0.0.1:9000;
    #    fastcgi_param  SCRIPT_FILENAME $document_root$fastcgi_script_name;
    #    include        fastcgi_params;
    #}
     
    include /usr/local/nginx/conf/staticfiles.conf;
    include /usr/local/nginx/conf/php.conf;
    include /usr/local/nginx/conf/drop.conf;
    #include /usr/local/nginx/conf/errorpage.conf;
    }
     
    
     
  2. p4guru

    p4guru Well-Known Member

    bit confused you getting files prompting for download if you leave centmin mod config as is ? or when you try adding to existing centmin mod existing config ?

    you don't need to touch php.conf from centmin mod

    which files are downloading ? php files ? attachments ?
     
  3. lostincable

    lostincable Active Member

    Okay ill cut it down :)!

    This works -

    Code:
    server {
      server_name xxxxx localhost www.localhost;
     
      # limit_conn limit_per_ip 16;
      # ssi  on;
     
    access_log /xxxxxx/access.log combined buffer=32k;
    error_log /xxxxx/error.log;
     
    root /xxxxxx/public;
     
    location / {
        try_files $uri $uri/ /index.php?$uri&$args;
        index index.php index.html;
    }
     
    location /internal_data/ {
        internal;
    }
    location /library/ {
          internal;
    }
     
    #location ~ \.php$ {
    #    try_files $uri /index.php
    #    fastcgi_pass    127.0.0.1:9000;
    #    fastcgi_param  SCRIPT_FILENAME $document_root$fastcgi_script_name;
    #    include        fastcgi_params;
    #}
     
    include /usr/local/nginx/conf/staticfiles.conf;
    include /usr/local/nginx/conf/php.conf;
    include /usr/local/nginx/conf/drop.conf;
    #include /usr/local/nginx/conf/errorpage.conf;
    }
    This doesn't work -

    Code:
    server {
      server_name xxxxx localhost www.localhost;
     
      # limit_conn limit_per_ip 16;
      # ssi  on;
     
    access_log /xxxxxx/access.log combined buffer=32k;
    error_log /xxxxx/error.log;
     
    root /xxxxxx/public;
     
    location / {
        try_files $uri $uri/ /index.php?$uri&$args;
        index index.php index.html;
    }
     
    location /internal_data/ {
        internal;
    }
    location /library/ {
          internal;
    }
     
    location ~ \.php$ {
    try_files $uri /index.php
    fastcgi_pass    127.0.0.1:9000;
    fastcgi_param  SCRIPT_FILENAME $document_root$fastcgi_script_name;
    include        fastcgi_params;
    }
     
    include /usr/local/nginx/conf/staticfiles.conf;
    include /usr/local/nginx/conf/php.conf;
    include /usr/local/nginx/conf/drop.conf;
    #include /usr/local/nginx/conf/errorpage.conf;
    }
    It makes all URL's download instead of executing if that makes sense?
     
  4. p4guru

    p4guru Well-Known Member

    you don't need this

    Code:
    location ~ \.php$ {
    try_files $uri /index.php
    fastcgi_pass    127.0.0.1:9000;
    fastcgi_param  SCRIPT_FILENAME $document_root$fastcgi_script_name;
    include        fastcgi_params;
    }
    it's already in php.conf generated by centmin mod http://centminmod.com/nginx_configure.html
     
    lostincable likes this.
  5. lostincable

    lostincable Active Member

    Okay cheers :)!!!

    I thought so I just wasn't sure as I have had this in VBulletin config file for ages and it works fine....
     
  6. p4guru

    p4guru Well-Known Member

    Glad i could help :)
     

Share This Page