To get ckeditor 4 working in Drupal 9, you have to look at the http error you get:
- 404: means the library cannot be found
- 403, 500: means an access / permission problem
Personally, I had the 404 error first.
When I tried to browse for an image on the server, the url in the window was:
libraries/civicrm/packages/kcfinder/browse.php?cms=civicrm&type=images&CKEditor=html_message&CKEditorFuncNum=0&langCode=en
But looking at the files on the server, there was no browse.php file in libraries/civicrm/packages/kcfinder
However, in my installation I could find it in vendor/civicrm/civicrm-packages/kcfinder
So I copied the kcfinder directory from vendor to libraries:
cp -r vendor/civicrm/civicrm-packages/kcfinder web/libraries/civicrm/packages
Now, the browse.php file could be found, but I got an access error.
I solved this by adding the following lines to the .htaccess file.
RewriteCond %{REQUEST_URI} !/libraries/civicrm/packages/kcfinder.*$
RewriteCond %{REQUEST_URI} !/libraries/civicrm/extern.*$
Add these lines above the line:
RewriteRule "^(.+/.*|autoload)\.php($|/)" - [F]
Next issue was that the civicrm configuration file could not be found.
The installation tries to locate the file civicrm.config.php but it was not available.
You should copy this file from a Drupal7 installation to the directory:
web/libraries/civicrm
This file tries to fill in the variable $settingsFile with the exact location of civicrm.settings.php.
For some reason, the code could not locate my file. Because I ran out of patience, I replaced:
$settingsFile = civicrm_conf_init() . '/civicrm.settings.php';
with the hard coded path of my settings file:
$settngsFile = '/var/www/ (...etc...) sites/default/civicrm.settings.php';
I would like to hear from Drupal 9 experts how this can be improved!