1

I am running a OS Ubunutu 16.4.2 with Nginx as a server. After clone a laravel project, and run composer install and npm install and create the .env file and run sudo chown -R ila:www-data mysite.com/.

That was the error I got from NginX error log with a 404 in the browser:

2017/06/14 15:52:47 [error] 11459#11459: *16 FastCGI sent in stderr: "PHP message: 
PHP Warning:  
require(/home/ila/vhosts/mysite.com/bootstrap/../vendor/autoload.php): 
failed to open stream: No such file or directory in
/home/ila/vhosts/mysite.com/bootstrap/autoload.php on line 17

PHP message: PHP Fatal error:  require(): Failed opening required
'/home/ila/vhosts/mysite.com/bootstrap/../vendor/autoload.php' 
(include_path='.:/usr/share/php') in 
/home/ila/vhosts/mysite.com/bootstrap/autoload.php on line 17" while 
reading response header from upstream, client: 127.0.0.1, server: 
mysite.com, request: "GET / HTTP/1.1", upstream:
"fastcgi://unix:/var/run/php/php7.0-fpm.sock:", host: "mysite.com"

Then following this post I ran composer update and I am still getting the 404 error in the browser and now error log is not being updated tail -f /var/log/nginx/mysite.com-error.log.

So I still get the error 404 in the browser and no clues in the error log.

Any idea in how to solve this scenario?

Note: I was expecting to have any permission error for the storage/ file that I could solve with chmod guo+w storage/.

Update

