Directus can't be installed on a shared hosting
Asked Answered
S

2

11

I'm trying to setup 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.

According to the console, many resources cannot be reached:

  • 404: /_/users/me?fields=last_page:1
  • 401: /interfaces:1
  • 401: /layouts:1
  • 401: /pages:1
  • 403: /_/collections:1
  • 403: /_/settings:1
  • 401: (API root)
  • 403: /_/collection_preset...
  • 403: /_/users?field...
  • 403: /_/relations?limit=1

MySQL version (5.7) and PHP version (7.3) meet the requirements for 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
Schoolfellow answered 28/8, 2019 at 7:56 Comment(2)
I just gave up with OVH. I lost so much time to make it work on a Pro hosting and a WebCloud. I went to Infomaniak, with absolutely no problem at all!Schoolfellow
What have you tried to debug the problem?Confessional
B
0

I had some problems on a shared hosting as well after i did 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). 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.

Bourke answered 9/7, 2020 at 12:57 Comment(0)
D
0

The blockers I have found while requesting the installed app on shared hosting.

  • The name of the app needs to be present in the API call (as Directus can handle multiple apps with the same instance).

  • The collections you want to reach outside of the Admin needs to have a public role to be accessible.

  • Also, adding RewriteBase / under the line of RewriteEngine On in my public/.htaccess did the trick on Ionos/1and1 shared hosting. Without this line, the rewriting wasn't performing and was returning a 500 error.

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>

All the other steps I have done to install on my shared hosting (ionos/1and1) which handles SSH:

Env:

Create PHP 7.4+ env

Create Mysql 5.2+ Db

Download Directus Suite and push to FTP from https://github.com/directus/directus or from ssh git clone [email protected]:directus/directus.git

Push to FTP or git clone.

Bind the admin (sub)domain name to /public folder.

Set execute rights on the folder /bin recursively: $ chmod -R +x ./bin

Set the write permission for the folders /logs and /public/uploads:

  • $ chmod -R +w /logs
  • $ chmod -R +w /public/uploads

Installing dependencies:

Connect to ssh console and navigate to the root folder of Directus

Download Composer: $ curl -sS https://getcomposer.org/installer | /usr/bin/php7.4-cli

Check Composer install: $ /usr/bin/php7.4-cli composer.phar

Check latests version: $ /usr/bin/php7.4-cli composer.phar selfupdate

Install dependencies: $ /usr/bin/php7.4-cli composer.phar install

Create project:

You can go to the URL https://admin.mysite.com/admin/#/install or setup the project with the following command-line interface:

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

Populate the Database Schema: $ /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

Digamy answered 10/11, 2020 at 7:51 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.