DEV Community

Mohammed Shaheem P
Mohammed Shaheem P

Posted on

How to install Mautic in AWS with EC2, RDS and SES

Follow this article to install Mautic on AWS EC2

Start EC2 Instance

Launch an instance with a recommended configuration of (2 CPU – 4GB RAM).

To get more details about mautic hardware requirements read this article

You must also have configured your security group to allow SSH (port 22), HTTP (port 80), and HTTPS (port 443) connections.

To get more details about AWS Security Group read this article

Connect to EC2 instance with SSH

Run this command, if necessary, to ensure your key is not publicly viewable.

chmod 400 <certificate_name>.pem
Enter fullscreen mode Exit fullscreen mode

Connect to your instance using its Public DNS

ssh -i <certificate_name>.pem ec2-user@public_dns
Enter fullscreen mode Exit fullscreen mode

Install Apache Server

To ensure that all of your software packages are up to date, perform a quick software update on your instance.

sudo yum update -y
Enter fullscreen mode Exit fullscreen mode

Use the yum install command to install Apache web server

sudo yum install -y httpd
Enter fullscreen mode Exit fullscreen mode

Start the Apache web server.

sudo systemctl start httpd
Enter fullscreen mode Exit fullscreen mode

Use the systemctl command to configure the Apache web server to start at each system boot.

sudo systemctl enable httpd
Enter fullscreen mode Exit fullscreen mode

You can verify that httpd is on by running the following command:

sudo systemctl is-enabled httpd
Enter fullscreen mode Exit fullscreen mode

Now if open the public IPv4 address inside a browser you can see Apache home page

Apache Home Page

Setup Apache Permissions

Apache httpd serves files that are kept in a directory called the Apache document root. The Amazon Linux Apache document root is /var/www/html, which by default is owned by root.

To allow the ec2-user account to manipulate files in this directory, you must modify the ownership and permissions of the directory.

Add user (in this case, ec2-user) to the apache group.

sudo usermod -a -G apache ec2-user
Enter fullscreen mode Exit fullscreen mode

Log out and then log back in again to pick up the new group, and then verify your membership.

Change the group ownership of /var/www and its contents to the apache group.

sudo chown -R ec2-user:apache /var/www
Enter fullscreen mode Exit fullscreen mode

To add group write permissions and to set the group ID on future subdirectories, change the directory permissions of /var/www and its subdirectories.

sudo chmod 2775 /var/www && find /var/www -type d -exec sudo chmod 2775 {} \;
Enter fullscreen mode Exit fullscreen mode

To add group write permissions, recursively change the file permissions of /var/www and its subdirectories:

find /var/www -type f -exec sudo chmod 0664 {} \;
Enter fullscreen mode Exit fullscreen mode

Install PHP

For installing Mautic 3 you need to install atleast php7.2 as per the time of writing this article

you can get current requirements here

you can use amazon-linux-extras commands to install php

sudo amazon-linux-extras install -y php7.2
Enter fullscreen mode Exit fullscreen mode

To test PHP, create a PHP file in the Apache document root.

echo "<?php phpinfo(); ?>" > /var/www/html/phpinfo.php
Enter fullscreen mode Exit fullscreen mode

In a web browser, type the URL of the file that you just created. This URL is the public DNS address of your instance followed by a forward slash and the file name. For example:

http://`my.public.dns.amazonaws.com`/phpinfo.php
Enter fullscreen mode Exit fullscreen mode

Top comments (0)