[英]Directus can't be installed on a shared hosting
I'm trying to setup Directus.我正在尝试设置 Directus。
I just performed a brand new install following the guidelines described in the documentation.我刚刚按照文档中描述的指南执行了全新的安装。 However once I login, I have this error: "Server Error - Something is wrong with this instance's server or database."
但是,一旦我登录,就会出现此错误:“服务器错误 - 此实例的服务器或数据库出现问题。”
A UI would be expected instead with this message: "No Collections Setup - It seems like there aren't any collections setup yet"预期用户界面会显示以下消息:“没有收藏集设置 - 似乎还没有任何收藏集设置”
The installation works fine on localhost with WAMP, so I suspect that something on the shared host or the database is misconfigured.使用 WAMP 在 localhost 上安装工作正常,所以我怀疑共享主机或数据库上的某些内容配置错误。
According to the console, many resources cannot be reached:根据控制台,很多资源无法访问:
/_/users/me?fields=last_page:1
/_/users/me?fields=last_page:1
/interfaces:1
/interfaces:1
/layouts:1
/layouts:1
/pages:1
/pages:1
/_/collections:1
/_/collections:1
/_/settings:1
/_/settings:1
(API root)
(API root)
/_/collection_preset...
/_/collection_preset...
/_/users?field...
/_/users?field...
/_/relations?limit=1
/_/relations?limit=1
MySQL version (5.7) and PHP version (7.3) meet the requirements for Directus... MySQL 版本 (5.7) 和 PHP 版本 (7.3) 满足 Directus...
I really don't know what to look for to diagnose any compatibility issue with the shared hosting...我真的不知道要寻找什么来诊断与共享主机的任何兼容性问题...
EDIT编辑
Here is the log (without the stacks):这是日志(没有堆栈):
[2019-08-28 11:31:24] api[_].ERROR: Directus\Database\Exception\ItemNotFoundException: Item not found in [server root path]/directus/src/core/Directus/Services/ItemsService.php:139
[2019-08-28 11:31:29] api[_].ERROR: Directus\Database\Exception\ItemNotFoundException: Item not found in [server root path]/directus/src/core/Directus/Services/ItemsService.php:139
[2019-08-28 11:31:29] api[].ERROR: Directus\Exception\UnauthorizedException: Unauthorized request in [server root path]/directus/src/helpers/app.php:268
[2019-08-28 11:31:29] api[].ERROR: Directus\Exception\UnauthorizedException: Unauthorized request in [server root path]/directus/src/helpers/app.php:268
[2019-08-28 11:31:29] api[_].ERROR: Directus\Permissions\Exception\ForbiddenCollectionReadException: Reading items from "directus_collections" collection was denied in [server root path]/directus/src/core/Directus/Permissions/Acl.php:988
[2019-08-28 11:31:29] api[_].ERROR: Directus\Permissions\Exception\ForbiddenCollectionReadException: Reading items from "directus_settings" collection was denied in [server root path]/directus/src/core/Directus/Permissions/Acl.php:988
[2019-08-28 11:31:29] api[].ERROR: Directus\Exception\UnauthorizedException: Unauthorized request in [server root path]/directus/src/helpers/app.php:268
[2019-08-28 11:31:29] api[_].ERROR: Directus\Permissions\Exception\ForbiddenCollectionReadException: Reading items from "directus_collection_presets" collection was denied in [server root path]/directus/src/core/Directus/Permissions/Acl.php:988
[2019-08-28 11:31:29] api[].ERROR: Directus\Exception\UnauthorizedException: Unauthorized request in [server root path]/directus/src/helpers/app.php:268
[2019-08-28 11:31:29] api[_].ERROR: Directus\Permissions\Exception\ForbiddenCollectionReadException: Reading items from "directus_relations" collection was denied in [server root path]/directus/src/core/Directus/Permissions/Acl.php:988
[2019-08-28 11:31:29] api[_].ERROR: Directus\Permissions\Exception\ForbiddenCollectionReadException: Reading items from "directus_collection_presets" collection was denied in [server root path]/directus/src/core/Directus/Permissions/Acl.php:988
[2019-08-28 11:31:29] api[_].ERROR: Directus\Permissions\Exception\ForbiddenCollectionReadException: Reading items from "directus_users" collection was denied in [server root path]/directus/src/core/Directus/Permissions/Acl.php:988
@yako - Can you please check ping
endpoint once? @yako-您能一次检查
ping
端点吗? If the server is set up correctly it will respond with pong
as plain text. 如果服务器设置正确,它将以
pong
作为纯文本响应。
I had some problems on a shared hosting as well after i did git clone.在我执行 git clone 之后,我在共享主机上也遇到了一些问题。
Somehow after scratching my head for a while is just ran composer install
in the directus base dir and voila it worked (v8).不知何故,在我挠头一段时间后,只是在 Directus 基本目录中运行了
composer install
,瞧它起作用了(v8)。 I was able to install as its written in the docs.我能够按照文档中的说明进行安装。
My assumption is the composer install
action is setting/correcting some folders permission and/or dependencies.我的假设是
composer install
操作正在设置/更正某些文件夹权限和/或依赖项。
The name of the app needs to be present in the API call (as Directus can handle multiple apps with the same instance).应用程序的名称需要出现在 API 调用中(因为 Directus 可以处理具有相同实例的多个应用程序)。
The collections you want to reach outside of the Admin needs to have a public role to be accessible.您想要在 Admin 之外访问的集合需要具有公共角色才能访问。
Also, adding RewriteBase /
under the line of RewriteEngine On
in my public/.htaccess
did the trick on Ionos/1and1 shared hosting.此外,在我的
public/.htaccess
的RewriteEngine On
行下添加RewriteBase /
对 Ionos/1and1 共享主机也有帮助。 Without this line, the rewriting wasn't performing and was returning a 500 error.如果没有这一行,重写将不会执行并返回 500 错误。
Eg:例如:
# Comment this line if you are getting: "Option SymLinksIfOwnerMatch not allowed here" error in Apache
Options +SymLinksIfOwnerMatch
# php5_module automatically handles HTTP_AUTHORIZATION headers, but fcgi_module does not.
<IfModule mod_setenvif.c>
<IfModule mod_proxy_fcgi.c>
SetEnvIfNoCase ^Authorization$ "(.+)" HTTP_AUTHORIZATION=$1
</IfModule>
</IfModule>
<ifModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
# Map all admin endpoints to the admin app (except static files)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^admin/(.*) admin/index.html [NC,L]
# Map all other requests to invoke the API router (except static files)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule !^admin index.php?%{QUERY_STRING} [L]
</ifModule>
# Uncomment the following lines to modify PHP settings. The lines below can be used to increase the max upload size of files in Directus
#<IfModule mod_php7.c>
#php_value upload_max_filesize 50M
#php_value post_max_size 100M
#</IfModule>
Create PHP 7.4+ env创建 PHP 7.4+ 环境
Create Mysql 5.2+ Db创建 Mysql 5.2+ 数据库
Download Directus Suite and push to FTP from https://github.com/directus/directus or from ssh git clone git@github.com:directus/directus.git
下载 Directus Suite 并从https://github.com/directus/directus或从 ssh
git clone git@github.com:directus/directus.git
directus.git 推送到 FTP
Push to FTP or git clone.推送到 FTP 或 git clone。
Bind the admin (sub)domain name to /public
folder.将管理(子)域名绑定到
/public
文件夹。
Set execute rights on the folder /bin
recursively: $ chmod -R +x ./bin
递归设置文件夹
/bin
执行权限: $ chmod -R +x ./bin
Set the write permission for the folders /logs
and /public/uploads
:设置文件夹
/logs
和/public/uploads
的写权限:
$ chmod -R +w /logs
$ chmod -R +w /public/uploads
Connect to ssh console and navigate to the root folder of Directus连接到 ssh 控制台并导航到 Directus 的根文件夹
Download Composer: $ curl -sS https://getcomposer.org/installer | /usr/bin/php7.4-cli
下载 Composer:
$ curl -sS https://getcomposer.org/installer | /usr/bin/php7.4-cli
$ curl -sS https://getcomposer.org/installer | /usr/bin/php7.4-cli
Check Composer install: $ /usr/bin/php7.4-cli composer.phar
检查 Composer 安装:
$ /usr/bin/php7.4-cli composer.phar
Check latests version: $ /usr/bin/php7.4-cli composer.phar selfupdate
检查最新版本:
$ /usr/bin/php7.4-cli composer.phar selfupdate
Install dependencies: $ /usr/bin/php7.4-cli composer.phar install
安装依赖:
$ /usr/bin/php7.4-cli composer.phar install
You can go to the URL https://admin.mysite.com/admin/#/install
or setup the project with the following command-line interface:您可以访问 URL
https://admin.mysite.com/admin/#/install
或使用以下命令行界面设置项目:
Configure Directus: $ /usr/bin/php7.4-cli bin/directus install:config -k my-project -h db_host -n db_name -u db_user -p db_pass -d directus_path -a super_admin_token
配置 Directus:
$ /usr/bin/php7.4-cli bin/directus install:config -k my-project -h db_host -n db_name -u db_user -p db_pass -d directus_path -a super_admin_token
Populate the Database Schema: $ /usr/bin/php7.4-cli bin/directus install:database -d directus_path
填充数据库架构:
$ /usr/bin/php7.4-cli bin/directus install:database -d directus_path
Install Initial Configurations: $ install:install -e admin_email -p admin_password -t site_name
安装初始配置:
$ install:install -e admin_email -p admin_password -t site_name
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.