1

Hi I have downloaded my live site and want to run it locally through Mamp so that I can do an upgrade from 3.7.29 to the new craft 4. I have run craft cms locally before so I know it does work however that is usually from a fresh installation. I have the database and all files installed and I have done the usual configuration in Mamp. I have set .env to look for the local database rather than the live site and use host PRIMARY_SITE_URL=http://localhost:8888 rather than the live host. In general.php I have site url as: 'siteUrl' => 'http://localhost:8888/' rather than the live url.

When I test out to see the home page in a browser I just get a blank screen (no error) with a file download with a different name on the file each time such as 3J5BZQ7Y and when I open that file in note pad it shows these settings:

<?php
/**
 * Craft web bootstrap file
 */

// Define path constants
define('CRAFT_BASE_PATH', dirname(__DIR__));
define('CRAFT_VENDOR_PATH', CRAFT_BASE_PATH . '/vendor');

// Load Composer's autoloader
require_once CRAFT_VENDOR_PATH . '/autoload.php';

// Load dotenv?
if (class_exists('Dotenv\Dotenv') && file_exists(CRAFT_BASE_PATH . '/.env')) {
    Dotenv\Dotenv::create(CRAFT_BASE_PATH)->load();
}

// Define additional PHP constants
// (see https://craftcms.com/docs/3.x/config/#php-constants)
define('CRAFT_ENVIRONMENT', getenv('ENVIRONMENT') ?: 'production');
// ...

// Load and run Craft
/** @var craft\web\Application $app */
$app = require CRAFT_VENDOR_PATH . '/craftcms/cms/bootstrap/web.php';
$app->run();

I have tried out different php versions through Mamp to see if it could be that (everything from 5.xx upto 8.08) but still just the same downlaod file. I have also checked in terminal whether php is actually installed with php -v and it says

PHP 8.0.8 (cli) (built: Sep 30 2021 13:54:04) ( NTS )

It says this regardless of which version I choose in Mamp.

Does anyone know what I could be doing wrong please? Thanks

2 Answers 2

1

This sounds like an old issue I used to run into. I think there was an issue with MAMP that was causing it to not parse PHP files. A restart of MAMP fixed that but I found that Chrome (especially) would cache the url and continuously try to download the PHP once it had happened the first time.

The only solution I found was to completely nuke all the history and cached items I could find within Chrome. This was an exercise in frustration but normally worked after a few attempts.

I don't know what version of MAMP you are using but it's worth noting that the problem seems to have disappeared when I updated to MAMP 6

1
  • I'm using MAMP 6 and Firefox but the same happens in all other browsers. I've tried clearing cache and it doesn't fix it.
    – cannon303
    Commented Jul 6, 2022 at 14:50
1

So I managed to figure out what was happening albeit in part. When I downloaded the site files from the live server I downloaded the whole public_html folder. For some reason MAMP or the craftCMS installation didn't like this. Maybe something to do with permissions on that folder. When I renamed it and created a new public_html folder and moved the files into that things seem to start working. I now get a message: "Service Unavailable - Our site is temporarily unavailable. Please try again later." but I guess that's a separate issue.

Your Answer

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

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