0

I'm puzzled why, for a fresh CiviCRM install on WordPress, the URL variable [civicrm.files] is set incorrectly, resulting in some out-of-the-box broken behavior. Specifically:

I "successfully" installed CiviCRM v.4.7.30 on WordPress v.4.9.4. I got some pop-up warnings and jumped to the "System Status" screen, which was blank except for System Status: Error in the footer.

When I "inspected" the web page, I found "404 file not found errors" for some angular-modules... files, for example https://crm.staging.myorganization.org/home/myorganization/sites/staging/crm.myorganization.org/wp-content/uploads/civicrm/persist/contribute/dyn/angular-modules.e0e4119919ee72acc13134f3f09d77c0.js was not found.

After some digging, the tip to go to Administer -> System Settings -> Debugging and disabling the "Asset Cache" (from https://civicrm.stackexchange.com/a/19597/5790) made the "System Status" screen work. Yay! But that's not a good production solution.

Digging further, I found that URL variables were set to the following. The [civicrm.files] value is incorrect.

URL Variables
[cms.root] https://crm.staging.myorganization.org/
[civicrm.root] https://crm.staging.myorganization.org/wp-content/plugins/civicrm/civicrm/ [civicrm.files] https://crm.staging.myorganization.org/home/myorganization/www/sites/staging/crm.myorganization.org/wp-content/uploads/civicrm/

However all of the Path variables were correct:

Path Variables
[cms.root] /home/myorganization/www/public_html/sites/staging/crm.myorganization.org
[civicrm.root] /home/myorganization/www/sites/staging/crm.myorganization.org/wp-content/plugins/civicrm/civicrm
[civicrm.files] /home/myorganization/www/sites/staging/crm.myorganization.org/wp-content/uploads/civicrm

On the Administer -> System Settings -> Resource URLs, the default values include the following:

Image Upload URL [civicrm.files]/persist/contribute/
Extension Resource URL [civicrm.files]/ext/

It is the use of the invalid [civicrm.files] value here that resulted in the blank "System Status" screen. Once I changed these to the correct absolute URL, the "System Status" screen worked fine, even after I changed Administer -> System Settings -> Debugging -> Asset Cache back to the default "auto" setting.

Why is [civicrm.files] set to this odd incorrect value, when [civicrm.root] is perfectly fine? This is confusing for a CiviCRM newcomer (such as myself). Of all things, the "System Status" screen should be able to report the issues for the fresh install.


To clarify the installed folder structure:

The $_SERVER['DOCUMENT_ROOT'] is /home/myorganization/www/public_html, but I've created a folder structure under /home/myorganization/www/sites for test, staging, and production folders for various sites. The ~/www/sites folder is symlinked into /home/myorganization/www/public_html. I've created a custom __index.php__ file that gives the values of various PHP variables:

Full URL= https://crm.staging.myorganization.org/index.php
$_SERVER['DOCUMENT_ROOT']= /home/myorganization/www/public_html $_SERVER['PHP_SELF']= /sites/staging/crm.myorganization.org/index.php
$_SERVER['SCRIPT_NAME']= /sites/staging/crm.myorganization.org/index.php
$_SERVER['SCRIPT_FILENAME']= /home/myorganization/www/public_html/sites/staging/crm.myorganization.org/index.php
realpath( $_SERVER['SCRIPT_FILENAME'])= /home/myorganization/www/sites/staging/crm.myorganization.org/index.php
getcwd()= /home/myorganization/www/sites/staging/crm.myorganization.org
__FILE__= /home/myorganization/www/sites/staging/crm.myorganization.org/index.php

Bonus Question

After fixing the above, the "System Status" screen still complains "Incorrect Resource URL: The Resource URL is not set correctly. Please set the CiviCRM Resource URL." Why?

1

2 Answers 2

0

The issue is that the file structure you are using is not accounted for in the installer.

We've covered the standard directory structures and detect them, however there are some use cases that we have not been able to both detect and set programmatically. In these cases, you will need to override the values.

In your case you needed to override the URLs as the [civicrm.files] URL is appending /home/myorganization/www/sites/staging/crm.myorganization.org to the URL.

I have seen this before (mostly with symlinks or if both WP is installed in it's own directory AND wp-content has been moved). Can you let us know who your host is and confirm your configuration?

1
  • Hi Kevin. I've edited the original post providing details on the installed folder structure. This is a self-installed structure intended to support side-by-side production, staging, and test installs. It's hosted by A2 Hosting.
    – Martin_W
    Mar 2, 2018 at 21:19
0

This happened to me and is a common issue - especially on shared hosts. Solution is to add the correct information in your civicrm.settings.php file.

Try placing the following in the overrides section of your civicrm.settings.php file.

global $civicrm_paths;
$civicrm_paths['civicrm.files'] = array(
  'url' => 'https://crm.staging.myorganization.org/wp-content/uploads/civicrm/',
  'path' => '/home/myorganization/www/sites/staging/crm.myorganization.org/wp-content/uploads/civicrm',
);

More info can be found in this answer.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.