How to Setup a New Project in Craft CMS 3

June 29, 2018galaxy-admin
  • Craft CMS
  • Technology
  • Web Application
  • Web Development
Share:
There are two ways you can set up a new project in Craft 3, vis-a-vis, via Composer and Manual. Both the methods require extensive technical expertise & understanding of Craft CMS. With Composer method you have to know your commands and what you’re doing with them but in case of the manual method you just have to perform some simple operations.

Composer Method in Craft CMS

If you have a good understanding of Craft CMS, then you can setup a new Craft project with the some terminal commands. Though, before installing Craft with composer, do make sure that you’re running Composer version 1.3.0 or above. Here are the essential steps: Check the Composer version composer -V Run this command in case your Composer needs updating composer self-update When you’ve confirmed that you’re running a compatible version of the Composer, run the following command (substitute with the path where Composer should create the project): composer create-project craftcms/craft <PATH> The composer will do all the work and it will display a success message. Another way is to do it manually.

Manual Method to setup Craft CMS

You will have to download the archive from Craft’s website. Choose the archive format you’re familiar to work with. Extract the archive where you want your Craft project to be saved. Then follow these 5 steps:

Step 1: Setting up permissions

When you’re doing the manual setup, you have to download and extract the Craft archive in the desired place. The extraction will provide you with a Craft directory which has these files in it: config/… storage/ templates/ vendor/… web/… .env .env.example composer.json craft craft.bat LICENSE.md README.md Out of these files, there are some files for which PHP needs access permissions for different users to write on it. The files are: .env Composer.json Composer.lock config/license.key storage/* Vendor The permissions are defined on the basis of the relationship between the system user that the PHP is running as and ownership of the folders/files.
  • If they are the same user, use 744.
  • If they’re in the same group, then use 774.
  • If you’re not sure, then use 777.

Step 2: Securing the project with a security key

You have to set up a security key to encrypt the data of your project. Every project in Craft has a unique one. You can also use same security key for multiple environments running Craft. You can set a unique security key using the terminal or with a password generator. The password generator will help you to create a cryptographically secure key. Now you need to insert the generated key in your .env file. Open the .env file and insert the security key in between the quotes where it says: SECURITY_KEY=” “ Save the file.

Setting the security key with terminal

Run the following command in your project’s root directory: ./craft setup/security-key.

Step 3: Creating a database

Craft 3 supports MySQL 5.5+ and PostgreSQL 9.5+. So you can choose your database accordingly. But there are some recommended database settings:
  • For MySQL Default Character Set: utf8 Default Collation: utf8_unicode_ci
  • For PostgreSQL Character Set: UTF8

Step 4: Setting up a web server

With the database done setting up. You need a web server on which you can host your Craft project. Make sure you set the path of it’s document root to- web/directory(name of the directory) You will need to update your hosts file if you’re not using any local hosts like MAMP. You can find your respective host files here
  • For macOS/Linux/Unix: /etc/hosts
  • For Windows: \Windows\System32\drivers\etc\hosts
Enter http://<HOSTNAME>/index.php?p=admin in the address bar of your browser (substitute <HOSTNAME> with your web server’s host name). Just to check if the setup works. If there are no errors, Craft’s Setup Wizard will show!

Step 5: Running the setup

You can either run the setup from terminal or from the browser. In the terminal after running the setup command and telling the installer ‘how to connect to the database’, your installation should take care of itself. Browser setup on the other hand provides an interactive installer to setup your Craft.

With Terminal

Open your terminal to run the command ./craft setup Answer the questions about how to connect to your database to start the installation. After the installation, you can access your new Craft project.

With Browser

Open your browser and enter http://<HOSTNAME>/index.php?p=admin (substitute <HOSTNAME> with your web server’s host name) in the address bar of your browser to find Craft’s installer. Follow the instructions and your Craft should be up and running in few minutes. I. Accept the license agreement II. Enter the Database information III. Create an admin account IV. Enter the preferred system name, URL and language V. Finish You’re all set to tweak the website from your Craft control panel. If you’ve followed every step mentioned in this tutorial then you should be able to fire up your Craft projects right away. Both the methods require expertise in Craft CMS. You can connect with us here for further assistance and queries.

Related Blogs

Idea Validation for Startups in 2024: Ensuring Your Product Fits The Market

Idea Validation for Startups in 2024: Ensuring Your Product Fits The Market

January 25, 2024

Read now
  • Product Development
Balancing Budget and Quality: Innovations in Cost-Effective Product Development

Balancing Budget and Quality: Innovations in Cost-Effective Product Development

January 18, 2024

Read now
  • Product Development