Novice dev here, really struggling to get my local setup functioning. After a couple of days of wrestling with Apache config settings, I finally have Craft connecting via a VHOST setup. The problem –
Craft can’t connect to the database with the credentials in craft/config/db.php.
This should all be tried and tested as it came from my lead dev on this project and had been working, so it is likely something silly I have done in the set up. I just can't figure out what.
Thus far, I have downloaded the repo, installed all dependencies and have successfully got the local server running with npm run start. I've configured a Virtual Host and that's all running fine. I downloaded a copy of the production db from the live site and uploaded it to my local db (connect via Sequel Pro). Both db's have the same name.
My db.php file is:
return array( // The database server name or IP address. Usually this is 'localhost' or '127.0.0.1'. 'server' => $_SERVER['DATABASE_HOST'], // The name of the database to select. 'database' => $_SERVER['DB_NAME'], // The database username to connect with. 'user' => 'root', // The database password to connect with. 'password' => $_SERVER['DB_PASSWORD'], // The prefix to use when naming tables. This can be no more than 5 characters. 'tablePrefix' => 'craft',
My VHOST is:
<VirtualHost *:80> SetEnv DATABASE_HOST localhost SetEnv DB_NAME dbName SetEnv DB_PASSWORD dbPassword SetEnv DEV_MODE true SetEnv SITE_URL sitename.local SetEnv DB_PORT 3306 DocumentRoot "/Users/username/Sites/sitename/public" ServerName www.sitename.local ServerAlias www.sitename.local ErrorLog "/Users/username/Sites/sitename/error_log" CustomLog "/Users/username/Sites/sitename/access_log" common <Directory "/Users/username/Sites/sitename/public"> Options Indexes FollowSymLinks Includes ExecCGI AllowOverride All Require all granted </Directory> </VirtualHost>
I'm stumped. The only think I have been able to find on similar threads seems to point to db version issues (which might be the case but I don't know how to check).
Does anyone have any ideas?