简体   繁体   English

drupal 更新后站点抛出 HTTP ERROR 500

[英]After drupal update site throws HTTP ERROR 500

I updated drupal from 9.2.7 to latest version using composer.我使用 composer 将 drupal 从 9.2.7 更新到最新版本。 The update was completed but the site throws "This site currently unable to handle this request.HTTP ERROR 500" I changed the owner as "sudo chown -R username:groupname <drupal_directory>" with backup's username and password.更新已完成,但站点抛出“此站点当前无法处理此请求。HTTP 错误 500”我将所有者更改为“sudo chown -R 用户名:组名 <drupal_directory>”,并使用备份的用户名和密码。 But no use.但是没有用。 I applied "chmod 755 -R <drupal_directory>" and the site loaded.我应用了“chmod 755 -R <drupal_directory>”并加载了站点。 But am getting permission errors when I tried a new update with composer.但是当我尝试使用 composer 进行新的更新时出现权限错误。 I am sure this problem is because of permission but what is the proper way to fix this problem?我确定这个问题是因为许可,但解决这个问题的正确方法是什么?

Generally, I create some bash script so that I can run it every time I run some updates or make any change to the Drupal installation.通常,我会创建一些 bash 脚本,以便我可以在每次运行某些更新或对 Drupal 安装进行任何更改时运行它。

The script may be something like:该脚本可能类似于:

#!/bin/bash

# site directory
site_directory="/path/to/drupal/installation" # full path to drupal installation

# user and group
user_name="user_name" # root is a good choice
group_name="group_name" # nginx, www-data, apache, etc., depending on the installed web server 

# reset user and group
chown -R ${user_name}:${group_name} ${site_directory}/

# reset general permitions
find ${site_directory} -type d -exec chmod u=rwx,g=rx,o= '{}' \;
find ${site_directory} -type f -exec chmod u=rw,g=r,o= '{}' \;

# reset files permitions
find ${site_directory}/web/sites/default/files/ -type d -exec chmod ug=rwx,o= '{}' \;
find ${site_directory}/web/sites/default/files/ -type f -exec chmod ug=rw,o= '{}' \;

# reset general selinux context (comment if not running selinux)
chcon -R system_u:object_r:httpd_sys_content_t:s0 ${site_directory}/

# reset files selinux context (comment if not running selinux)
chcon -R -t httpd_sys_rw_content_t ${site_directory}/web/sites/default/files/

Of course, clearing the caches is also a good idea.当然,清除缓存也是一个好主意。

Yes.是的。 The above script, sets permissions in a, somewhat, restrictive way.上面的脚本以某种限制性的方式设置了权限。

Namely, I feel uncomfortable, setting execute permissions to drush.即,我感到不舒服,将执行权限设置为 drush。

Any time I need to run drush, I specifically set execution permissions to drush:每当我需要运行 drush 时,我都会专门设置 drush 的执行权限:

cd /path/to/drupal/installation
chmod 700 vendor/bin/drush

Then, I can run the necessary drush commands.然后,我可以运行必要的 drush 命令。

If You find this tedious, just add:如果你觉得这很乏味,只需添加:

chmod 700 ${site_base_directory}/vendor/bin/drush

at the end of the script above.在上面脚本的末尾。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM