0

I upload the data local to server . I changed env.php file and also change core_config_data table but when I run url on server it gives me 500 server error. while on local its run perfectly. can any one help me?

Error Like Below:

Fatal error: Uncaught Magento\Framework\Exception\LocalizedException: Can't create directory /var/www/html/magento2/var/generation/Magento/Framework/App/ResourceConnection/. in /var/www/html/magento2/vendor/magento/framework/Code/Generator.php:103 Stack trace: #0 /var/www/html/magento2/vendor/magento/framework/Code/Generator/Autoloader.php(35): Magento\Framework\Code\Generator->generateClass('Magento\\Framewo...') #1 [internal function]: Magento\Framework\Code\Generator\Autoloader->load('Magento\\Framewo...') #2 [internal function]: spl_autoload_call('Magento\\Framewo...') #3 /var/www/html/magento2/vendor/magento/framework/Code/Reader/ClassReader.php(19): ReflectionClass->__construct('Magento\\Framewo...') #4 /var/www/html/magento2/vendor/magento/framework/ObjectManager/Definition/Runtime.php(44): Magento\Framework\Code\Reader\ClassReader->getConstructor('Magento\\Framewo...') #5 /var/www/html/magento2/vendor/magento/framework/ObjectManager/Factory/Dynamic/Developer.php(71): Magento\Framework\ObjectManager\Definition\Runt in /var/www/html/magento2/vendor/magento/framework/Code/Generator.php on line 103

I am using magento version: 2.0.2

6
  • enable error reporting it will show you the error
    – Piyush
    Jan 29 '18 at 13:29
  • how to enable error reporting? I am newbie to magento 2
    – H_Parekh
    Jan 29 '18 at 13:30
  • 1
    you can enable display_errors from app/bootstrap.php file. At line no. 11 remove # from the start ini_set('display_errors', 1);.
    – Piyush
    Jan 29 '18 at 13:32
  • @piyush , thanks , I edit my question please give me response
    – H_Parekh
    Jan 29 '18 at 13:43
  • please run commands given in below answer by @SureshChikani
    – Piyush
    Jan 29 '18 at 13:44
1

Run below command and check

rm -rf var/page_cache var/cache var/composer_home var/generation var/di var/view_preprocessed
php bin/magento setup:upgrade
php bin/magento setup:static-content:deploy -f
php bin/magento indexer:reindex
php bin/magento indexer:clean
php bin/magento cache:c

Give full permissions to var folder : Magento 2 folder/file permissions

5
  • Thanks for reply, I edit the question so please give me answer..
    – H_Parekh
    Jan 29 '18 at 13:44
  • Check my updated answer, give permission to var/ folder. Jan 29 '18 at 13:45
  • how to give permission and which permission?
    – H_Parekh
    Jan 29 '18 at 13:46
  • I give all the permission but still the same error comes . I think am missing something , so can you please give me step by step answer
    – H_Parekh
    Jan 30 '18 at 6:33
  • Check which URL run in console or also you can check it with enable developer mode. Jan 30 '18 at 6:36
1

Give correct permissions to your directories.

Recommended settings for the permissions are as follows:

All directories have 770 permissions.

770 permissions give full control (that is, read/write/execute) to the owner and to the group and no permissions to anyone else.

All files have 660 permissions.

660 permissions mean the owner and the group can read and write but other users have no permissions.

Try to run these commands in SSH and your permissions should be sorted:

cd <your Magento install dir> 

find . -type f -exec chmod 644 {} \;                        // 644 permission for files

find . -type d -exec chmod 755 {} \;                        // 755 permission for directory 

find ./var -type d -exec chmod 777 {} \;                // 777 permission for var folder    

find ./pub/media -type d -exec chmod 777 {} \;

find ./pub/static -type d -exec chmod 777 {} \;

chmod 777 ./app/etc

chmod 644 ./app/etc/*.xml

chown -R :<web server group> .

chmod u+x bin/magento

You can find out more information on this website: https://devdocs.magento.com/

0
find var vendor pub/static pub/media app/etc -type f -exec chmod g+w {} \;
find var vendor pub/static pub/media app/etc -type d -exec chmod g+ws {} \;

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.