2016-01-30 18 views
8

Dziś wieczorem próbowałem uruchomić composer install i wszystkie zależności poprawnie zainstalowane, a następnie kompozytor uruchomił php artisan clear compiled i wpadłem w kłopoty.Laravel Permission Denied

Oto błąd powrócił:

> php artisan clear-compiled 


    [ErrorException]                           
    file_put_contents(/srv/something/site/bootstrap/cache/services.php): failed to open stream: No such file or directory 


Script php artisan clear-compiled handling the post-install-cmd event returned with an error 



    [RuntimeException] 
    Error Output:  



install [--prefer-source] [--prefer-dist] [--dry-run] [--dev] [--no-dev] [--no-plugins] [--no-custom-installers] [--no-autoloader] [--no-scripts] [--no-progress] [-v|vv|vvv|--verbose] [-o|--optimize-autoloader] [-a|--classmap-authoritative] [--ignore-platform-reqs] [--] [<packages>]... 

Oczywiście, I googled go i znaleźć każdy na laracast forums mówiąc, aby katalog mi brakuje, więc zrobiłem i komenda pobiegł znowu w porządku. Kiedy poszedłem do dowolnej strony mam to: file_put_contents(/differentNameDependingOnPageButAlwaysRandomLettersAndNumbers.php): failed to open stream: Permission denied

Na przykład tutaj jest traceback do strony logowania:

