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

johnDoe220's avatar

Laravel script not loading in vps!

Laravel script not loading in vps! Hi, I just managed to run my project on VPS and there was no problem, so I tested different pages including index.php and index.html in different files and directories and everything was working fine. But when I did the same thing with the Laravel project, the page returned blank. The addressing is completely correct and points to the public folder, but the project does not run. As a summary: All types of files are loaded in any directory without problems, except for Laravel. I think the problem is with .htaccess and it should probably be changed. Considering that it works on localhost

0 likes
29 replies
vincent15000's avatar

Have you generated the app key with php artisan key:generate ?

Tray2's avatar

Usually when the page is empty like that has to do with permissions, make sure that you have the correct permissions on the storage directory, and if you have that and it still doesn't work, make sure you replace the modified htaccess with the original ones. You should never update the htaccess unless you know exactly what you are doing. I also suggest taking a look in the log files, usually they can be found here /var/logs/

johnDoe220's avatar

@Tray2 this error log.

\Handler->renderExceptionResponse()\n#17 /var/www/site/vendor/laravel/framework/src/Illuminate/Foundation/Bootstrap/HandleExceptions.php(220): Illuminate\Foundation\Exceptions\Handler->render()\n#18 /var/www/site/vendor/laravel/framework/src/Illuminate/Foundation/Bootstrap/HandleExceptions.php(197): Illuminate\Foundation\Bootstrap\HandleExceptions->renderHttpResponse()\n#19 /var/www/site/vendor/laravel/framework/src/Illuminate/Foundation/Bootstrap/HandleExceptions.php(233): Illuminate\Foundation\Bootstrap\HandleExceptions->handleException()\n#20 /var/www/site/vendor/laravel/framework/src/Illuminate/Foundation/Bootstrap/HandleExceptions.php(257): Illuminate\Foundation\Bootstrap\HandleExceptions->handleShutdown()\n#21 [internal function]: Illuminate\Foundation\Bootstrap\HandleExceptions->Illuminate\Foundation\Bootstrap\{closure}()\n#22 {main}\n  thrown in /var/www/site/vendor/laravel/framework/src/Illuminate/Filesystem/Filesystem.php on line 190
OussamaMater's avatar

@johnDoe220 as @tray2 said, permissions are not correctly configured.

You need to make sure the user that the process is running as in your case the webserver you chose (nginx, apache, etc..) (the user must be www-data or a low privileged user, for security purposes) owns the directory or at least have enough permissions to write*.

1 like
johnDoe220's avatar

@OussamaMater You probably only noticed the first line of the error, because after that I fixed the license error, which is clear in the next lines, the error is something else.

OussamaMater's avatar

@johnDoe220 Keep sharing the logs so we can assist you, and how about you tell us the steps you followed to deploy this application (of course after installing and setting the env), like what user are you using? what are the current permissions, etc..

1 like
johnDoe220's avatar

i'm root user.and use apache2

sudo chown -R :www-data /var/www/myproject
sudo chmod -R 775 /var/www/myproject/storage
sudo chmod -R 775 /var/www/myproject/bootstrap/cache
OussamaMater's avatar

@johnDoe220 Yes these commands looks correct, permissions are set, so why not clear the logs, retry and see what's the new error? probably something else now?

Edit, the nginx (or whatever webserver your running) is running as the www-data right?

OussamaMater's avatar

@johnDoe220 is the APP_DEBUG=true? and have you installed all the dependencies and created an app key?

And actually what @tray2 pointed is better and more secure, 664 does the same job but better, so you shouldn't worry about these permissions.

1 like
Tray2's avatar

It's a permissions issue and chmoding should solve the issue.

file_put_contents(/var/www/site/storage/framework/views/fa87e26090aa5af305a1518e8cf90d38a0abc12a.php): Failed to open stream: Permission denied in /var/www/site/vendor/laravel/framework/src/Illuminate/Filesystem/Filesystem.php:190\nStack trace:\n#0 
Tray2's avatar

@johnDoe220 What error do you get? Does Laravel created cached view in the storage directory? Try turning on debug and set the prod to local, just to see if you get any errors that don't make it to the log.

Have you enabled mod_rewrite?

OussamaMater's avatar

@johnDoe220 is this a custom 404 page you made or what? what kind of vps does this? I only see stuff like this on the shared hosting

1 like
johnDoe220's avatar

@OussamaMater

[Mon Aug 29 13:55:49.264954 2022] [ssl:warn] [pid 20219] AH01906: www.mysite.com:443:0 server certificate is a CA certificate (BasicConstraints: CA == TRUE !?)             
[Mon Aug 29 13:55:49.265263 2022] [ssl:warn] [pid 20219] AH01909: www.mysite.com:443:0 server certificate does NOT include an ID which matches the server name              
[Mon Aug 29 13:55:49.265589 2022] [ssl:error] [pid 20219] AH02217: ssl_stapling_init_cert: can't retrieve issuer certificate! [subject: [email protected],CN=21>
[Mon Aug 29 13:55:49.265615 2022] [ssl:error] [pid 20219] AH02604: Unable to configure certificate www.mysite.com:443:0 for stapling                                        
PHP Warning:  PHP Startup: Unable to load dynamic library 'openssl' (tried: /usr/lib/php/20210902/openssl (/usr/lib/php/20210902/openssl: cannot open shared object file: No s>
                                                                                                                                                                             

mysite is fake domain name(example)

OussamaMater's avatar

@johnDoe220 can your run php -m and paste the output? I think it's something about the openssl module not loaded, not sure though

1 like
johnDoe220's avatar

@OussamaMater I will configure the server from the beginning, it doesn't work like this, I will let you know the result

Tray2's avatar

@johnDoe220 I would guess that you are using apache and haven't turned on mod_rewrite.

johnDoe220's avatar

@Tray2 i run this

 sudo a2enmod rewrite // retrun : Module rewrite already enabled

but run your text

 a2enmod mod_rewrite // return : ERROR: Module mod_rewrite does not exist!
johnDoe220's avatar

@Tray2 @oussamamater I now rebooted the server OS and more gracefully installed the raw Laravel project. But now a new problem has arisen, and that is that when I run the combination key ctrl + f5, the Laravel project comes up. But when I press the f5 key alone, the simple default html page I created is displayed. I also cleared the cache of the browser, I checked with another computer, but the same problem still exists, is it possible that the vps caches itself?

Please or to participate in this conversation.