Yii Framework Forum: Yii2 - getting 404 Error after installing Yii/Nginx - Yii Framework Forum

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

Yii2 - getting 404 Error after installing Yii/Nginx Rate Topic: -----

#1 User is offline   pandaNine 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 3
  • Joined: 26-February 18

Posted 27 February 2018 - 03:24 AM

Hi communitiy

I've installed Nginx, php-fpm and MariaDB by this tutorial but I chose PHP version 7 instead of 5.

After this I copied the web app to /var/www/default/. First I got some DB errors which I resolved. Now I'm getting a 404 Not Found error on the site I want to open. localhost is forwarding to localhost/site/login which throws the 404. I tried localhost?r=site/login and it is also forwarding to /site/login.

Here some informations:
PHP 7.0.27
Nginx 1.13.9
Maria DB 10.2.13
Yii 2.0

/usr/local/etc/nignx/sites-available/default

server {
listen 80;
server_name localhost;
root /var/www/default/app;

access_log /usr/local/etc/nginx/logs/default.access.log main;

set $yii_bootstrap "index.php";

location / {
    index  index.html $yii_bootstrap;
    try_files $uri $uri/ /index.php$request_uri;
}

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;
}

location = /info {
allow 127.0.0.1;
deny all;
rewrite (.*) /.info.php;
}

# phpmyadmin
location ~ ^/phpmyadmin/(.+\.php)$ {
try_files $uri =404;
fastcgi_intercept_errors on;
root /usr/local/share/;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
include fastcgi_params;
}

error_page 404 /404.html;
error_page 403 /403.html;
}


Any suggestions to solve this error?
0

#2 User is offline   pandaNine 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 3
  • Joined: 26-February 18

Posted 27 February 2018 - 03:26 AM

here's the link to the tutorial:
snapdev.net/2016/04/12/install-nginx-php-fpm-mariadb-phpmyadmin-lemp-on-localhost-for-mac-osx-along-with-multiple-sites/comment-page-1/#comment-1199
0

#3 User is offline   _marcelo 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 71
  • Joined: 22-October 15
  • Location:MaceiĆ³ / Brazil

Posted 27 February 2018 - 07:08 AM

Try change

location / {
    index  index.html $yii_bootstrap;
    try_files $uri $uri/ /index.php$request_uri;
}


To:


location / {
    index  index.html $yii_bootstrap;
    try_files $uri $uri/ /web/index.php$request_uri;
}

0

#4 User is offline   pandaNine 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 3
  • Joined: 26-February 18

Posted 27 February 2018 - 09:30 AM

View Post_marcelo, on 27 February 2018 - 07:08 AM, said:

Try change

location / {
    index  index.html $yii_bootstrap;
    try_files $uri $uri/ /index.php$request_uri;
}


To:


location / {
    index  index.html $yii_bootstrap;
    try_files $uri $uri/ /web/index.php$request_uri;
}



Thx for your answer.

I changed these 4 lines and the 404 error is still there.

Any other suggestions? In my opinion, the url resolving doesn't work correctly.
0

#5 User is offline   CeBe 

  • Advanced Member
  • Yii
  • Group: Yii Dev Team
  • Posts: 576
  • Joined: 16-July 10
  • Location:Berlin. Germany

Posted 24 March 2018 - 09:41 PM

View PostpandaNine, on 27 February 2018 - 03:24 AM, said:

root /var/www/default/app;


root should point to the web directory of the Yii application, not the base directory.

View PostpandaNine, on 27 February 2018 - 03:24 AM, said:

set $yii_bootstrap "index.php";

location / {
index index.html $yii_bootstrap;
try_files $uri $uri/ /index.php$request_uri;
}


This is correct. So if you changed it, revert these.
0

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users