2

I downloaded Bitnami's Magento VM (OVA, using it in vmware on windows). It is a Debian 9 (Debian GNU/Linux 9.8 (stretch)) with Apache/2.4.39 (Unix), PHP 7.1.27. By default, it is configured to serve Magento from /opt/bitnami/apps/magento/htdocs enter image description here The user I can use to connect with SSH is the bitnami user, which does not have permission to modify files in magento's directory. All the services are configured to run with another user, like daemon or mysql. enter image description here

What am I supposed to do to be able to open magento's directory through SFTP with an IDE on my host system and be able to deploy files too? enter image description here

My understanding was I can connect with SSH, leave the terminal open, so I can run commands using bin/magento or use git in the directory and have PhpStorm on my host system edit and deploy files, while I can use the bitnami vm's ip to open the website in my browser.

Edit.: I jsut realized, there is a magento installation in ~/apps/magento/htdocs too, why?

szabkel
  • 143
  • 6
  • Please read through https://devdocs.magento.com/guides/v2.3/config-guide/prod/prod_file-sys-perms.html this will answer any questions you may have regarding file permissions – Dava Gordon Apr 12 '19 at 09:27
  • @DavaGordon Do I need to reconfigure the whole bitnami vm then? Change the php-fpm, apache users to a group and change the ownership of the files to the group somehow? I mean, this is supposed to work, I think I am missing something – szabkel Apr 12 '19 at 14:09
  • No id suggest just changing the permissions of the magneto directory can i suggest you take a look at https://magento.stackexchange.com/questions/91870/magento-2-folder-file-permissions i dont see the point in duplicating content which is already provided. any issues just message back. – Dava Gordon Apr 12 '19 at 14:49
  • also after a quick search i can see that similar issues on AWS have been raised. please see https://support.weltpixel.com/hc/en-us/articles/115006621627-Bitnami-AWS-Installation-issues-with-Magento-2-Theme-or-Extensions-Solved- for reference – Dava Gordon Apr 12 '19 at 14:51
  • @DavaGordon I am not sure. I fired up a new bitnami vm, changed the permissions according to the post you mention and it broke the installation. – szabkel Apr 15 '19 at 08:28
  • if you used standard permissions magento recommended then it should work if your still having issues try changing all folder perms to 755 and file permissions to 644 and making the pub/static var/ and generation folders 777 – Dava Gordon Apr 15 '19 at 09:20
  • @DavaGordon I tried. What you are describing is the post you previously linked, but it does not solve the problem. New files are uploaded with different permissions, it suggest me to set 777 permission for /var which cannot be right and another post wants me to change vendor files... – szabkel Apr 15 '19 at 13:13
  • Maybe if I do this: https://magento.stackexchange.com/a/170488/77952 but new files I upload will still have different owners (bitnami:bitnami) and permissions than the files that are already in the app/code folder. – szabkel Apr 15 '19 at 13:20
  • When i first looked at a VM i toyed around with that but never used it as was far too buggy, ended up creating a new virtual box. – Dava Gordon Apr 15 '19 at 13:24
  • It does not seem buggy so far and setting up user rights would be the same on a new vm too. If only I would be more comfortable with linux permission config... – szabkel Apr 15 '19 at 13:30
  • have you tried contacting the support for bitnami see if they have any suggestions also have you tried running sudo chown -R bitnami:daemon . from the root of your magento instance – Dava Gordon Apr 15 '19 at 13:33
  • @DavaGordon https://community.bitnami.com/t/how-to-use-phpstorm-with-a-bitnami-vm/66537 – szabkel Apr 15 '19 at 13:34

1 Answers1

2

I kind of solved this, but remember not to use this solution when you are on a production machine!

By default, the bitnami VM is configured with the correct permissions and with a one-user approach. The user which owns the directory is daemon, also used for apache. It is not possible to easily add permissions for the bitnami user.

The daemon user is a service user, but we can change it to allow us to login with SSH/SFTP on our PhpStorm.

  1. Login as the bitnami user
  2. Change the daemon user's type with sudo usermod -s /bin/bash daemon (you can view the result before and after with cat /etc/passwd)
  3. Create a password for the daemon user: sudo passwd daemon
  4. Configure PhpStorm to use the remote server with the daemon user (over SFTP)

All the new files uploaded will be using the correct permissions and you can change existing files too, like the ./.gitignore file.

Another important thing is, for every other task, you should still use the bitnami user (it helps to remember that the daemon user is not in the sudoers file, so you won't be able to sudo with it). Bitnami already has a wrapper for the bin/magento untility, you should always use the bitnami user and sudo ./bin/magento-cli to run cli commands, like cache:clean..etc, like you would do without this change.

You can easily revert this change, if you run sudo usermod -s /usr/sbin/nologin daemon

szabkel
  • 143
  • 6