Symfony2 post-update-cmd gives “An error occurred when generating the bootstrap file”

后端 未结 11 1093
一向
一向 2020-12-15 05:13

I am currently on Symfony2 2.3.7. When I run the composer update command. In the post-update-cmd a script is run to update symfony2. But it fails:

Script Sen         


        
11条回答
  •  -上瘾入骨i
    2020-12-15 05:23

    How to solve install/update Symfony 2 issues

    One important Symfony requirement is that the app/cache and app/logs directories must be writable both by the web server and the command line user.

    On Linux and macOS systems, if your web server user is different from your command line user, you need to configure permissions properly to avoid issues. There are several ways to achieve that:

    The most common solution :

    In a terminal execute following commands :

    rm -rf bin
    rm -rf vendor
    composer install
    # or if your didn't install composer
    php composer.phar install
    

    It should work now! For more informations see Symfony installation.

    If you still have this error : «An error occurred when generating the bootstrap file»
    It means that you have file permission issue.
    See below procedure for solve the problem ↓

    Setting up or Fixing File Permissions :

    In a terminal execute following commands :

    rm -rf app/cache/*
    rm -rf app/logs/*
    

    On macOS systems, the chmod command supports the +a flag to define an ACL. Use the following script to determine your web server user and grant the needed permissions:

    HTTPDUSER=$(ps axo user,comm | grep -E '[a]pache|[h]ttpd|[_]www|[w]ww-data|[n]ginx' | grep -v root | head -1 | cut -d\  -f1)
    sudo chmod +a "$HTTPDUSER allow delete,write,append,file_inherit,directory_inherit" app/cache app/logs
    sudo chmod +a "$(whoami) allow delete,write,append,file_inherit,directory_inherit" app/cache app/logs
    

    On most Linux and BSD distributions don't support chmod +a, but do support another utility called setfacl. You may need to install setfacl and enable ACL support on your disk partition before using it. Then, use the following script to determine your web server user and grant the needed permissions:

    HTTPDUSER=$(ps axo user,comm | grep -E '[a]pache|[h]ttpd|[_]www|[w]ww-data|[n]ginx' | grep -v root | head -1 | cut -d\  -f1)
    # if this doesn't work, try adding `-n` option
    sudo setfacl -dR -m u:"$HTTPDUSER":rwX -m u:$(whoami):rwX app/cache app/logs
    sudo setfacl -R -m u:"$HTTPDUSER":rwX -m u:$(whoami):rwX app/cache app/logs
    

    If none of the previous methods work for you

    Change the umask so that the cache and log directories are group-writable or world-writable (depending if the web server user and the command line user are in the same group or not). To achieve this, put the following line at the beginning of the app/console, web/app.php and web/app_dev.php files:

    umask(0002); // This will let the permissions be 0775
    // or
    umask(0000); // This will let the permissions be 0777
    

    Note : Changing the umask is not thread-safe, so the ACL methods are recommended when they are available.

    For more information see official documentation : Symfony file permissions

提交回复
热议问题