uvdesk / community-skeleton

UVdesk Opensource Community Helpdesk Project built for all to make a Full Ticketing Support System along with many more other features.
https://www.uvdesk.com
MIT License
7.32k stars 452 forks source link

Cannot install due to wrong directory permissions #603

Open ProCycleDev opened 1 year ago

ProCycleDev commented 1 year ago

Bug report

Title

Cannot install due to wrong directory permissions

Issue Description

Using the directions provided in the README file using composer create-project the configuration step fails due to some directories needing write permissions. Some of these are documented elsewhere, but not in the README file. They recommend setting 775 on .env, var, config. However write permissions are also required on migrations else the installation fails with a non-specific error like in #290

Preconditions

Have a hosting environment that is configured so that files are owned by a user that is not the webserver (standard security practice). Files have a group set that the webserver is a member of. Any file that the webserver is allowed to write to as part of normal operation has the permissions 775. Any file the webserver should not have write permission to is 755.

Steps to reproduce

  1. Follow the installation instructions using composer
  2. Attempt to install using either the console or the web interface

Expected result

Installation completes successfully

Actual result

Installation fails due to permission issues. If the directions in the blog post are used then installation starts but fails at step 4 with an error 119844965-14e94000-bf33-11eb-8689-9236cece9cb1

Suggestions to address issue

  1. Fix blog post instructions. The migrations directory also needs to be writeable or installation will fail.
  2. Add note about write permissions in the README.md file
  3. Add note about write permissions in the documentation
  4. Ideally, set file permissions in the repository so they are automatically set upon download of the project and no intervention is needed by the user. Currently .env and config is set to group writable in the git repo but not the files that are generated in the subdirectory config/packages. The var and migrations folder is not in this repo and I am uncertain where it comes from but the permissions on that directory should be set to group writable too.

Sample

For installation to succeed the config/packages, var/ and migrations/ directory and files within need to be writable by the webserver. chmod -R ug=rwX,g=rX config/packages var/ migrations/

komal-sh-27 commented 1 year ago

@ProCycleDev Do you have still this issue?

Once check the below cases:

=> It happens mainly because of less execution time in the php.ini file. By default, max_execution_time is 30 sec you need to increase it and restart your server.

Check here how to increase max-execution time.

Also, provide write permission for .env file in your project.

Then finally try to set up your project.

=> Provide read/write permission for the below folders:

For var folder -chmod 777 -R path of var folder of UVdesk project For config folder – chmod 777 -R path of config folder of UVdesk project For public folder – chmod 777 -R path of the public folder of UVdesk project

If you still facing the same issue, let us know.

ProCycleDev commented 1 year ago

This is a bug report about documentation not a support request. I have identified the source of the issue and it is the permissions on the migrations folder that has been missed in all of the documentation. In addition there are three places where the install process is documented and only one mentions permissions.

navjotjsingh commented 1 year ago

Thank you. After hours of troubleshooting, this is the only thing that worked for me. The permissions on the migrations folder need to be set as well for the installation to work. Please add this to the documentation.

Sanjaybhattwebkul commented 1 year ago

Hi @ProCycleDev Thanks for reporting, we will add this step to our documentation.

joshlopes commented 1 year ago

I'm having the same issue but setting permissions does not fix the issue. migrations is empty and he thinks that the db is up to date -- I've spent hours debugging the issue -- the demo looks nice -- Instalattion? Horrible...

Examining helpdesk setup for any configuration issues:

  [-] Establishing a connection with database server
  [v] Successfully established a connection with database cosmosrescue

  [-] Comparing the cosmosrescue database schema with the current mapping metadata.
  [v] The current database schema is up-to-date with the current mapping metdata.

  [-] Checking if an active super admin account exists
{"message":"Error thrown while running command \"uvdesk:configure-helpdesk\". Message: \"SQLSTATE[42S02]: Base table or view not found: 1146 Table 'cosmosrescue.uv_support_role' doesn't exist\"","context":{"exception":{"class":"PDOException","message":"SQLSTATE[42S02]: Base table or view not found: 1146 Table 'cosmosrescue.uv_support_role' doesn't exist","code":42,"file":"/srv/src/Console/Wizard/ConfigureHelpdesk.php:242"},"command":"uvdesk:configure-helpdesk","message":"SQLSTATE[42S02]: Base table or view not found: 1146 Table 'cosmosrescue.uv_support_role' doesn't exist"},"level":500,"level_name":"CRITICAL","channel":"console","datetime":"2022-10-09T18:20:45.670538+00:00","extra":{}}
18:20:45 CRITICAL  [console] Error thrown while running command "uvdesk:configure-helpdesk". Message: "SQLSTATE[42S02]: Base table or view not found: 1146 Table 'cosmosrescue.uv_support_role' doesn't exist" ["exception" => PDOException { …},"command" => "uvdesk:configure-helpdesk","message" => "SQLSTATE[42S02]: Base table or view not found: 1146 Table 'cosmosrescue.uv_support_role' doesn't exist"]
{"message":"Command \"uvdesk:configure-helpdesk\" exited with code \"1\"","context":{"command":"uvdesk:configure-helpdesk","code":1},"level":100,"level_name":"DEBUG","channel":"console","datetime":"2022-10-09T18:20:45.683380+00:00","extra":{}}
joshlopes commented 1 year ago

On localhost it fails on database migration: image

So clearly it's a problem with the database and I have no clue where I can fetch it 🙈

komal-sh-27 commented 1 year ago

@joshlopes

Check the below these cases and make changes accordingly:

  1. A web server might don't have permission to allow overriding of the Apache config on a per-directory basis. Allow Override needs to be set to All for the directory block as mentioned below:
<Directory /home/users/var/www/htdocs>
Options Indexes FollowSymLinks
AllowOverride All
Require all granted
  1. If your database password contains some special character(such as #$%@) then change your password and make it without special characters.

locate the .env file in your project and make sure APP_ENV=dev when you are doing your setup.

  1. Allow read-write permission for the below file & folder:

For .env file – chmod 777 -R path of .env file of UVdesk project For Var folder -chmod 777 -R path of var folder of UVdesk project For Config folder – chmod 777 -R path of config folder of UVdesk For Public folder – chmod 777 -R path of the public folder of UVdesk For Migration folder – chmod 777 -R path of the migration folder of UVdesk

  1. It happens mainly because of less execution time in the php.ini file. By default, max_execution_time is 30 sec you need to increase it and restart your server.

Check here how to increase max-execution time. Restart your server.

And clear your project cache by: php bin/console c:c Now try to install your project.

=> Also, run the below commands in your project root directory:

php bin/console doctrine:migrations:diff

php bin/console doctrine:migrations:migrate

And clear the cache of the project:

php bin/console c:c

=> Once you try with the manual installation of uvdesk from here.

If the issue is still in the manual installation setup, let us know.

alexacron commented 1 year ago

I can confirm that migrations/ need to be mentioned in the documentation as well as in the verification step during the installation. I got the error and fixed it by looking for clues in the log file:

`tail -100 var/log/dev.log |grep CRITICAL

[2022-10-25T13:08:58.312965+00:00] console.CRITICAL: Error thrown while running command "uvdesk_wizard:database:migrate". Message: "Warning: file_put_contents(/..../migrations/Version20221025130858.php): failed to open stream: Permission denied" {"exception":"[object] (ErrorException(code: 0):`