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?