Topics

Tribe Support

Tribe Support's Topics

George Nicolae

September 05 2018

Nginx rewrite issue

Got Anahita succesfully installed on a second attempt. Forgot to point my domain to the installation directory. Did that too and when i thought that was it, bumped in the Nginx rewrite issue. I get the homepage but no styling attached to it and 404 not found on any other page.

I really like to get it working and I have no clue to solve this.

Nick Swinford
Nick Swinford
September 05 2018 Permalink
In your configuration.php file set $debug to 1 and $error_reporting to E_ALL and see what errors you get.
Rastin Mehr liked this
George Nicolae
September 05 2018 Permalink
This is what I get:

Warning: file_put_contents(/home/admin/web/mywebsite/public_html/myproject/www/cache/site.js.0c5af962301f4bbd48db55face48c4b9): failed to open stream: Permission denied in /home/admin/web/mywebsite/public_html/myproject/src/libraries/default/base/template/helper/javascript/file.php on line 119
George Nicolae
September 05 2018 Permalink
Maybe I should post the content of my Nginx file? I got this kind of problem with wordpress too but using vestacp on top I just selected the Nginx template for wordpress rewrite
Nick Swinford
Nick Swinford
September 06 2018 Permalink
Those two errors wouldn't cause this issue. You can generally still run Anahita without any issues with them.

Can you check your php error log and see if there's anything in there?

Yeah, your nginx file might help.
George Nicolae
September 06 2018 Permalink
The most errors I see in the log look like this

2018/09/05 15:09:05 [error] 13309#13309: *1 open() "/home/admin/web/mysite/public_html/myproject/www/templates/shiraz/css/style1/style.css" failed (13: Permission denied), client: **.**.**.***, server: mysite, request: "GET /templates/shiraz/css/style1/style.css HTTP/1.1", host: "mysite", referrer: "http ://mysite/"
George Nicolae
September 06 2018 Permalink
This is my nginx config part minus the header with server directives:

location / {

location ~* ^.+\.(jpeg|jpg|png|gif|bmp|ico|svg|css|js)$ {
expires max;
}

location ~ [^/]\.php(/|$) {
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
if (!-f $document_root$fastcgi_script_name) {
return 404;
}

fastcgi_pass 127.0.0.1:9002;
fastcgi_index index.php;
include /etc/nginx/fastcgi_params;
}
}

error_page 403 /error/404.html;
error_page 404 /error/404.html;
error_page 500 502 503 504 /error/50x.html;

location /error/ {
alias /home/admin/web/mywebsite/document_errors/;
}

location ~* "/\.(htaccess|htpasswd)$" {
deny all;
return 404;
}
George Nicolae
September 07 2018 Permalink
An Nginx config file from someone who installed Anahita would also help. I feel bad that I managed to install it and I'm out of luck to use it.
Nick Swinford
Nick Swinford
September 07 2018 Permalink
@Rastin, getAnahita.com is running on Nginx right? I don't have any experience with it.
Rastin Mehr
Rastin Mehr
September 07 2018 Permalink
Yes, we're using Nginx. My first suspicion here is directory permissions. Anahita is trying to recreate a new js and css files but doesn't have the right directory permission. Could you try setting all directory permissions to 755?
George Nicolae
September 07 2018 Permalink
@Rastin added
try_files $uri $uri/;
rewrite ^(.*)$ /index.php?p=$1 last;
to that config file under location, and from the plain HTML and no CSS or JS I got to the point where at last en-GB.lib_anahita.js and site.js were loaded in the footer( only on front page) and the register form worked to register my admin account. Nothing more.
Rastin Mehr
Rastin Mehr
September 07 2018 Permalink
Does this example help?
Loading ...
George Nicolae
September 07 2018 Permalink
I guess around that I should work. Unfortunatelly same thing.

But now triyng to open in browser the adress of the shiraz/css/style1/style.css gets me "{"code":500,"message":"Component com_templates not found"}" instead of: 404, not found.

And the page source when logged in starts with div class=row
With no header at all.
Rastin Mehr
Rastin Mehr
September 07 2018 Permalink
Alright, can you set the error reporting to maximum in your php config file and $error_reporting = '30719' in anahita configuration.php file. The idea is to get a meaningful error. It's possible that a php extensions isn't installed on your server.
George Nicolae
September 07 2018 Permalink
Actually every file I open from the page source gets me the 500 error. For site.js is: component com_media not found.


Enabling error reporting I get:
Warning: file_put_contents(/home/admin/web/my-website/public_html/myproject/www/cache/site.js.0c5af962301f4bbd48db55face48c4b9): failed to open stream: Permission denied in /home/admin/web/my-website/public_html/myproject/src/libraries/default/base/template/helper/javascript/file.php on line 119
Rastin Mehr
Rastin Mehr
September 07 2018 Permalink
chmod 755 www/cache perhaps?
Rastin Mehr
Rastin Mehr
September 07 2018 Permalink
or

find www -type d -exec chmod 755 {} \;

in the root directory where Anahita is installed. Also your website root is the www directory not the one above. You probably know that already, but I wanted to point it out.
Rastin Mehr
Rastin Mehr
September 07 2018 Permalink
Also do you know if Anahita is built correctly in the www directory? Sometimes because of permissions issues components don't get symlinked properly.
George Nicolae
September 07 2018 Permalink
They both are 755.

Last try or I'm out of luck, I guess. How do I know it's correctly build? Do I have to look at a specific file, or if something is missing?
Rastin Mehr
Rastin Mehr
September 07 2018 Permalink
Have you tried building Anahita on your local machine once? Sometimes that helps for comparison sake. Most installation issues happen because of inconsistencies in server environments. We are working on Docker and Kubernetes approach to deal with that issue.
Rastin Mehr
Rastin Mehr
September 07 2018 Permalink
Basically all the directories here https://github.com/anahitasocial/anahita/tree/master/src will be symlinked in the www directory. We use symlinks because it's more efficient that copying and deleting files.

Powered by Anahita