Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error 500 #52

Closed
oldgalileo opened this issue Jun 10, 2014 · 12 comments
Closed

Error 500 #52

oldgalileo opened this issue Jun 10, 2014 · 12 comments

Comments

@oldgalileo
Copy link

Hello!

I have been struggling for close to 6 hours now on trying to get this to run. I really really want this, but for whatever reason, I just can't. The site itself works fine, but when I try to go to any actual pages, such as example.com/login, it throws an error 500. I have looked up a bunch of solutions but nothing seems to run. I am using nginx and using my own configuration since yours just doesn't work. I am running nginx on Ubuntu 13.10 Server.

/etc/nginx/sites-available/default:

server {
    listen 80; 
    root /var/www;
    server_name example; #this isn't what is actually in mine, I just don't want to reveal my domain

    location / {
    try_files $uri/ $uri /index.php?$query_string;
    }

    location ~ \.php$ {
        fastcgi_split_path_info ^(.+\.php)(/.+)$;
        fastcgi_pass unix:/var/run/php5-fpm.sock;
        fastcgi_index index.php;
        include fastcgi_params;
    }

    location /doc/ {
        alias /usr/share/doc/;
        autoindex on;
        allow 127.0.0.1;
        deny all;
    }

    location ~/\.ht {
        deny all;
    }

}

At the moment, I am just trying to get the bare minimum to work. Then I will add the config block etc.

I have no idea anymore.

@oldgalileo
Copy link
Author

Okay. So I fiddled with it a bit more. It seems that when I change the configuration to this:

server {
    listen 80;   # We're deliberately leaving this as-is to avoid conflict at the moment

    root /var/www;
    server_name example.com;

    location / {
    try_files $uri/ $uri /index.php?$query_string;
    }

    location ~ \.php$ {
        fastcgi_split_path_info ^(.+\.php)(/.+)$;
        fastcgi_pass unix:/var/run/php5-fpm.sock;
        fastcgi_index index.php;
        include fastcgi_params;
    }

    location /doc/ {
        alias /usr/share/doc/;
        autoindex on;
        allow 127.0.0.1;
        deny all;
    }

    location ~/\.ht {
        deny all;
    }

}

The things like /login and stuff work great. However going to simply example.com/ and gives me a 403. However reverting back to the previous one fixes it and reverses it. Going to example.com/index does work however. Gah.

@danpros
Copy link
Owner

danpros commented Jun 10, 2014

Did you use the example Nginx config? I try using it and work fine, CentOS+Nginx.

server {
  listen 80;

  server_name example.com www.example.com;
  root /usr/share/nginx/html;

  access_log /var/log/nginx/access.log;
  error_log /var/log/nginx/error.log error;

  index index.php;

  location ~ /config/ {
     deny all;
  }

  location / {
    try_files $uri $uri/ /index.php;
  }

  location ~ \.php$ {
        fastcgi_pass   127.0.0.1:9000;
        fastcgi_index  index.php;
        fastcgi_param  SCRIPT_FILENAME   $document_root$fastcgi_script_name;
        include        fastcgi_params;
  }
}

@oldgalileo
Copy link
Author

I will try it again, but it did not appear to work last time. Also, I am running on Ubuntu Server.

@oldgalileo
Copy link
Author

Nope. Still a 403 when I go to example.com and a success when I go to example.com/index. Any other ideas?

EDIT: Wait. Actually, it's a 502 for example.com/index. Interesting.
EDIT 2: I can confirm it is not an issue with php5-fpm. I tested that and it just made things worse.

@ncang
Copy link

ncang commented Jun 10, 2014

it's run on localhost ?

@oldgalileo
Copy link
Author

Um. Yeah, I think so. I mean, I have a domain pointing to it, but yes. It is running on localhost I am pretty sure. How would I check?

EDIT: If you mean on my personal machine, no. I am running on a VPS.

@ncang
Copy link

ncang commented Jun 10, 2014

i mean, make sure webserver (nginx) work in your localhost, & try htmly run well on locahost before pointing to domain,

@oldgalileo
Copy link
Author

I would, but the testing environment wouldn't be the same. I am running Mac OS X and don't really have an option to install refit or whatever it is called.

@ncang
Copy link

ncang commented Jun 10, 2014

try clear browser cache, or restart nginx 💨 , sorry if it does not help

@oldgalileo
Copy link
Author

Sadly, I have tried both of those. If anyone else wants to chime on on successes with HTMLy and nginx, by all means.

@oldgalileo
Copy link
Author

Ahah! Okay. I have figured it out and you should definitely add this to the README.

Here is the config that worked:

server {
  listen 80;

  server_name mc.snowcraft.in;
  root /var/www;

  access_log /var/log/nginx/access.log;
  error_log /var/log/nginx/error.log error;

  index index.php;

  location ~ /config/ {
     deny all;
  }

  location / {
    try_files $uri $uri/ /index.php;
  }

  location ~ .php$ {
    try_files $uri =404;
    fastcgi_split_path_info ^(.+\.php)(/.+)$;
    fastcgi_pass unix:/var/run/php5-fpm.sock;
    fastcgi_index index.php;
    include fastcgi_params;
  }
}

And that works with everything. The other thing is that you have to make sure that php5-fpm was set up properly. My issue was that it was running on the sock, while I was telling it to listen on 127.0.0.1:9000. The two need to be the same in both files, and for me, the IP based one didn't work at all. So yeah. Wooo! It works!

@fahmi182
Copy link
Contributor

Congratulation ! @HowardStark :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants