Install Mautic on an Ubuntu 14.04 VPS


install-mautic-on-an-ubuntu-14-04-vpsIn this tutorial, we will explain how to install Mautic on an Ubuntu 14.04 VPS with MariaDB, PHP-FPM and Nginx. Mautic is an open source marketing automation software built on top of the Symfony 2 components and open source libraries. This guide should work on other Linux VPS systems as well but was tested and written for an Ubuntu 14.04 VPS.

Login to your VPS via SSH

ssh user@vps

Update the system and install necessary packages

[user]$ sudo apt-get update && sudo apt-get -y upgrade
[user]$ sudo apt-get install software-properties-common git curl vim

Install MariaDB 10.0

To install MariaDB, run the following commands:

[user]$ sudo apt-key adv --recv-keys --keyserver hkp://keyserver.ubuntu.com:80 0xcbcb082a1bb943db
[user]$ sudo add-apt-repository 'deb http://ftp.osuosl.org/pub/mariadb/repo/10.0/ubuntu trusty main'
[user]$ sudo apt-get update
[user]$ sudo apt-get install -y mariadb-server

When the installation is complete, run the following command to secure your installation:

[user]$ mysql_secure_installation

Next, we need to create a database for our Mautic installation.

[user]$ mysql -uroot -p
MariaDB [(none)]> CREATE DATABASE mautic;
MariaDB [(none)]> GRANT ALL PRIVILEGES ON mautic.* TO 'mauticuser'@'localhost' IDENTIFIED BY 'mauticuser_passwd';
MariaDB [(none)]> FLUSH PRIVILEGES;
MariaDB [(none)]> \q

Install Nginx

Ubuntu 14.04 comes with nginx version 1.4, to install the latest stable version of Nginx version 1.8, run:

[user]$ sudo add-apt-repository -y ppa:nginx/stable
[user]$ sudo apt-get update
[user]$ sudo apt-get -y install nginx

Install PHP and required PHP modules

To install the latest stable version of PHP version 5.6 and all nessesary modules, run:

[user]$ sudo add-apt-repository -y ppa:ondrej/php5-5.6
[user]$ sudo apt-get update
[user]$ sudo apt-get -y install php5-fpm php5-cli php5-json php5-curl php5-gd php5-mysqlnd php5-imap php5-mcrypt

Install Composer

Composer is a dependency manager for PHP with which you can install packages. Composer will pull in all the required libraries and dependencies you need for your project.

[user]$ curl -sS https://getcomposer.org/installer | php
[user]$ sudo mv composer.phar /usr/local/bin/composer

Install Mautic

Create a root directory for your Mautic installation script using the following command:

[user]$ mkdir -p ~/myMautic.com/{public_html,logs}

Clone the project repository from GitHub:

[user]$ git clone https://github.com/mautic/mautic.git ~/myMautic.com/public_html

Change to the directory and install composer packages:

[user]$ cd ~/myMautic.com/public_html
[user]$ composer install

PHP-FPM configuration

Create a new PHP-FPM pool for your user:

[user]$ sudo vim /etc/php5/fpm/pool.d/your_user.conf
[your_user]
user = your_user  
group = your_user  
listen = /var/run/php5-fpm-your_user.sock  
listen.owner = your_user
listen.group = your_user  
listen.mode = 0666  
pm = ondemand  
pm.max_children = 5  
pm.process_idle_timeout = 10s;  
pm.max_requests = 200  
chdir = /

Do not forget to change your_user with your username.

Restart PHP-FPM:

[user]$ sudo service php5-fpm restart

Nginx configuration

Create a new Nginx server block with the following content:

[user]$ sudo nano /etc/nginx/sites-available/myMautic.com
server {
    server_name myMautic.com;
    listen 80;
    root /home/your_user/myMautic.com/public_html;

    access_log /home/your_user/myMautic.com/logs/access.log;
    error_log /home/your_user/myMautic.com/logs/error.log;

    index index.php;

    location / {
        try_files $uri $uri/ /index.php?$query_string;
    }

    sendfile off;

    location ~ \.php$ {
        fastcgi_split_path_info ^(.+\.php)(/.+)$;
        fastcgi_pass unix:/var/run/php5-fpm-your_user.sock;
        fastcgi_index index.php;
        include fastcgi_params;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        fastcgi_intercept_errors off;
        fastcgi_buffer_size 16k;
        fastcgi_buffers 4 16k;
    }

    location ~ /\.ht {
        deny all;
    }    
}

