How to install Craft CMS to a web server. Part 2. Craft CMS install

Categories: Code

Tags: ,

Craft CMS 3 can be installed and updated by Composer. So in Part 2, we will use the Composer to install the Craft to a web server using a

If you don’t have the Composer installed on your web server, please read my previous post first.

As mentioned in my previous post I am new to Craft, and it took a few attempts to install and make it work on my web server. So if you are new to Craft as I am, and trying to install it on a web server, hopefully this post can save some of your time.

The ingredients you need

  1. Firstly, set up a directory (folder) on your server for the Craft CMS to be uploaded to, then change its document root directory.

    In my case I have set up a subdomain called craft from the cPanel on my web server, then modified the subdomain’s document root folder to be ~/public_html/craft/web.

    Subdomain Document Root Directory

    In more details, when you set up a subdomain its directory will be ~/public_html/subdomain or something similar. Then you need to change the subdomain’s document root directory to be ~/public_html/subdomain/web.

    This is very important that you set up the subdomain’s document root directory. If you don’t set it up, after you install the Craft CMS you would get 503, 500 or 403 errors. It will be explained more in the later process.

  2. Next, open the and connect to your server by using the command below.

    Replace USER, HOST_NAME and PORT according to your own server.

    If you are already connected to your server, skip this step. Please refer to the previous post for more details.

  3. Then move to your subdomain directory using the following command.
    cd public_html/subdomain

    Replace public_html/subdomain with your own subdomain directory.

  4. Now we can command Composer to install Craft CMS in your subdomain directory by inputting the following snippet in the
    composer create-project craftcms/craft .

    Do not miss the dot at the end of the command. Otherwise, Composer will create a separate sub folder called craft within your subdomain folder.

  5. After the command, you will see the installing process on your screen. When the Craft CMS is successfully uploaded onto your subdomain folder you will see the the Craft CMS welcome message. It will look like the image below.

    Craft CMS installation using Composer

  6. Now if you open the File Manager on your cPanel, you will see that the Craft CMS is uploaded to the ~/public_html/subdomain directory. And you will also notice that index.php or .htaccess files are missing from the subdomain folder.

    The index.php and .htaccess are located in the folder called web. This is the reason why we needed to set up the subdomain’s document root folder to be ~/public_html/subdomain/web earlier.

  7. Finally, with the Craft CMS uploaded onto your server, you can finalise the installation.

    Open your browser and type in the URL of your subdomain then add /admin at the end, something like in the address bar.

    You will see the install screen of your first Craft CMS on your browser. It will look like the image below.

    Craft CMS Install Screen

    Follow the instruction on the screen. You need to have a fresh database set up to connect to your Craft CMS.

  8. After completing the install process including connecting the database, you will be redirected to the admin panel of the Craft CMS. It will look like the following image.

    Craft CMS Admin Dashboard

    Congratulations! You have successfully installed Craft on your web server. Happy Crafting!