• If you are still using CentOS 7.9, it's time to convert to Alma 8 with the free centos2alma tool by Plesk or Plesk Migrator. Please let us know your experiences or concerns in this thread:
    CentOS2Alma discussion

Question how to switch shell user to vhost domain owner user with su command ?

jmano

New Pleskian
i am trying to follow the magento 2 install and migration instructions and am having trouble creating what magento calls a Magento file system owner . Since Plesk uses different users/groups than a traditional Apache install i'm having trouble figuring out how i can do this. Obviously the webserver group in Plesk is not apache but psaserv but if i create a user and add it to this group i cannot edit the file system (permission denied). if i try to switch to the user setup by plesk (the subscription user) i cannot switch to it with
Code:
su - username
in the shell. i don't get any error message just the su command doesn't work, i remain the root user.

As a workaround i can do everything as root and then switch user/group on the file system with chown and chgrp afterwards but i want to understand what the best practice is to get this to work.

Here is the instructions from the magento manual:

About the shared group

To enable the web server to write files and directories in the Magento file system but to also maintain ownership by the Magento file system owner. This is necessary so both users can share access to Magento files. (This includes files created using the Magento Admin or other web-based utilities.)

This section discusses how to create a new Magento file system owner and put that user in the web server’s group. You can use an existing user account if you wish; we recommend the user have a strong password for security reasons.

Step 1: Create the Magento file system owner and give the user a strong password
This section discusses how to create the Magento file system owner. (Magento file system owner is another term for the command-line user.)

To create a user on CentOS or Ubuntu, enter the following command as a user with root privileges:

adduser <username>
To give the user a password, enter the following command as a user with root privileges:

passwd <username>
Follow the prompts on your screen to create a password for the user.

For example, to create a user named magento_user and give the user a password, enter:

sudo adduser magento_user
sudo passwd magento_user

Step 2: Find the web server user’s group

To find the web server user’s group:

  • CentOS: egrep -i '^user|^group' /etc/httpd/conf/httpd.conf
Typically, the user and group name are both apache

Step 3: Put the Magento file system owner in the web server’s group

To put the Magento file system owner in the web server’s primary group (assuming the typical Apache group name for CentOS and Ubuntu), enter the following command as a user with root privileges:

  • CentOS: usermod -g apache <username>
For example, to add the user magento_user to the apache primary group on CentOS:

usermod -g apache magento_user

To confirm your Magento user is a member of the web server group, enter the following command:

groups <user name>

A sample result follows:

magento_user : apache

To complete the task, restart the web server:

  • CentOS: service httpd restart
Step 4: Get the Magento software
Step 5: Set ownership and permissions for the shared group

To set ownership and permissions before you install the Magento software:

  1. Log in to your Magento server as, or switch to, the Magento file system owner.
2. Enter the following commands in the order shown:

cd <your Magento install dir>

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 {} \;

chown -R :<web server group> .

chmod u+x bin/magento
Next step
Switch to the Magento file system owner
After you’ve performed the other tasks in this topic, enter one of the following commands to switch to that user:

  • CentOS: su - <username>
For example,

su magento_user

then install and configure as the magento_user adn/or perform migration of your previous magento shop.
 
Back
Top