Username
Forgot password?
Welcome to our site!
Or Join with FTTF

LampCMS works from a sub-directory over Apache, but fails in Nginx

0

1043 views
We have a wordpress site running LampCMS under a sub-directory
'www' directory is re-named as questions-answers for our requirement. 

The URL: 'wordpress-site.com/questions-answers' (where 'questions-answers' works out of LampCMS). It runs perfectly over Apache. 
Configuration for Apache is given below :
Alias /questions-answers/api /var/www/projects/wordpress-site.com/lampcms/api
<Directory /var/www/projects/wordpress-site.com/lampcms/api>
RewriteEngine on
AllowOverride None
Directory>
Alias /questions-answers /var/www/projects/wordpress-site.com/lampcms/questions-answers
<Directory /var/www/projects/wordpress-site.com/lampcms/questions-answers>
RewriteEngine on
RewriteCond $1 !^(index\.php|(.+)\.(css|js|png|gif|jpg|jpeg|txt))
RewriteRule ^(.*)$ index.php/$1
AllowOverride None
Directory>

With Nginx, I have tried a few things and nothing worked correctly. I just could not get internal page routings to work correctly at all ! Here is my last-used Nginx configuration for reference. (needless to say, I could not convert Apache's rules to Nginx. Even online converters failed to do it)

server {
        listen       80;
        server_name  testing-qna.wordpress-site.com;
        root   /var/www/projects/testing-qna.wordpress-site.com/lampcms;
        access_log /var/log/nginx/testing-qna.wordpress-site.com-access.log;
        error_log /var/log/nginx/testing-qna.wordpress-site.com-error.log debug;
        index index.php;
        location /robots.txt {
          alias /var/www/html/robots.txt;
        }
        location ~ ^/questions-answers/api {
          root /var/www/projects/testing-qna.wordpress-site.com/lampcms;
          try_files $uri $uri/ /$1/$2 last;
        }
        location ~ ^/questions-answers/(css|images|js)/(.+)$ {
          root /var/www/projects/testing-qna.wordpress-site.com/lampcms;
          try_files $uri $uri/ /$1/$2 last;
        }
        location  ^/questions-answers {
          root /var/www/projects/testing-qna.wordpress-site.com/lampcms/questions-answers;
          try_files $uri $uri/ /index.php?/$uri;
          include /etc/nginx/fastcgi_params;
          fastcgi_pass  127.0.0.1:9000;
          fastcgi_param SCRIPT_FILENAME $document_root/$fastcgi_script_name;
          fastcgi_read_timeout 60s;
          include fastcgi_params;
        }
        try_files $uri $uri/ /index.php?/$uri;
        location ~ \.php {
          index index.php;
          include /etc/nginx/fastcgi_params;
          fastcgi_pass  127.0.0.1:9000;
          fastcgi_index index.php;
          fastcgi_param SCRIPT_FILENAME $document_root/$fastcgi_script_name;
          fastcgi_read_timeout 60s;
          include fastcgi_params;
        }
}

Based on Apache's rule-set, I added the rule for /api and css|js later. At some situation I needed the CSS rule as the page style was broken. Adding it, resolved styling issue. Thereafter, I tried a few things on-&-off, but retained the CSS part. '/api' part was added in the hope that routing will work. Unfortunately, it didn't make any difference.

I hope someone can help me identify what I am doing wrong.
 
asked July 30, 2015 at 8:31 AM

 in

0 Answers

Be the first to answer this question

Join with account you already have

FTTF

Preview

Alert