Setting up Craft CMS locally with MAMP and Composer

MAMP allows you to run a local web development server with Apache or Nginx as well as MySQL with a simple GUI.

Composer is a dependency manager for PHP that helps keep track of packages like Craft CMS and allows easy installation and saving of these packages.

  1. Download MAMP at https://www.mamp.info/en/downloads/

  2. Install composer with the instructions at https://getcomposer.org/download/

  3. Setup Craft CMS with composer by doing
    composer create-project craftcms/craft <Path>

    I have a projects folder I use for all my web projects and we will be able to point MAMP to use the folder we want. For me this looks like
    composer create-project craftcms/craft ~/Projects/craft-test

    After successful installation, you will see this
    Craft CMS command line setup with composer

  4. Open MAMP and go to MAMP > Preferences > Web Server and for Document Root select the web folder inside the folder you just composer installed Craft CMS into which would be ~/Projects/craft-test/web/

  5. In MAMP click start servers.
    If the MAMP start page doesn't open automatically click Open WebStart Page

  6. Go to Tools > PHPMYADMIN

  7. In the top left click new and enter a database name craft-test. The root user will be added to this database.

  8. Back in your terminal go to your craft project ~/Projects/craft-test and enter
    ./craft setup to start the Craft setup. It will ask you a few questions. Here is the database info based on what you just created with MAMP and PHPMYADMIN.

    • Database type: mysql
    • Host: localhost (or 127.0.0.1)
    • Database port: 8889
    • Database name: (the one you just created)
    • Database user: root
    • Database password: root
    • You are also asked to create a site name and username/ password

    After this is ran it will setup the database and tables and you should be all ready to go.

  9. Open http://localhost:8888/admin or http://127.0.0.1:8888/admin and you can now login to your local Craft CMS