Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

Zoul's avatar
Level 5

500 SERVER ERROR in production

hi, i have this error, and i checked the error_log file, i found

[07-Jun-2022 16:02:21 UTC] PHP Warning:  require(/home/oaahtnot/public_html/public/../vendor/autoload.php): failed to open stream: No such file or directory in /home/oaahtnot/public_html/public/index.php on line 34

in index.php in public folder

require __DIR__.'/../vendor/autoload.php';

I appreciate your help !

0 likes
18 replies
jlrdw's avatar

Did you install the framework?

Zoul's avatar
Level 5

thanks for your support @jlrdw , you mean by running composer install ? Yes if that what you meant

tisuchi's avatar

@zoul

Have you run composer update or composer install to make sure you have the latest update?

2 likes
jlrdw's avatar

@Zoul are you pointing to public as the document root? Also in index.php put:

echo "hello";

do you see hello?

1 like
Zoul's avatar
Level 5

@jlrdw yes i guess , its pointing to the root, i put echo "hello"; in index.php in public folder, and its printing the message in browser, and down i can still see500 SERVER ERRORerror

jlrdw's avatar

@Zoul I think you have a wrong folder structure. It's not finding the vendor folder. Can you show your basic folder structure? Also using apache or nginx?

1 like
Zoul's avatar
Level 5

@jlrdw Sure !

 public_html
	app
	bootstrap
	contig
	database
	public
	resources
	routes
	storage
	vendor
	editorconfig
	.env
	.htaccess
	error_log
	server.php
	etc
Zoul's avatar
Level 5

i'm putting my .htacces in root public_html folder and it contains of:

<IfModule mod_rewrite.c>
<IfModule mod_negotiation.c>
    Options -MultiViews
</IfModule>

RewriteEngine On

RewriteCond %{REQUEST_FILENAME} -d [OR]
RewriteCond %{REQUEST_FILENAME} -f
RewriteRule ^ ^ [N]

RewriteCond %{REQUEST_URI} (\.\w+$) [NC]
RewriteRule ^(.*)$ public/

RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ server.php
</IfModule> 

if that can help

jlrdw's avatar
jlrdw
Best Answer
Level 75

No, your htaccess needs to be placed where it was in public. Use a virtual host to point to public correctly.

Otherwise if public_html is now going to be public, place main laravel above public_html and point to public_html as document root.

Edit:

If you search, correctly setting up laravel has been discussed many times.

1 like
Zoul's avatar
Level 5

@jlrdw Ok, i will place it in public folder ... thanks

Zoul's avatar
Level 5

Thanks a lot @jlrdw these links, very informative,

I moved the htaccess file to public folder and it redirected to index.php file in public

<IfModule mod_rewrite.c>
    <IfModule mod_negotiation.c>
        Options -MultiViews
    </IfModule>
    RewriteEngine On
    # Redirect Trailing Slashes...
    RewriteRule ^(.*)/$ / [L,R=301]

    # Handle Front Controller...
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule ^ index.php [L]
</IfModule>

Then i enabled APP_DEBUG=true in env file and got this error although i'm checking $side_books variable before displaying it in component

Undefined variable $side_books (View: /home/oaahtnot/public_html/resources/views/components/book-sidebar.blade.php)

BookSidebar component

<?php

namespace App\View\Components;

use Illuminate\View\Component;
use App\Models\Book;
use Hashids\Hashids;
class BookSidebar extends Component
{

    /**
     * Create a new component instance.
     *
     * @return void
     */
    public function __construct()
    {
        // 
    }

    /**
     * Get the view / contents that represent the component.
     *
     * @return \Illuminate\Contracts\View\View|\Closure|string
     */
   public function render()
    {
        $hash = new Hashids('', 10); // pad to length 10
        $side_books = Book::select('id','title','name','file')->take(5)->ge();
        return view('components.book-sidebar',compact('side_books','hash')); 
    }
}
iftekhs's avatar

@Zoul Hi, I think this is a different question so if your previous question was solved mark it as solved by selecting the best answer and open a new thread for a new question. :)

1 like
Zoul's avatar
Level 5

thanks @iftekhs :) i guess, i was not seeing this error at the beginning becaus i did not enabled the debug mode but @jlrdw helped me alot with htaccess , i will open a new one if that what you recommand :)

1 like
Zoul's avatar
Level 5

thank you all for your valuable time and support !

Please or to participate in this conversation.