www 101

All you need to know about the internet

Have a Question?

If you have any question you can ask below or enter what you are looking for!

How to Install Craft CMS

Craft CMS is a system which is rapidly becoming the “go to” for web professionals. With it, you can create robust, flexible and customizable websites that are secure and simple for clients to use.

In this short video tutorial from my course on Craft CMS, we’ll step through how to install Craft CMS. We’ll cover the installation process for working offline, and along the way we’ll also look at how the installation process works for an online site.

How to Install Craft CMS

 

1. Download MAMP and Craft

As I mentioned, I’ll show you the installation process offline. But I’ll also show you what you need to do for the online version, so by the end of this tutorial you’ll know how to install Craft whether you’re working offline in a development environment, or online for deployment. 

For our offline installation and development in the course, we’re using MAMP. So if you don’t have MAMP installed on your system, head to the download page to grab a copy and install it before you move on. 

Next, go to the Craft website and hit the Download link in the top right corner to download Craft in the form of a zip. So go ahead and extract that zip, and if you look inside, you’ll see two folders: public and craft.

Craft file structure

The four files inside the public folder will go straight into your public HTML folder. So that means that only these four files will be directly accessible publicly. 

The craft folder is where your entire CMS is housed. And this folder will sit beside the public HTML folder in the same root folder. That puts it a level above all of your public files, meaning that none of the CMS files are publicly accessible. So that gives you a real security advantage right from the get-go.

2. Copy the Files Across

To start the installation process, the first thing you want to do is select all four files that are in the public folder and copy them. Then you need to find the htdocs folder inside your MAMP installation. 

With a Mac, you go to your Applications folder, you’ll find MAMP, and then inside there, you’ll find the htdocs folder. In Windows, it’s basically the same thing. Just go to your Program Files folder, locate your MAMP installation, and then locate your htdocs folder inside that. 

Now paste in the four files from your public folder that you’ve just copied. 

The htdocs folder in a MAMP installation is equivalent to the public_HTML folder in a regular web host. So if you’re installing Craft CMS on a regular web host, you’ll take those same four files and you’ll upload them to your public_HTML folder instead. 

The next thing we need to do is copy over the whole craft folder which contains the entire CMS. So select and copy your craft folder.

And now the craft folder is going go into the same root folder as your htdocs folder or your public_HTML folder. Once again, that’s putting it a level above all of your public files. 

So in this case, we’re going to paste it straight into the MAMP folder. If you’re working online and deploying via FTP, then put your craft folder in the same folder as your public_HTML folder like this.

Craft public HTML folder structure

Alternative File Structures

You might be in a scenario where it’s just not possible for you to set up your file structure in this way. So you might not be able to put your craft folder in the same folder as your public_HTML. You might, for example, be using an add-on domain, so you might be working in a subfolder inside your overall hosting account.

If that happens, it’s fine. You can actually put your craft folder wherever you want. And if you do need to put it in a non-default location, then just open up the index.php file and edit line 4 ($craftPath = '../craft';) to reflect the location of your craft folder.

3. Set Up the Database

Next, we need to set up a database for your site, and to do that, we’re going to use the phpMyAdmin tool. 

To get to that in your MAMP setup, hit Open WebStart page, and go to Tools > phpMyAdmin. If you’re working online and deploying a site then look for phpMyAdmin in your control panel. In cPanel, you’ll see it in the databases section. 

Add a User

In phpMyAdmin, the first thing we’re going to do is set up a new user. So hit the Users tab at the top and then hit Add User

When you’re setting up a live database, you want to try to make all of your user names and passwords very difficult to guess or brute force. So you basically want to use random strings of letters and numbers, but in our case we’ll keep things a bit simpler so that it’s just a little easier to demonstrate. So we’ll set the User name to craftcms. For Host, we’ll select Local. And then we’ll use the password generator.

User setup in phpMyAdmin

Grab the password, and copy and paste it into a notepad somewhere, because you’ll be using it in just a moment. 

Now we’re going to give our user global privileges, so hit the Check All button. Then scroll down and hit the Go button at the bottom of the page. And then you’ll see a message on the top saying: “You have added a new user.”

Create a New Database

Now we need a new database, so over on the left, hit the New link. Then enter the name craftcms again, and hit Create

Now if we look in the Privileges tab, you’ll see your new craftcms user that we just created, and this user has all privileges, which means that through this user you’ll be able to make the changes that you need to the database that you just set up.

Add the Details to Craft’s Config File

Now that we have our database and our user, we need to let the Craft CMS know what the details of those two are. So go to craft > config > db.php. There you can fill in the database name, the user name, and the password, following the prompts inside the file.

So now all our files are in place, our database is set up, and we’ve added the details of our database to Craft’s config. We’re ready to run the Craft installer. 

4. Run the Craft Installer

To run the installer, point your browser to the URL localhost:8888/index.php/admin. If you’re working online, just replace that local host address with your main domain name. 

From here it’s just a matter of following the prompts. It’s all fairly self-explanatory, except that by default, the site URL is going to be filled in as localhost. But for this to work on your MAMP setup, you need to make sure you have the port number on the end by adding :8888.

And then you can finish up, and just let the installer run. When it’s finished, hit Go to Craft CMS, and now your site is installed, and you should see a dashboard page that looks like this:

Dashboard page for new Craft CMS site

Conclusion

So that is how you set up a Craft CMS site. First you carry over the files, then you set up a database, you add your database details into Craft’s config, and you run the installer. 

Watch the Full Course

In the full course, Up and Running With Craft CMS, you’ll learn all the most important fundamentals for working with Craft CMS, from installation to customizing the back end and the essentials of templating.

And once you’ve got to grips with Craft CMS, you can then build on everything you’ve learned and develop a blog or a landing page from the ground up in my follow-up courses: