CraftCMS exception on first install (HTTP 503 – ServiceUnavailableHttpException)

4.2k Views Asked by At

I'm trying to install CraftCMS for the first time, and appear to have gone through all the steps on the installation guide - https://docs.craftcms.com/v3/installation.html#step-1-download-craft - yet I'm getting an Exception.

HTTP 503 – Service Unavailable – craft\web\ServiceUnavailableHttpException

Here is the line (509 in /var/www/craft/vendor/craftcms/cms/src/web/Application.php) that's throwing the exception:

// Should they be accessing the installer?
if (!$isInstalled) {
    if (!$isCpRequest) {
        throw new ServiceUnavailableHttpException();
    }

Below is the call stack:

craft\web\ServiceUnavailableHttpException in /var/www/craft/vendor/craftcms/cms/src/web/Application.php:509
Stack trace:
#0 /var/www/craft/vendor/craftcms/cms/src/web/Application.php(184): craft\web\Application->_processInstallRequest(Object(craft\web\Request))
#1 /var/www/craft/vendor/yiisoft/yii2/base/Application.php(386): craft\web\Application->handleRequest(Object(craft\web\Request))
#2 /var/www/craft/web/index.php(21): yii\base\Application->run()
#3 {main}

I'm using v3.0.24 as far as I can see:

- Installing craftcms/cms (3.0.24): Downloading (100%)

As I haven't even got started with the CMS, I don't really know what more info to give - or where to go from here. The .env file has been copied, there really is no more instruction to do anything. Any ideas?

UPDATE

I've identified this section here (in /vendor/yiisoft/yii2/db/mysql/Schema.php) is returning an empty array:

protected function findTableNames($schema = '')
{
    $sql = 'SHOW TABLES';
    if ($schema !== '') {
        $sql .= ' FROM ' . $this->quoteSimpleTableName($schema);
    }

    return $this->db->createCommand($sql)->queryColumn();
}

The table have been setup, I can see them in the MySQL console. My .env db config settings seem totally fine too.

2

There are 2 best solutions below

0
On

Try the following steps for install craft3 by the terminal. create a virtual host that point to the web directory of the project setup.

composer create-project craftcms/craft
./craft setup/security-key
./craft setup

After completing the above steps, provide the permission of storage, config, web, Modules, template folder.

Admin URL: http:///index.php/admin

0
On

For those creating a fresh install using Craft CMS Nitro and its nitro create command, don't forget to run the the Setup Wizard as a final step, as described in Step 6: Run the Setup Wizard, from the Craft Docs.

This will populate the database with Craft's tables and what not and should address the 503 error.