craftcms / cms

Build bespoke content experiences with Craft.
https://craftcms.com
Other
3.21k stars 616 forks source link

503 cpresources on migration. cpresources not being created properly? #2868

Open afridley opened 6 years ago

afridley commented 6 years ago

Description

cpresources show up as 503 error when migrating a craft 2 site

Steps to reproduce

  1. Update craft2 site to 2.6.2996
  2. Install composer require craftcms/cms:^3.0.0 in /craft directory
  3. Change index.php to
<?php

// Path to your craft/ folder
$craftPath = '../craft';

defined('CRAFT_BASE_PATH') || define('CRAFT_BASE_PATH', realpath($craftPath));

if (!is_dir(CRAFT_BASE_PATH.'/vendor')) {
  exit('Could not find your vendor/ folder. Please ensure that <strong><code>$craftPath</code></strong> is set correctly in '.__FILE__);
}

require_once CRAFT_BASE_PATH.'/vendor/autoload.php';
$app = require CRAFT_BASE_PATH.'/vendor/craftcms/cms/bootstrap/web.php';
$app->run();
  1. Go to https://www.yoursite.com/admin

You should see the craft3 installation without any styles. If you inspect console it will show all css and scripts as

GET https://www.yoursite.com/cpresources/9315f24d/jquery-ui.min.js 503 (Service Unavailable)

There is an folder structure of cpresources in the public directory. No files are in these folders. May be left from original site.

Composer seems to install the scripts not into cpresources as there is no other folder but instead to yoursite/craft/vendor/craftcms/cms/src/web/assets/

For instance Install.min.js gets GET http://www.yoursite.com/cpresources/1fb4f109/install.min.js 503 (Service Unavailable)

the file seems to be located at

yoursite/craft/vendor/craftcms/cms/src/web/assets/installer/dist

not where it is looking in cpresources

Additional info

brandonkelly commented 6 years ago

Those requests will only hit Craft/PHP if the files weren’t published correctly to begin with.

So I’m guessing either your cpresources/ folder doesn’t exist yet, or PHP doesn’t have execute + write permissions on it.

afridley commented 6 years ago

Hmm I tried changing the permissions and that didn't seem to do anything.

Whats odd is it creates cpresources in the /public directory.

If I manually move this to the base directory /var/www then I am able to install craft. It doesn't update the site but instead installs craft 3 alongside the craft2 installation

If I switch back to

$path = rtrim($craftPath, '/').'/app/index.php';

if (!is_file($path)) {
    if (function_exists('http_response_code')) {
        http_response_code(503);
    }

    exit('Could not find your craft/ folder. Please ensure that <strong><code>$craftPath</code></strong> is set correctly in '.__FILE__);
}

require_once $path;

I can see the craft2 site again.

brandonkelly commented 6 years ago

Sorry I missed that you are installing Craft 3 in a craft/ subdirectory. Just so we’re on the same page, can you post a screenshot of your full directory structure?

akshayagarwal commented 5 years ago

I was facing a similar issue but in my case the files were not published properly due to a PHP memory limit fault while installing a plugin. I deleted all of the files in the cpresources/ directory and pointed to /admin which created all those files back properly.