I will track the exactly point where or when the logs file stops to be updated.

  1. Deleted the project and ran the URL mysite.com. Result an error 404 Not Found nginx/1.10.0 (Ubuntu). Got this error in mysite.com-error.log

    2017/06/15 09:16:18 [error] 3718#3718: *30 FastCGI sent in stderr: "PHP message: PHP Warning: Unknown: failed to open stream: No such file or directory in Unknown on line 0 Unable to open primary script: /var/www/vhosts/mysite.com/public/index.php (No such file or directory)" while reading response header from upstream, client: 127.0.0.1, server: mysite.com, request: "GET / HTTP/1.1", upstream: "fastcgi://unix:/var/run/php/php7.0-fpm.sock:", host: "mysite.com"

    Which is expected since I dont have the project directory.

  2. Cloned the repository into vhosts/ and ran the URL mysite.com. Result an error This page isn’t working mysite.com is currently unable to handle this request.HTTP ERROR 500

    2017/06/15 09:35:32 [error] 3718#3718: *41 FastCGI sent in stderr: "PHP message: PHP Warning:
    require(/home/ila/vhosts/mysite.com/bootstrap/../vendor/autoload.php): failed to open stream: No such file or directory in /home/ila/vhosts/mysite.com/bootstrap/autoload.php on line 17 PHP message: PHP Fatal error: require(): Failed opening required '/home/ila/vhosts/mysite.com/bootstrap/../vendor/autoload.php' (include_path='.:/usr/share/php') in /home/ila/vhosts/mysite.com/bootstrap/autoload.php on line 17" while reading response header from upstream, client: 127.0.0.1, server: mysite.com, request: "GET / HTTP/1.1", upstream: "fastcgi://unix:/var/run/php/php7.0-fpm.sock:", host: "mysite.com"

    The project is being reached by the server but have an issue with the autoload.php now it is a Laravel issue.

  3. Now I will run composer install and npm install. Now I have vendor/autoload.php and nothing inside bootstrap/cache. After run ran the URL mysite.com in the browser I still have This page isn’t working mysite.com is currently unable to handle this request.HTTP ERROR 500

    2017/06/15 10:19:31 [error] 3718#3718: *53 FastCGI sent in stderr: "PHP message: PHP Fatal error: Uncaught UnexpectedValueException: The stream or file "/home/ila/vhosts/mysite.com/storage/logs/laravel.log" could not be opened: failed to open stream: Permission denied in /home/ila/vhosts/mysite.com/vendor/monolog/monolog/src/Monolog/Handler/StreamHandler.php:107 Stack trace: 0 /home/ila/vhosts/mysite.com/vendor/monolog/monolog/src/Monolog/Handler/AbstractProcessingHandler.php(37): Monolog\Handler\StreamHandler->write(Array) 1 /home/ila/vhosts/mysite.com/vendor/monolog/monolog/src/Monolog/Logger.php(337): Monolog\Handler\AbstractProcessingHandler->handle(Array) 2 /home/ila/vhosts/mysite.com/vendor/monolog/monolog/src/Monolog/Logger.php(616): Monolog\Logger->addRecord(400, Object(UnexpectedValueException), Array) 3 /home/ila/vhosts/mysite.com/vendor/laravel/framework/src/Illuminate/Log/Writer.php(203): Monolog\Logger->error(Object(UnexpectedValueException), Array) 4 /home/ila/vhosts/mysite.com/vendor/laravel/framework/src/Illuminate/Log/Writer.php(114): Illuminate\Log...

    PHP message: PHP Fatal error: Uncaught UnexpectedValueException: The stream or file "/home/ila/vhosts/mysite.com/storage/logs/laravel.log" could not be opened: failed to open stream: Permission denied in /home/ila/vhosts/mysite.com/vendor/monolog/monolog/src/Monolog/Handler/StreamHandler.php:107 Stack trace: 0 /home/ila/vhosts/mysite.com/vendor/monolog/monolog/src/Monolog/Handler/AbstractProcessingHandler.php(37): Monolog\Handler\StreamHandler->write(Array) 1 /home/ila/vhosts/mysite.com/vendor/monolog/monolog/src/Monolog/Logger.php(337): Monolog\Handler\AbstractProcessingHandler->handle(Array) 2 /home/ila/vhosts/mysite.com/vendor/monolog/monolog/src/Monolog/Logger.php(616): Monolog\Logger->addRecord(400, Object(Symfony\Component\Debug\Exception\FatalErrorException), Array) 3 /home/ila/vhosts/mysite.com/vendor/laravel/framework/src/Illuminate/Log/Writer.php(203): Monolog\Logger->error(Object(Symfony\Component\Debug\Exception\FatalErrorEx

    Here at this point we have a permission denied for storage/ folder.

  4. This is what we have drwxrwxr-x 6 ila ila 4096 Jun 15 09:35 storage/ AND now I will run $sudo chmod -R guo+w storage/ to give write permission to storage/ folder and now we have drwxrwxrwx 6 ila ila 4096 Jun 15 09:35 storage/

At this point $ tail -f /var/log/nginx/mysite.com-error.log is not updating mysite.com-error.logany more AND I have an error in the browser.

enter image description here

It is a Laravel error. I know I need to create .env file, but before, lets check what we have inside $ tail -f vhosts/mysite.com/storage/logs/laravel.log

#0 /home/ila/vhosts/mysite.com/vendor/laravel/framework/src/Illuminate/Foundation/ProviderRepository.php(165): Illuminate\Foundation\ProviderRepository->writeManifest(Array)
#1 /home/ila/vhosts/mysite.com/vendor/laravel/framework/src/Illuminate/Foundation/ProviderRepository.php(61): Illuminate\Foundation\ProviderRepository->compileManifest(Array)
#2 /home/ila/vhosts/mysite.com/vendor/laravel/framework/src/Illuminate/Foundation/Application.php(549): Illuminate\Foundation\ProviderRepository->load(Array)
#3 /home/ila/vhosts/mysite.com/vendor/laravel/framework/src/Illuminate/Foundation/Bootstrap/RegisterProviders.php(17): Illuminate\Foundation\Application->registerConfiguredProviders()
#4 /home/ila/vhosts/mysite.com/vendor/laravel/framework/src/Illuminate/Foundation/Application.php(208): Illuminate\Foundation\Bootstrap\RegisterProviders->bootstrap(Object(Illuminate\Foundation\Application))
#5 /home/ila/vhosts/mysite.com/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php(160): Illuminate\Foundation\Application->bootstrapWith(Array)
#6 /home/ila/vhosts/mysite.com/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php(144): Illuminate\Foundation\Http\Kernel->bootstrap()
#7 /home/ila/vhosts/mysite.com/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php(116): Illuminate\Foundation\Http\Kernel->sendRequestThroughRouter(Object(Illuminate\Http\Request))
#8 /home/ila/vhosts/mysite.com/public/index.php(53): Illuminate\Foundation\Http\Kernel->handle(Object(Illuminate\Http\Request))
#9 {main}
  1. Creating .env and refreshing the browser. Gave me NO ERROR inside mysite.com-error.log.

Had the follow error in the browser:enter image description here

I got the follow error inside $ tail -f vhosts/mysite.com/storage/logs/laravel.log

[2017-06-15 14:58:23] local.ERROR: Exception: The bootstrap/cache directory must be present and writable. in /home/ila/vhosts/mysite.com/vendor/laravel/framework/src/Illuminate/Foundation/ProviderRepository.php:190
Stack trace:
#0 /home/ila/vhosts/mysite.com/vendor/laravel/framework/src/Illuminate/Foundation/ProviderRepository.php(165): Illuminate\Foundation\ProviderRepository->writeManifest(Array)
#1 /home/ila/vhosts/mysite.com/vendor/laravel/framework/src/Illuminate/Foundation/ProviderRepository.php(61): Illuminate\Foundation\ProviderRepository->compileManifest(Array)
#2 /home/ila/vhosts/mysite.com/vendor/laravel/framework/src/Illuminate/Foundation/Application.php(549): Illuminate\Foundation\ProviderRepository->load(Array)
#3 /home/ila/vhosts/mysite.com/vendor/laravel/framework/src/Illuminate/Foundation/Bootstrap/RegisterProviders.php(17): Illuminate\Foundation\Application->registerConfiguredProviders()
#4 /home/ila/vhosts/mysite.com/vendor/laravel/framework/src/Illuminate/Foundation/Application.php(208): Illuminate\Foundation\Bootstrap\RegisterProviders->bootstrap(Object(Illuminate\Foundation\Application))
#5 /home/ila/vhosts/mysite.com/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php(160): Illuminate\Foundation\Application->bootstrapWith(Array)
#6 /home/ila/vhosts/mysite.com/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php(144): Illuminate\Foundation\Http\Kernel->bootstrap()
#7 /home/ila/vhosts/mysite.com/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php(116): Illuminate\Foundation\Http\Kernel->sendRequestThroughRouter(Object(Illuminate\Http\Request))
#8 /home/ila/vhosts/mysite.com/public/index.php(53): Illuminate\Foundation\Http\Kernel->handle(Object(Illuminate\Http\Request))
#9 {main}

At this point I have no error (updates) inside tail -f /var/log/nginx/mysite.com-error.log AND I have no error (updates) inside $ tail -f vhosts/mysite.com/storage/logs/laravel.log AND now I have 404 not found again:enter image description here

Finally I found my stupid error was inside my routes/web.php file.enter image description here

IgorAlves
  • 5,086
  • 10
  • 52
  • 83

0 Answers0