Joomla 2.5 on Nginx

Discussion in 'Installation/Configuration' started by Kozley, Feb 27, 2012.

  1. Kozley

    Kozley Member

    Last edited: Feb 27, 2012
  2. falko

    falko Super Moderator

    This is what I've added to the nginx Directives field on the Options tab in ISPConfig:

    Code:
           # deny running scripts inside writable directories
           location ~* /(images|cache|media|logs|tmp)/.*\.(php|pl|py|jsp|asp|sh|cgi)$ {
                    return 403;
                    error_page 403 /403_error.html;
           }
    
           location / {
                    try_files $uri $uri/ /index.php?q=$uri&$args;
           }
    
           # caching of files
           location ~* \.(ico|pdf|flv)$ {
                    expires 1y;
           }
    
           location ~* \.(js|css|png|jpg|jpeg|gif|swf|xml|txt|otf|woff)$ {
                    expires 14d;
           }
     
  3. Kozley

    Kozley Member

    Thanks for the reply. I added to the nginx Directives and restart php-fpm and reload nginx, also clear browser cache. Same result =(
     
  4. falko

    falko Super Moderator

    Can you post the full vhost?

    Are there any errors in the site's error log or the overall nginx error log?
     
  5. Kozley

    Kozley Member

    Here's the full vhost:
    Code:
    server {
            listen *:80;
    
    
            server_name www.veniversum.eu www.www.veniversum.eu;
    
            root   /var/www/www.veniversum.eu/web;
    
    
    
            index index.html index.htm index.php index.cgi index.pl index.xhtml;
    
    
    
            error_page 400 /error/400.html;
            error_page 401 /error/401.html;
            error_page 403 /error/403.html;
            error_page 404 /error/404.html;
            error_page 405 /error/405.html;
            error_page 500 /error/500.html;
            error_page 502 /error/502.html;
            error_page 503 /error/503.html;
    
            error_log /var/log/ispconfig/httpd/www.veniversum.eu/error.log;
            access_log /var/log/ispconfig/httpd/www.veniversum.eu/access.log combined;
    
            ## Disable .htaccess and other hidden files
            location ~ /\. {
                deny all;
                access_log off;
                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;
            }
    
            location /stats {
                index index.html index.php;
                auth_basic "Members Only";
                auth_basic_user_file /var/www/clients/client0/web1/.htpasswd_stats;
            }
    
            location /awstats-icon {
                alias /usr/share/awstats/icon;
            }
    
            location ~ \.php$ {
                try_files $uri =404;
                include /etc/nginx/fastcgi_params;
                fastcgi_pass 127.0.0.1:9010;
                fastcgi_index index.php;
                fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
                fastcgi_param PATH_INFO $fastcgi_script_name;
                fastcgi_intercept_errors on;
            }
    
    
                    location /phpmyadmin {
                           root /usr/share/;
                           index index.php index.html index.htm;
                           location ~ ^/phpmyadmin/(.+\.php)$ {
                                   try_files $uri =404;
                                   root /usr/share/;
                                   fastcgi_pass 127.0.0.1:9000;
                                   fastcgi_index index.php;
                                   fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
                                   include /etc/nginx/fastcgi_params;
                                   fastcgi_buffer_size 128k;
                                   fastcgi_buffers 256 4k;
                                   fastcgi_busy_buffers_size 256k;
                                   fastcgi_temp_file_write_size 256k;
                                   fastcgi_intercept_errors on;
                           }
                           location ~* ^/phpmyadmin/(.+\.(jpg|jpeg|gif|css|png|js|ico|html|xml|txt))$ {
                                   root /usr/share/;
                           }
                    }
                    location /phpMyAdmin {
                           rewrite ^/* /phpmyadmin last;
                    }
    
                    location /cgi-bin/mailman {
                           root /usr/lib/;
                           fastcgi_split_path_info (^/cgi-bin/mailman/[^/]*)(.*)$;
                           include /etc/nginx/fastcgi_params;
                           fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
                           fastcgi_param PATH_INFO $fastcgi_path_info;
                           fastcgi_param PATH_TRANSLATED $document_root$fastcgi_path_info;
                           fastcgi_intercept_errors on;
                           fastcgi_pass unix:/var/run/fcgiwrap.socket;
                    }
                    location /images/mailman {
                           alias /usr/share/images/mailman;
                    }
                    location /pipermail {
                           alias /var/lib/mailman/archives/public;
                           autoindex on;
                    }
    
                   # deny running scripts inside writable directories
                   location ~* /(images|cache|media|logs|tmp)/.*\.(php|pl|py|jsp|asp|sh|cgi)$ {
                            return 403;
                            error_page 403 /403_error.html;
                   }
    
                   location / {
                            try_files $uri $uri/ /index.php?q=$uri&$args;
                   }
    
                   # caching of files
                   location ~* \.(ico|pdf|flv)$ {
                            expires 1y;
                   }
    
                   location ~* \.(js|css|png|jpg|jpeg|gif|swf|xml|txt|otf|woff)$ {
                            expires 14d;
                   }
    
    
    }
    
    
    Not overall nginx error log I could see.

    EDIT: Now I could see the error log
    Code:
    2012/02/29 14:40:03 [emerg] 20857#0: open() "/etc/nginx/fastcgi.conf" failed (2: No such file or directory) in /etc/nginx/sites-enabled/100-www.veniversum.eu.vhost:115
    2012/02/29 14:40:03 [emerg] 20858#0: open() "/etc/nginx/fastcgi.conf" failed (2: No such file or directory) in /etc/nginx/sites-enabled/100-www.veniversum.eu.vhost:115
    2012/02/29 14:42:03 [emerg] 20978#0: open() "/etc/nginx/fastcgi.conf" failed (2: No such file or directory) in /etc/nginx/sites-enabled/100-www.veniversum.eu.vhost:112
    2012/02/29 14:42:03 [emerg] 20979#0: open() "/etc/nginx/fastcgi.conf" failed (2: No such file or directory) in /etc/nginx/sites-enabled/100-www.veniversum.eu.vhost:112
    
    Ok, I see fastcgi.conf is empty in directory. So I don't know what I would make to solve missing fastcgi.conf.
     
    Last edited: Feb 29, 2012
  6. Kozley

    Kozley Member

    Now I'm gave up! I has to install ubuntu 11.10 and got error 502. I'm back to Apache! Nginx does not works with Joomla 2.5!
     
  7. falko

    falko Super Moderator

    It does. I'm running it on nginx myself. But I can't say where the problem is with your configuration. Maybe PHP-FPM wasn't running correctly? There's a bug in the PHP-FPM init script on Ubuntu 11.10 (see chapter 4 on http://www.howtoforge.com/using-php5-fpm-with-apache2-on-ubuntu-11.10 ).
     
  8. Kozley

    Kozley Member

    Thank you so much! It was bugged on the PHP-FPM init script, now it's fixing.

    EDIT: I noticed why I got error 503. It was Joomla Offline page problem. I don't know why. Please help!
     
    Last edited: Mar 2, 2012
  9. airflow

    airflow New Member

    Hello guys,

    I am facing a kind of similar situation on my installation which is based on:
    http://www.howtoforge.com/perfect-server-centos-6.2-x86_64-with-nginx-ispconfig-3

    When I do a clear/fresh installation of joomla (any version) on my server it works perfectly including SEF.

    When I move my website from my previous server which is on iis and php+mysql I get "500 - internal server error" on my Frontend!
    The back end works perfectly fine.
    I have tried turning of SEF as well but no luck.
    I have changed both user and group ownership on the transferred files from the previous server which has made all the requirements writable.

    I am just not figuring out why this '500 - internal server error' appears! I would really appreciate it if anyone can guide me a little bit through.

    Thank in advance
     
  10. falko

    falko Super Moderator

    Did you check nginx' error log?
     
  11. airflow

    airflow New Member

    I did but there wasn't anything stated regarding that. Would you please direct me to the right path direction if you believe there should be something there?

    I would really appreciate it.
     
  12. falko

    falko Super Moderator

    The overall nginx error log should be in /var/log/nginx/, but it's also possible that the website has its own error log.
     
  13. CuttlefishJones

    CuttlefishJones New Member

    Hi, I've been getting the same error (503 service unavailable) on multiple Joomla sites and its been driving me crazy until I realised there is no error.

    When Joomla is put offline it responds with site unavailable. Nginx is just being to pedantic about the response.

    So, in fact, its actually right. The site is 503. I have yet to automate a fix for it but I think that if you capture the 503 in the conf file for your site and redirect that to a Joomla login page then you should be OK.

    R*
     

Share This Page