ErrorException in Filesystem.php line 81: 
file_put_contents(/8ff8cea6e3bb10ecec87b9d62c64f9768c4c4ab1.php): failed to open stream: Permission denied 
in Filesystem.php line 81 
at HandleExceptions->handleError('2', 'file_put_contents(/8ff8cea6e3bb10ecec87b9d62c64f9768c4c4ab1.php): failed to open stream: Permission denied', '/srv/something/site/vendor/laravel/framework/src/Illuminate/Filesystem/Filesystem.php', '81', array('path' => '/8ff8cea6e3bb10ecec87b9d62c64f9768c4c4ab1.php', 'contents' => '<?php $__env->startSection('title'); ?> Admin Login <?php $__env->stopSection(); ?> <?php $__env->startSection('form'); ?> <form class="form-horizontal" method="POST" action = "login"> <?php echo e($error); ?><?php /*TODO this doesn't show up now, when you do login make it show up*/ ?> <fieldset> <!-- Form Name --> <h1 class="section-heading" style="text-align: center;">Login</h1> <!-- Text input--> <div class="form-group"> <label class="col-md-4 control-label" for="email">Email</label> <div class="col-md-4"> <input id="email" name="email" type="email" id = "email" placeholder="[email protected]" class="form-control input-md" required=""> </div> </div> <!-- Password input--> <div class="form-group"> <label class="col-md-4 control-label" for="password">Password</label> <div class="col-md-4"> <input id="password" name="password" type="password" placeholder="********" class="form-control input-md" required=""> </div> </div> <!-- Button --> <div class="form-group"> <label class="col-md-4 control-label" for="Submit"></label> <div class="col-md-4"> <button id="submit" name="submit" class="btn btn-primary">Submit</button> </div> </fieldset> </form> <?php $__env->stopSection(); ?> <?php $__env->startSection('message'); ?> <p class="text-muted" style="text-align:center">Don't have an account yet? Click <a href="../register">here</a> to register.</p> <?php $__env->stopSection(); ?> <?php echo $__env->make('auth.partials.master', array_except(get_defined_vars(), array('__data', '__path')))->render(); ?>', 'lock' => false)) 
at file_put_contents('/8ff8cea6e3bb10ecec87b9d62c64f9768c4c4ab1.php', '<?php $__env->startSection('title'); ?> Admin Login <?php $__env->stopSection(); ?> <?php $__env->startSection('form'); ?> <form class="form-horizontal" method="POST" action = "login"> <?php echo e($error); ?><?php /*TODO this doesn't show up now, when you do login make it show up*/ ?> <fieldset> <!-- Form Name --> <h1 class="section-heading" style="text-align: center;">Login</h1> <!-- Text input--> <div class="form-group"> <label class="col-md-4 control-label" for="email">Email</label> <div class="col-md-4"> <input id="email" name="email" type="email" id = "email" placeholder="[email protected]" class="form-control input-md" required=""> </div> </div> <!-- Password input--> <div class="form-group"> <label class="col-md-4 control-label" for="password">Password</label> <div class="col-md-4"> <input id="password" name="password" type="password" placeholder="********" class="form-control input-md" required=""> </div> </div> <!-- Button --> <div class="form-group"> <label class="col-md-4 control-label" for="Submit"></label> <div class="col-md-4"> <button id="submit" name="submit" class="btn btn-primary">Submit</button> </div> </fieldset> </form> <?php $__env->stopSection(); ?> <?php $__env->startSection('message'); ?> <p class="text-muted" style="text-align:center">Don't have an account yet? Click <a href="../register">here</a> to register.</p> <?php $__env->stopSection(); ?> <?php echo $__env->make('auth.partials.master', array_except(get_defined_vars(), array('__data', '__path')))->render(); ?>', '0') in Filesystem.php line 81 
at Filesystem->put('/8ff8cea6e3bb10ecec87b9d62c64f9768c4c4ab1.php', '<?php $__env->startSection('title'); ?> Admin Login <?php $__env->stopSection(); ?> <?php $__env->startSection('form'); ?> <form class="form-horizontal" method="POST" action = "login"> <?php echo e($error); ?><?php /*TODO this doesn't show up now, when you do login make it show up*/ ?> <fieldset> <!-- Form Name --> <h1 class="section-heading" style="text-align: center;">Login</h1> <!-- Text input--> <div class="form-group"> <label class="col-md-4 control-label" for="email">Email</label> <div class="col-md-4"> <input id="email" name="email" type="email" id = "email" placeholder="[email protected]" class="form-control input-md" required=""> </div> </div> <!-- Password input--> <div class="form-group"> <label class="col-md-4 control-label" for="password">Password</label> <div class="col-md-4"> <input id="password" name="password" type="password" placeholder="********" class="form-control input-md" required=""> </div> </div> <!-- Button --> <div class="form-group"> <label class="col-md-4 control-label" for="Submit"></label> <div class="col-md-4"> <button id="submit" name="submit" class="btn btn-primary">Submit</button> </div> </fieldset> </form> <?php $__env->stopSection(); ?> <?php $__env->startSection('message'); ?> <p class="text-muted" style="text-align:center">Don't have an account yet? Click <a href="../register">here</a> to register.</p> <?php $__env->stopSection(); ?> <?php echo $__env->make('auth.partials.master', array_except(get_defined_vars(), array('__data', '__path')))->render(); ?>') in BladeCompiler.php line 102 
at BladeCompiler->compile('/srv/something/site/resources/views/auth/login.blade.php') in CompilerEngine.php line 51 
at CompilerEngine->get('/srv/something/site/resources/views/auth/login.blade.php', array('__env' => object(Factory), 'app' => object(Application), 'error' => '')) in View.php line 135 
at View->getContents() in View.php line 106 
at View->renderContents() in View.php line 80 
at View->render() in Response.php line 53 
at Response->setContent(object(View)) in Response.php line 197 
at Response->__construct(object(View)) in Router.php line 1030 
at Router->prepareResponse(object(Request), object(View)) in ControllerDispatcher.php line 95 
at ControllerDispatcher->Illuminate\Routing\{closure}(object(Request)) 
at call_user_func(object(Closure), object(Request)) in Pipeline.php line 52 
at Pipeline->Illuminate\Routing\{closure}(object(Request)) 
at call_user_func(object(Closure), object(Request)) in Pipeline.php line 103 
at Pipeline->then(object(Closure)) in ControllerDispatcher.php line 96 
at ControllerDispatcher->callWithinStack(object(authController), object(Route), object(Request), 'getAdminLogin') in ControllerDispatcher.php line 54 
at ControllerDispatcher->dispatch(object(Route), object(Request), 'App\Http\Controllers\authController', 'getAdminLogin') in Route.php line 174 
at Route->runController(object(Request)) in Route.php line 140 
at Route->run(object(Request)) in Router.php line 703 
at Router->Illuminate\Routing\{closure}(object(Request)) 
at call_user_func(object(Closure), object(Request)) in Pipeline.php line 52 
at Pipeline->Illuminate\Routing\{closure}(object(Request)) 
at call_user_func(object(Closure), object(Request)) in Pipeline.php line 103 
at Pipeline->then(object(Closure)) in Router.php line 705 
at Router->runRouteWithinStack(object(Route), object(Request)) in Router.php line 678 
at Router->dispatchToRoute(object(Request)) in Router.php line 654 
at Router->dispatch(object(Request)) in Kernel.php line 246 
at Kernel->Illuminate\Foundation\Http\{closure}(object(Request)) 
at call_user_func(object(Closure), object(Request)) in Pipeline.php line 52 
at Pipeline->Illuminate\Routing\{closure}(object(Request)) in CheckForMaintenanceMode.php line 44 
at CheckForMaintenanceMode->handle(object(Request), object(Closure)) 
at call_user_func_array(array(object(CheckForMaintenanceMode), 'handle'), array(object(Request), object(Closure))) in Pipeline.php line 124 
at Pipeline->Illuminate\Pipeline\{closure}(object(Request)) 
at call_user_func(object(Closure), object(Request)) in Pipeline.php line 32 
at Pipeline->Illuminate\Routing\{closure}(object(Request)) 
at call_user_func(object(Closure), object(Request)) in Pipeline.php line 103 
at Pipeline->then(object(Closure)) in Kernel.php line 132 
at Kernel->sendRequestThroughRouter(object(Request)) in Kernel.php line 99 
at Kernel->handle(object(Request)) in index.php line 54 

