2.2 Installing Craft CMS
To get the ball rolling, we’ll step through how to install Craft CMS. We’ll be working offline for this course, but in this lesson we’ll also cover how the installation process applies for an online site.
1.Introduction1 lesson, 01:04
2.Up and Running With Craft CMS9 lessons, 43:24
3.Conclusion1 lesson, 01:35
2.2 Installing Craft CMS
Hey, welcome back to Up and Running with Craft CMS. In this lesson we're gonna get the ball rolling by going through how you install Craft CMS. Now throughout this course we're gonna be working offline, so I'm gonna show you the installation process offline. But it does work the same way online. So by the end of this course 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 throughout the course, we're gonna be using MAMP. So if you don't have MAMP installed on your system, head to MAMP.info/en/downloads. Grab a copy and install it before you move on with the rest of the course. At the end of the last lesson you downloaded Craft in the form of a zip. So go ahead and extract that zip now. And if you look inside, you're gonna see two folders. You have this public folder here, and you have Craft here. And the files that are inside the public folder, these four files only, they're gonna go straight into your public HTML folder. So that means that only these four files will be directly accessible publicly. In the Craft folder, this is where your entire CMS is housed. And this Craft folder is gonna sit side by side 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 files at the CMS are publicly accessible. So that gives you a real security advantage right from the get-go. To start the installation process, the first thing you wanna 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 gonna 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 gonna paste it straight in to 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. Hey, you might also be in a scenario where it's just not possible for you to set up your Craft file structure in this way. So you might not be able to put your Craft folder in the same folder as your public HTML. Say, for example, you might 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 then, you can edit line four here to reflect the location of your Craft folder. Next we need to set up a database for your site and to do that, we're gonna use the phpMyAdmin tool. Now to get to that in your MAMP setup, hit this Open WebStart > Tools > phpMyAdmin. If you're working online and deploying a site then look for phpMyAdmin in your control panel. In C panel, you'll see it in the databases section. All right, so now in phpMyAdmin, the first thing we're gonna do is set up a new user. So hit the Users tab up here and then hit Add User. And when you're setting up a live database, you wanna try to make all of your user names and passwords very difficult to guess or brute force. So you basically wanna use random strings of letters and numbers, but in our case we wanna keep things a bit simpler so that it's just a little easier to demonstrate. So we're gonna set username to craftcms. For host, we're gonna select local. And then we'll use the password generator. Now grab that, copy and paste that into a notepad somewhere, because you'll be using it in just a moment. Now we're gonna give our user global privileges. So hit this Check All here. And now scroll down and hit the Go button. And then you'll see this message on the top saying that you've added a new user, so that's been done successfully. Now we need a new database, so over on the left hit this New link here, then in this field give your database a name, we'll just use craftcms again. And then hit Create. Now if we look in the Privileges tab here, you can see that we have our craftcms user that we just created and this user has all privileges, which means through this user you'll be able to make the changes that you need to the database that you just set up. 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 into your Craft > Config > db.php. Now we'll fill in our database name which was craftcms. We'll add the user for our database which was also craftcms. And finally, we'll add the password which you should have in a little notepad somewhere. All right, 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. Now we're ready to run the Craft installer. Now back in our browser, you wanna point your browser to the URL localhost :8888/index.php/admin. Now if you're working online, just replace that local host address with your main domain name. So from here it's just a matter of following the prompts. So it's all fairly self-explanatory, so just set yourself up a username. And once again if you're working online make sure that your username is not something that's easy to guess or brute force. For our little demo though, we'll just use admin. So then add in an email address and set up a password. Now give your site a name. Now by default, the site URL is gonna be filled in as local host. 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 we can finish up. And we'll just let the installer run. And then when it's finished, hit Go to Craft CMS, And now your site is installed. If you wanna have a look at the front end, then just up on the top left here, open up in a new tab, and there's our front end. 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. In the next lesson, we're gonna start looking at how Craft works in the backend. And it's a little bit different to other systems that you might have worked with in the past because it's designed for you to create the ideal system for your clients or for yourself from the ground up. So in the next lesson we're gonna have a look at how Craft organizes content. We'l learn a bit of the terminology, and we'll make sure that you have a grasp of how all of these things work together before we start actually creating a custom backend. So I'll see you in the next lesson.