Can't run Laravel app on digitalocean using ngnix - php

My Laravel app is returning 404 on every route.
This is the address: http://67.205.191.11/, when I try for example http://67.205.191.11/classes, 404 not found is returned.
my nginx default config file looks as below:
server {
listen 80 default_server;
listen [::]:80 default_server ipv6only=on;
root /var/www/venture-backend/public/;
index index.php index.html index.htm;
# Make site accessible from http://localhost/
server_name 67.205.191.11;
location / {
try_files $uri $uri/ /index.php$is_args$args;
}
# Only for nginx-naxsi used with nginx-naxsi-ui : process denied requests
#location /RequestDenied {
# proxy_pass http://127.0.0.1:8080;
#}
#error_page 404 /404.html;
# redirect server error pages to the static page /50x.html
#
#error_page 500 502 503 504 /50x.html;
#location = /50x.html {
# root /usr/share/nginx/html;
#}
# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
#
location ~ \.php$ {
try_files $uri /index.php =404;
fastcgi_pass unix:/var/run/php5-fpm.sock;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
# deny access to .htaccess files, if Apache's document root
# concurs with nginx's one
#
#location ~ /\.ht {
# deny all;
#}
}
Anyone knows why my routes are not working?

Related

php-fpm can't work within tengine on centos 6

I have been installed php-fpm and tengine centos 6.
Here is my /usr/local/nginx/conf/nginx.conf
server {
listen 80;
server_name localhost;
location / {
root html;
index index.html index.htm;
error_page 404 /404.html;
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
location ~ \.php$ {
proxy_pass http://127.0.0.1;
}
location ~ \.php$ {
root html;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
# fastcgi_param SCRIPT_FILENAME/$document_root$fastcgi_script_name;
include fastcgi_params;
}
# deny access to .htaccess files, if Apache's document root
# concurs with nginx's one
#
location ~ /\.ht {
deny all;
}
}
http://172.104.126.251/index.html Work!
But
http://172.104.126.251/index.php can't work, it appear error page.
Hope you guys can help me, thanks!

Codiginter 3 : 404 for all pages except assest

I am trying to deploy my Codeigniter 3 HMVC website in nginx (AWS). I have tried all the solutions I found in SO but none of them worked. It is been 6 hours now. Please someone help m e out here.
I have installed nginx and tested a "Hello World" in a PHP file and it works fine.
(All the static files in assets/ folder are served in the browser. Only the routing seems to cause the issue for other urls)
This is the configs in my /etc/nginx/sites-enabled/blahblah.lk
server {
listen 80 default_server;
listen [::]:80 default_server ipv6only=on;
root /var/www/blah/public/;
index index.php index.html index.htm;
# Make site accessible from http://localhost/
server_name blahblah.lk;
location / {
# First attempt to serve request as file, then
# as directory, then fall back to displaying a 404.
try_files $uri $uri/ /index.php;
}
location ~* ~/(assets|files|robots\.txt){}
# Only for nginx-naxsi used with nginx-naxsi-ui : process denied requests
#location /RequestDenied {
# proxy_pass http://127.0.0.1:8080;
#}
#error_page 404 /404.html;
# redirect server error pages to the static page /50x.html
#
#error_page 500 502 503 504 /50x.html;
#location = /50x.html {
# root /usr/share/nginx/html;
#}
# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
#
location ~ \.php$ {
fastcgi_split_path_info ^(.+\.php)(/.+)$;
# # NOTE: You should have "cgi.fix_pathinfo = 0;" in php.ini
#
# # With php5-cgi alone:
#fastcgi_pass 127.0.0.1:9000;
# With php5-fpm:
fastcgi_pass unix:/var/run/php5-fpm.sock;
fastcgi_index index.php;
include fastcgi_params;
}
If nginx is running properly, it might be a codeigniter setup issue.
Check the rewrite rules and make sure your controllers have uppercase-first filenames, while the controller subfolders are all-lowercase. That kept me from going for hours.

Codeigniter + Nginx must render 404 page provided by framework

So, I have next problem. This is my nginx config
server {
disable_symlinks off;
listen 80;
server_name g9tv.loc;
charset utf-8;
#access_log logs/host.access.log main;
location / {
root /home/dejmos/www/g9tv;
index index.html index.htm index.php;
try_files $uri $uri/ /index.php;
}
error_page 404 /index.php;
# redirect server error pages to the static page /50x.html
#
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /home/dejmos/www/g9tv;
}
# proxy the PHP scripts to Apache listening on 127.0.0.1:80
#
#location ~ \.php$ {
# proxy_pass http://127.0.0.1;
#}
# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
#
location ~ \.php$ {
try_files $uri =404;
fastcgi_intercept_errors on;
root /home/dejmos/www/g9tv;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME /home/dejmos/www/g9tv$fastcgi_script_name;
include fastcgi_params;
}
# deny access to .htaccess files, if Apache's document root
# concurs with nginx's one
#
location ~ /\.ht {
deny all;
}
}
When I go to page that not exists on server I got 404 page provided by nginx, but I need to get 404 page provided by codeigniter show_404() function.
Problem resolved. It caused by subfolder. I place Codeigniter to root folder and all ok now.

nginx PHP won't display

I have my website stored in /usr/share/nginx/html .gave 777 to all directories and files.when i fire-up the browser and navigate to website, it downloads the page rather than displaying it.
php-fpm is installed and running
this my /etc/nginx/conf.d/default.conf
server {
listen 80;
server_name hostedweb.net;
#charset koi8-r;
#access_log /var/log/nginx/log/host.access.log main;
location / {
root /usr/share/nginx/html;
index index.php index.htm;
}
#error_page 404 /404.html;
# redirect server error pages to the static page /50x.html
#
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /usr/share/nginx/html;
}
# proxy the PHP scripts to Apache listening on 127.0.0.1:80
#
#location ~ \.php$ {
# proxy_pass http://127.0.0.1;
#}
# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
#
location ~ \.php$ {
root html;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name;
include fastcgi_params;
}
# deny access to .htaccess files, if Apache's document root
# concurs with nginx's one
#
#location ~ /\.ht {
# deny all;
#}
}
I'm on CentOS 6
any help is appreciated
In your location ~ \.php$ { try adding include fastcgi_params;
Also in your php portion you could try taking out the root html; portion, or try setting it to root /usr/share/nginx/html;
Have you tried removing or commenting out fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name;? I don't have that line in any of my nginx config files and they seem to work fine.
Did you try adding
try_files $uri $uri/;
To your location / {} block
And I believe you don't need this line
fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name;
because you included the fastcgi_params

How to set up Clean url for Drupal with Nginx in localhost

I setup a nginx server in my localhost
So now I want to enable clean url for this server
(Change localhost/drupalsite/?q=abc to localhost/drupalsite/abc)
I have tried some tutorials but thet don't work for me
http://wiki.nginx.org/Drupal
https://drupal.org/node/976392
http://richardbanks.net/blog/2012/11/nginx-url-rewrites-the-correct-method
This is some basic config in nginx.conf file
server {
listen 8080;
server_name localhost;
#charset koi8-r;
#access_log /var/log/nginx/host.access.log main;
location / {
root /srv/nginx/www/nginx_htdocs/;
index index.html index.htm index.php;
}
#error_page 404 /404.html;
# redirect server error pages to the static page /50x.html
#
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /srv/nginx/www/nginx_htdocs/;
}
# proxy the PHP scripts to Apache listening on 127.0.0.1:80
#
#location ~ \.php$ {
# proxy_pass http://127.0.0.1;
#}
# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
#
location ~ \.php$ {
root html;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
#fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name;
#fastcgi_param SCRIPT_FILENAME $request_filename;
#fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param SCRIPT_FILENAME /srv/nginx/www/nginx_htdocs/$fastcgi_script_name;
include fastcgi_params;
}
#--------------- TUNG CUSTOM
#------------- END CUSTOM
# deny access to .htaccess files, if Apache's document root
# concurs with nginx's one
#
#location ~ /\.ht {
# deny all;
#}
}
Here's a gist of a full configuration that works very well with Drupal's clean URL's
You must try to handle not found urls as possible query strings for index.php (if that's how Drupal works, which I'm not sure).
For example, in your first location block:
location / {
root /srv/nginx/www/nginx_htdocs/;
index index.html index.htm index.php;
try_files $uri $uri/ /index.php?$request_uri;
}
This way, if
`http://mysite.com/xyz`
doesn't match any file or folder, it gets handed to index.php in the form of
`http://mysite.com/index.php?xyz`

Categories