Question

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

Was it helpful?

Solution

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

OTHER TIPS

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/

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 {} \;
Licensed under: CC-BY-SA with attribution
Not affiliated with magento.stackexchange
scroll top