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

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/

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
    location ~ \.php$ {
            include snippets/fastcgi-php.conf;
    #       # With php7.0-cgi alone:
    #       fastcgi_pass;
    #       # 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.

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


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

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

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