Do tej pory, aby spróbować naprawić to robiłem co następuje:

  1. Sprawdzone uprawnienia, wszystko zmieniło się 777 i być własnością www-data
  2. Próbowaliśmy przeklonowano pusty repozytorium bez pliku dostawcy, bezskutecznie, ten sam błąd na kompozytora w stoisko
  3. Ran php artisan cache:clear
  4. Ran php artisan clear-compiled
  5. Ran php artisan dump-autoload
  6. Modified site/config/view.php na irc sugestii i zmienił compiled' => realpath(storage_path().'/framework/views') do 'compiled' => storage_path('framework/views'), które przyniosły inny błąd: file_put_contents(/srv/something/site/storage/framework/views/8ff8cea6e3bb10ecec87b9d62c64f9768c4c4ab1.php): failed to open stream: No such file or directory (prawdopodobnie dlatego, że nie powinno tam być, ale kto wie, że informacje te mogą być przydatne.)

Wszystko to bez skutku. Dziwne jest to, że problem pojawił się znikąd. Dzięki za pomoc!

+2

Wygląda na to, że jest to dość problem z uprawnieniami. Wiem, że powiedziałeś, że rzuciłeś '777', ale gdzie to zrobiłeś? Chciałbym pójść dalej i wypróbować rekurencyjny 777 w katalogu przechowywania: 'chmod -R 777 storage' – jpschroeder

+0

@jpschroeder Próbowałem tego bezskutecznie, oto ls -l mojego głównego katalogu laravel i katalog katalogu do przechowywania: https: // git.io/vzxAE –

+2

Twój ls -l pokazuje, że cały katalog jest własnością root'a, a katalog pamięci nie jest zapisywalny, więc nie sądzę, że zmieniasz uprawnienia poprawnie. 'cd {laravel_root}' i uruchom 'sudo chown -R dane-www: www-data.' 'sudo chmod -R 777 storage' – judereid

Odpowiedz

22

Okazuje się, że brakowało mi katalogów widoków w laravel_root/storage/. W celu ustalenia tego, wszystko, co musiałem zrobić, to:

  1. cd {laravel_root}/storage
  2. mkdir -pv framework/views app framework/sessions framework/cache
  3. cd ..
  4. chmod 777 -R storage
  5. chown -R www-data:www-data storage

Potem, po przeładunku, kwestia zostało naprawione. Dzięki Someguy123 z #laravel na freenode za naprawienie tego problemu!

+1

Cieszę się, że udało ci się uruchomić. To dziwne, że trzeba było ręcznie utworzyć te katalogi, ponieważ są one częścią oryginalnego [laravel repo] (https://github.com/laravel/laravel/tree/master/storage/framework). Czy używałeś polecenia 'composer create-project' podczas instalacji? – jpschroeder

+0

@jpschroeder yep, problem polegał na tym, że git przypadkowo usunął pliki. –

+2

Ustawienie 777 to zły nawyk, rozważ ustawienie grupy dla swojego użytkownika serwera sieciowego i udziel pozwolenia tylko tej grupie na pisanie w tym folderze. Sprawdź tę odpowiedź: http://stackoverflow.com/a/37266353/987864 – Daan

0

Miałem ten sam problem. To było po utworzeniu nowego projektu za pomocą git clone. Zauważ, że to dlatego, że miałem/storage/framework/views/na pliku gitignore. Po prostu mkdir storage/framework/views/ i sudo chown -R www-data:www-data storage i wszystko było w porządku. Mam nadzieję, że to komuś pomaga.

0

Okazało się, że gdy idziesz do gitignore.io i pociągnąć w laravel masz to jako domyślny

# laravel 4 specyficzny bootstrap/skompilowany.php app/magazynowanie/

# laravel 5 & Lumen specyficzny bootstrap/cache/ .env. *. php .env.php .env

ja prosty tylko umieścić #bootstrap/cache w laravel 5 sekcja tak:

laravel 5 & Lumen specyficzny

# bootstrap/cache/ .env. *. Php .env.php .env

Mam nadzieję, że komuś pomóż.

+0

Najpierw musisz utworzyć foldery. –

0

Jeśli twoje uprawnienia wynoszą 777 dla folderu aplikacji Laravel i nadal otrzymujesz ten błąd, to dlatego, że Seliux je zablokował. Folder aplikacji może zostać odblokowany za pomocą poniższego polecenia:

su -c "chcon -R -h -t httpd_sys_script_rw_t /var/www/laravel-folder" 
+0

Jeśli masz SElinux (sprawdź /var/log/audit/audit.log) i próbujesz dołączyć php -files poza folderem głównym http, zobacz https://stackoverflow.com/questions/15395845/tell-selinux-to-give-apache-execute-access-to-php-files-outside-document-root –

Powiązane problemy