This question already has an answer here:

I am having following error when try to install Magento 2.1.7

Fatal error: Uncaught Magento\Framework\Exception\FileSystemException: The file "/opt/lampp/htdocs/magento2/var/.regenerate" cannot be deleted Warning!unlink(/opt/lampp/htdocs/magento2/var/.regenerate): Permission denied in /opt/lampp/htdocs/magento2/vendor/magento/framework/Filesystem/Driver/File.php:382 Stack trace: #0 /opt/lampp/htdocs/magento2/vendor/magento/framework/Filesystem/Directory/Write.php(172): Magento\Framework\Filesystem\Driver\File->deleteFile('/opt/lampp/htdo...') #1 /opt/lampp/htdocs/magento2/vendor/magento/framework/Code/GeneratedFiles.php(98): Magento\Framework\Filesystem\Directory\Write->delete('/var/.regenerat...') #2 /opt/lampp/htdocs/magento2/vendor/magento/framework/App/ObjectManagerFactory.php(114): Magento\Framework\Code\GeneratedFiles->cleanGeneratedFiles() #3 /opt/lampp/htdocs/magento2/vendor/magento/framework/App/Bootstrap.php(385): Magento\Framework\App\ObjectManagerFactory->create(Array) #4 /opt/lampp/htdocs/magento2/vendor/magento/framework/App/Bootstrap.php(362): Magento\Framework\App\Bo in /opt/lampp/htdocs/magento2/vendor/magento/framework/Filesystem/Driver/File.php on line 382

marked as duplicate by sv3n, Prince Patel, liyakat, Fabian Schmengler, Keyul Shah Jul 24 '17 at 9:01

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

  • Give 777 permission to pub and var folders – Raghu Jul 22 '17 at 15:35
  • This is not permission issue, this means that you need to run this (with your data): php magento setup:install \ --admin-firstname=John \ --admin-lastname=Smith \ --admin-email=jsmith@mail.com \ --admin-user=admin \ --admin-password=password1 \ --base-url=magento.local \ --db-host=localhost \ --db-name=magento \ --db-user=magento \ --db-password=magento \ --currency=USD \ --timezone=America/Chicago \ --language=en_US \ --use-rewrites=1 This error shows when you do not have created DB and connection with same. – iva Apr 18 '18 at 10:42

Set proper file and folder permissions of your Magento 2 project.

Follow Magento 2 folder/file permissions

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