Do not forget to change your_user with your username.

Activate the server block by creating a symbolic link :

[user]$ sudo ln -s /etc/nginx/sites-available/myMautic.com /etc/nginx/sites-enabled/myMautic.com

Test the Nginx configuration and restart nginx:

[user]$ sudo nginx -t
[user]$ sudo service nginx restart

Final steps

Open http://myMautic.com in your favorite web browser and you should see the Mautic install screen. Provide the database information and create an admin user.

That’s it. You have successfully installed Mautic on your Ubuntu 14.04 VPS. For more information about how to manage your Mautic installation, please refer to the official Mautic documentation.


Of course you don’t have to do any of this if you use one of our Linux VPS Hosting services, in which case you can simply ask our expert Linux admins to setup this for you. They are available 24×7 and will take care of your request immediately.

PS. If you liked this post please share it with your friends on the social networks using the buttons on the left or simply leave a reply below. Thanks.

Tutorials
How to install Pligg CMS on Ubuntu 14.04
Tutorials
SSH login without password using SSH keys
Tutorials
How to install Panda3D on Ubuntu 10.04
  • John Linhart

    I wouldn’t recommend using the latest GitHub version of Mautic since there might be some pre-release bugs. Rather download the latest stable release from https://www.mautic.org/download/. You also won’t need to install Composer since the official package has all the dependencies.


  • GG

    GGGG

    Author Reply

    I followed the instructions and ended up with a default.domain in the site. What am I doing wrong?


    • admin

      adminadmin

      Author Reply

      Please check your nginx configuration file and make sure you add the nginx server block related to Mautic.


      • Filip

        FilipFilip

        Author Reply

        Once I run this installation, can I fetch updates from the main repo since the download link is from the master repo on Github, or do I need to set up automatic updates in another way, so I can properly do git fetch upstream


        • admin

          adminadmin

          Author Reply

          For more information on this, please read the documentation at http://mautic.github.io/developer-documentation

          Please note, each time you update Mautic’s source after the initial setup/installation via a new git pull, etc. you will need to clear the cache.


  • Marcos

    MarcosMarcos

    Author Reply

    Follow the steps and ended with a 502 Bad Gateway. Whats wrong?


    • admin

      adminadmin

      Author Reply

      Please check the Nginx error log for more info


      • Marcos

        MarcosMarcos

        Author Reply

        Just find out it was a typo. Sorry to bother :)


  • Razi Khan

    Razi KhanRazi Khan

    Author Reply

    How do I install mautic on subfolder ? using nginx , do I still need to create user and sites-available/(my subfolder conf)


    • admin

      adminadmin

      Author Reply

      Yes, you can install Mautic in a subdirectory. As for creating Nginx virtual config it is totally up to you.


      • Razi Khan

        Razi KhanRazi Khan

        Author Reply

        can you please guide ? , I am getting “The site is currently offline due to encountering an error”
        my default site conf
        ” server {
        listen 80;
        server_name domain.com;

        access_log /var/log/nginx/domain.com.access_log;
        error_log /var/log/nginx/domain.com.error_log;

        root /var/www/html;
        index index.php index.htm index.html;

        include /etc/nginx/global/wordpress.conf;
        include /etc/nginx/global/restrictions.conf;
        include /etc/nginx/global/mautic.conf;
        }

        and mautic.conf
        “server {
        server_name domain.com/mautic;
        listen 80;
        root /var/www/html/mautic/public_html;

        access_log /var/www/html/mautic/logs/access.log;
        error_log /var/www/html/mautic/logs/error.log;

        index index.php;

        location / {
        try_files $uri $uri/ /index.php?$query_string;
        }

        sendfile off;

        location ~ \.php$ {
        fastcgi_split_path_info ^(.+\.php)(/.+)$;
        fastcgi_pass 127.0.0.1:9000;
        fastcgi_index index.php;
        include fastcgi_params;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        fastcgi_intercept_errors off;
        fastcgi_buffer_size 16k;
        fastcgi_buffers 4 16k;
        }

        location ~ /\.ht {
        deny all;
        }
        }


        • admin

          adminadmin

          Author Reply

          You can check your log files for errors or more information about the problem you are experiencing. Thanks.