So... I've installed Craft online, and I wanted to start templating my CraftCMS, but I'd like to work with a repository so I can have some kind of versioning. The easiest way to do so seemed to me to install Craft on our hosting server, download those files locally and connect to the online database using MAMP pro. I had some issues with our host (I had to whitelist my IP address), but now I can connect to the database using Sequel Pro, but when I try to access my craft CMS site through my local files I get the Craft message "service unavailable". My Mamp Pro is pointed to my public folder (2 folders in my site: public and craft, and it's pointed to this public folder with the index file in it) and I've used the same db settings as the ones I've used in Sequal Pro. Still: no succes. The only thing I've changed after downloading the site are these db setting for the host - as I had to do in Sequal Pro. Can anyone help a newbie in Craft CMS out here :-)? Thanks!
Here is how I have set things up in the past using a similar workflow.
When you get Craft out of the box (for lack of better words) as you said there is a
craft folder and a
public folder. Generally you want your
craft folder above/out of your web root. That would look something like this:
craft/ |- app |- config ... public/ |- index.php |- robots.txt
When setting up your site, point your
doc_root to the
For example, if you are using a Mac, a default
doc_root might look like this:
<VirtualHost *:80> ServerName sitename.dev DocumentRoot "/Applications/MAMP/htdocs/sitename/public" </VirtualHost>
If successful, you should see a screen saying that your site is unavailable. I can't remember the exact verbiage.
From there I will edit two files:
return array( '*' => array( // Global configuration 'tablePrefix' => '' ), '.dev' => array( // local configuration 'server' => '127.0.0.1', 'user' => 'username', 'password' => 'password', 'database' => 'database' ), '.com' => array( // production configuration 'server' => 'hostname', 'user' => 'username', 'password' => 'password', 'database' => 'database' ) );
return array( '*' => array( 'cpTrigger' => 'your-custom-admin-url', 'omitScriptNameInUrls' => true ), '.dev' => array( // local configuration 'devMode' => true, 'siteUrl' => 'http://mysite.dev/', 'environmentVariables' => array( 'basePath' => $_SERVER['DOCUMENT_ROOT'] . '/', 'baseUrl' => 'http://mysite.dev/', ) ), '.com' => array( // production configuration 'siteUrl' => 'http://www.mysite.com/', 'environmentVariables' => array( 'basePath' => $_SERVER['DOCUMENT_ROOT'] . '/', 'baseUrl' => 'http://www.mysite.com' ) ) );
By having the multi-environment settings like the above, you can commit your code and it will run regardless of environment.
Generally, I like to have a local database which is separate from my production db. My luck, I'll do something silly and delete something on accident. Depending on how big of changes you are making post-launch, I am sure there are good/better/best ways to migrate the updates to your production db vs. manually entering it. But, if they are simple things (added a new field) I usually just do that manually on my production server.
It sounds like if you can connect to your production db via a 3rd party tool, but not your application there might be some permission trouble (just a guess). Try working locally with everything first, then move it to your other server.
Hope this helps!