1. Чтобы не получить бан прочти правила магентоман! Читать обязательно!

Magento 2 Strange Permission Reset ubuntu

Тема в разделе "Magento 2", создана пользователем dansmith, 15 май 2016.

XEvil 4.0 Релиз Состоялся!
Метки:
Модераторы: Violent
  1. dansmith

    dansmith Писатель

    Регистр.:
    14 дек 2013
    Сообщения:
    3
    Симпатии:
    1
    There seems to be some issue with magento after running setup:upgrade and di compile from the bin directory, Once those two commands ran. Permission and ownership seems to be reset and magento store stop working , It will work If I manually reset the permission.

    This is when the var/generation/Magento directory is owned by server.www-data (server is my current username). The website is loading properly.

    Now I have run the bin/magento setup:upgrade command. The ownership has now changed The website is throwing error.

    As per Magento 2 - I figure out it something to do with M2 - As every time you install extension or run compiler permission will reset so I've made a simply bash script to run once extension is installed.

    I run this like sh deploy.sh

    Right after I installed M2 extension my M2 was throwing 500 Server error so this small little script help me out fix everything.

    Код:
    rm -rf /home/server/public_html/pub/static/*
    rm -rf /home/server/public_html/var/di/*
    rm -rf /home/server/public_html/var/cache/*
    rm -rf /home/server/public_html/var/composer_home/*
    rm -rf /home/server/public_html/var/generation/*
    rm -rf /home/server/public_html/var/page_cache/*
    rm -rf /home/server/public_html/var/view_preprocessed/*
    php /home/server/public_html/bin/magento setup:upgrade
    php /home/server/public_html/bin/magento setup:di:compile
    php /home/server/public_html/bin/magento setup:static-content:deploy
    chmod -R 777 /home/server/public_html/var/*
    chmod -R 777 /home/server/public_html/pub/*
    chown -R www-data.server /home/server/public_html/*
    
     
    Последнее редактирование модератором: 15 май 2016
    Kingr нравится это.
  2. ghoster

    ghoster Постоялец

    Регистр.:
    19 окт 2015
    Сообщения:
    108
    Симпатии:
    477

    1. Add www-data user and your current user name to 1 group. For example: group: website
    2. Chgrp for group: website as the owner of your root site
    3. ReSet write permission for var and pub for your magento2 root site
     
  3. am6969

    am6969 Писатель

    Регистр.:
    25 мар 2017
    Сообщения:
    7
    Симпатии:
    0
    put here de apache or ngnix config.
     
  4. alex_me

    alex_me

    Регистр.:
    25 янв 2017
    Сообщения:
    165
    Симпатии:
    113
    You probably run /bin/magento script as another user
    You should set the same user (server.www-data) in PHP CLI shell

    http://serverfault.com/questions/453811/how-to-configure-php-cli-on-linux-ubuntu-to-run-as-www-data

    or

    make your own setup:upgrade and add at the end of execute() method call your permission script:

    setup:upgrade is
    \setup\src\Magento\Setup\Console\Command\UpgradeCommand.php

    Copy to your module and change it to extend original
    Magento\Setup\Console\Command\UpgradeCommand

    Manual
    http://inchoo.net/magento-2/console-command-magento-2/

    give it another name in cofigure() function, for instance setup:myupgrade

    in execute() add at the end bash script call:

    $output = shell_exec("./set_permissions_script.sh");

    Place set_permissions_script.sh to /bin folder
     
    Последнее редактирование: 7 апр 2017
  5. turn777

    turn777 Создатель

    Регистр.:
    15 апр 2014
    Сообщения:
    19
    Симпатии:
    6
    agree with alex_me, seems you run script from another user, This can't be magento issue, because permission sets by OS, so or you run shell script with another user or your apache run with user which not owner vhost directory
     
  6. Max Markiv

    Max Markiv Постоялец

    Регистр.:
    18 июл 2016
    Сообщения:
    100
    Симпатии:
    66
    try to run last 3 commands in this modified order/way:
    chown -R server:www-data /home/server/public_html/*
    chmod -R 777 /home/server/public_html/var
    chmod -R 777 /home/server/public_html/pub