I want to create a website using Laravel Framework in my localhost laragon server

I uploaded the website files in a Web Hosting. and when I enter the url http://www.mywebsite.com. then I just get the files like

enter image description here

But when I enter the url http://www.mywebsite.com/public then it is working perfectly.

Can anyone suggest me that what's I'm doing wrong.

3 Answers

0
iCoders On

You need to point your domain to public folder of laravel not root since laravel has index.php inside project folder/public/index.php so you need to point project folder/public/

0
Lucky Saini On

Let suppose you uploaded your application to /var/www/html directory. and your public folder path looks like this /var/www/html/public.

Then your site-available file code should be like this

server {
    listen 80 default_server;
    listen [::]:80 default_server;

    root /var/www/html/public;

    # Add index.php to the list if you are using PHP
    index index.php index.html index.htm index.nginx-debian.html;

    server_name www.mywebsite.com;

    location / {
            # First attempt to serve request as file, then
            # as directory, then fall back to displaying a 404.
            try_files $uri $uri/ =404;
    }

    # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
    location ~ \.php$ {
            include snippets/fastcgi-php.conf;
    #
    #       # With php7.0-cgi alone:
    #       fastcgi_pass 127.0.0.1:9000;
    #       # With php7.0-fpm:
            fastcgi_pass unix:/run/php/php7.2-fpm.sock;
    }

    # deny access to .htaccess files, if Apache's document root
    # concurs with nginx's one
    #
    #location ~ /\.ht {
    #       deny all;
    #}
}

You just need to change root path. Then your site will work properly as expected.

0
Community On
  • i moved all files from public folder (project_folder/public/ )

    into project folder

  • in index.php i changed this lines:

    • require DIR.'/../vendor/autoload.php';
    • $app = require_once DIR.'/../bootstrap/app.php';

      INTO:

    • require DIR.'/./vendor/autoload.php';

    • $app = require_once DIR.'/./bootstrap/app.php';

      and works fine ... Thank you to everyone :)