In this tutorial, we will guide you on how to install Drupal Commerce on macOS. Drupal Commerce is an open-source e-commerce platform built on Drupal, a content management system.
Before we start installing Drupal Commerce, make sure your system meets the following requirements:
To install Drupal Commerce, we need to install Composer first. Composer is a dependency manager for PHP.
Open the Terminal app on your Mac.
Type the following command and press Enter to start the installation of Composer:
$ curl -sS https://getcomposer.org/installer | php
After the installation is done, move the composer.phar
file to the /usr/local/bin
directory with this command:
$ mv composer.phar /usr/local/bin/composer
Verify that you have installed Composer by typing this command:
$ composer -v
If the output displays the version of Composer, it means that Composer is installed correctly.
We need to create a database to store the Drupal Commerce website's data. We can use MySQL or MariaDB to create a database.
Open the Terminal app on your Mac.
Log in to the mysql
client:
$ mysql -u root -p
Enter your MySQL root user password, if prompted.
Create a new database with this command:
mysql> CREATE DATABASE commerce_db;
Replace "commerce_db" with any name you want to give your database.
Create a new user with a password:
mysql> CREATE USER 'commerce_user'@'localhost' IDENTIFIED BY 'password';
Replace "commerce_user" with any name you want to give your user, and "password" with a strong password.
Grant all privileges to the user:
mysql> GRANT ALL PRIVILEGES ON commerce_db.* TO 'commerce_user'@'localhost';
This command gives all privileges to the user for the commerce_db database, which means the user has full control over the database.
Exit the mysql
client:
mysql> exit;
Now, we can install Drupal Commerce using Composer.
Open the Terminal app on your Mac.
Navigate to your Web Server's Document Root directory, where you want to install Drupal Commerce.
Use the following command to download the latest version of Drupal Commerce:
$ composer create-project drupalcommerce/project-base mysite --stability dev --no-interaction
This command installs Drupal Commerce in a folder called mysite
in your current working directory.
Wait for the installation to finish, It may take a while.
Modify the settings.php
file and configure it to connect to the database.
$ cp mysite/web/sites/default/default.settings.php mysite/web/sites/default/settings.php
$ nano mysite/web/sites/default/settings.php
Update the database settings in the settings.php
file:
'database' => [
'default' => [
'database' => 'commerce_db',
'username' => 'commerce_user',
'password' => 'password',
'host' => 'localhost',
'port' => '',
'driver' => 'mysql',
'prefix' => '',
],
],
Save and close the file.
Change the permissions of the files
and settings.php
directories to make them writable by the web server:
$ chmod -R a+w mysite/web/sites/default/files
$ chmod a+w mysite/web/sites/default/settings.php
Open your web browser and navigate to http://localhost/mysite/web/
.
Follow the on-screen instructions to complete the installation process.
Once the installation is complete, you can start building your Drupal Commerce website.
Congratulations! You have successfully installed Drupal Commerce on your macOS system. If you encounter any issues during installation, you can refer to the Drupal Commerce official documentation to solve them.
If you want to self-host in an easy, hands free way, need an external IP address, or simply want your data in your own hands, give IPv6.rs a try!
Alternatively, for the best virtual desktop, try Shells!