First of all: I'm new to Linux and web dev. I was a Dynamics NAV dev, so this whole things is totally new to me. I've been thrown to the deep end, so I'm trying to learn as much as

I installed Magento2 using Composer, and I can run bin/magento.

But, I can't run Magento on my browser. Running localhost just gives me white page. I can create a HelloWorld.php on the same folder and run it no problem though. I have setup the .htaccess and the config in apache2 folder.

I changed the permission to the whole /var/www/html folder to www-data and now I can see Magento setup page. But now I can't run bin/magento, because the permission is now on www-data.


  • Who is supposed to be the owner for the /var/www/html folder? I'm supposed it's www-data?
  • What's the correct setup here? Should I just put myself as part of the www-data?
  • www-data Owner will be working fine, Jan 12, 2018 at 4:41
  • The problem is that your apache is running with www-data user, and you php CLI is running with another user (your user probally), set all the permissions to www-data user, and runs your CLI comands with www-data user to.
    – lpFranz
    May 23, 2018 at 14:15

2 Answers 2


Please try to set folder permission to that listed below where you have installed:

sudo chown -R www-data:www-data magento

this solved my problem when installing Magento.


The solution for Giving a Folder Permission Everytime Issue.

Open this file with sudo user


and replace www-data with your system username for example:

export APACHE_RUN_USER=yoursystemuser

export APACHE_RUN_GROUP=yoursystemuser

line # 16-17

Save file and Run

sudo a2enmod rewrite

and restart apache after that you don't need to give permission every time.

Enjoy Coding.... :)

  • This is a very bad idea to run apache at the system level user. Jan 12, 2018 at 4:40

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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