简体   繁体   中英

Fresh laravel installation not work in nginx server (Ubuntu)

I just set up nginx web server inside my ubunutu 14.04 lts with fresh laravel project. My project name laravel and when I go to http://localhost/laravel/public/ I can see the laravel welcome page display, but when I create an url to test it didn't work.

    Route::get('test', function(){
      return 'It is work!!!';
});

I hope when I go to http://localhost/laravel/public/test | http://localhost/laravel/public/index.php/test http://localhost/laravel/public/test | http://localhost/laravel/public/index.php/test it should display It is work!!! instead of this I get 404 Not Found nginx/1.4.6 (Ubuntu) . I don't know what is wrong? I have php7 ubuntu 1.4.6 installed in my machine.

Here is nginx configuration->

server {
listen 80 default_server;
listen [::]:80 default_server ipv6only=on;

root /usr/share/nginx/html;
index index.php index.html index.htm;

server_name localhost;

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

# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
location ~ \.php$ {
    try_files $uri /index.php =404;
    fastcgi_split_path_info ^(.+\.php)(/.+)$;
    fastcgi_pass unix:/var/run/php/php7.0-fpm.sock;
    fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
    fastcgi_index index.php;
    include fastcgi_params;
}

}

Please help me. I really thankful fro your help.

It looks like Bogdan already answered this in the comments. But for anybody else, make sure to point your document root to the /public directory of your Laravel project.

root /usr/you/laravelinstall/public;

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM