Install Mautic in a Sub Folder on NGINX
For those of you who don’t know what Mautic is, it’s a powerhouse of an application for list building, marketing automation, sales funnels… and MORE!
And the incredible part? It’s FREE to use on your own server and site — you just need to know enough about Linux administration to set it up.
You can setup Mautic at a sub domain, but I wanted to install it within a sub folder. This would mean any landing pages created were at outergain.com/landing-page vs mautic.outergain.com/landing-page. However, installing in a sub folder on nginx wasn’t something many people were talking about when I first began with Mautic. So after trial and error, throwing computers out the window and destroying my office with a light saber, it began to work.
Here are the installation steps:
- These steps assume ‘example.com’ equals your actual website.
- ‘Data’ is the sub folder you’re installing Mautic into — The name is completely up to you.
- Your nginx sites are located in /var/www/
- Your PHP version is 7
Also note: We use Ubuntu and/or Debian. If you’re on a different distro, you may have to adjust a few commands.
1) Create the subfolder you want to run mautic out of.
2) Get the latest Mautic files.
From a command line, navigate to your folder. Example: cd /var/www/yoursite.com/pages and get the latest files:
If you need an older version, type similar to:
4) Unzip the installation files.
5) Remove the zipped file.
(add the .zip extension for a version, example: rm 2.8.2.zip)
6) Change ownership on the installation folder(s):
create a folder called ‘logs’ in pages/app (if it doesn’t exist). Then…
Next: Server Config (based on Debian LEMP):
1) Edit php.ini file.
Add this line to the bottom of your your php.ini file:
2) Install PHP packages
You may already have these items installed.
apt-get install php7-intl
apt-get install php7-mcrypt
3) Enable mcrypt:
4) Edit your site’s server block.
The normal path is: /etc/nginx/sites-available/yoursite.com
try_files $uri $uri/ /pages/?q=$uri&$args;
5) Restart nginx and php7-fpm
service php7-fpm restart
6) Create mysql database for Mautic
grant all on yourmauticdb.* to ‘yourmauticdbuser’ identified by ‘thepasswordyouwant’;
Finally, the installation!
7) Go to http://yoursite.com/pages/installer
At this step, the installer will let you know if anything on your server isn’t ready for Mautic. This includes missing packages, outdated packages, etc. You’ll need to fix each item until you get the green Ready to Install as shown below.
8) Database information.
Next you’ll need to enter in your database information from step 6. You’re installing into a clean database, so no need to save existing tables. As long as the database info checks out, the installer will continue.
9) General Settings
The next step will prompt for general admin info such as email, name and password.
10) Email Configuration
Next up is your mail server configuration. We recommend SendGrid or SparkPost. The information below shows setting up as an SMTP server. But you can also setup with an API, which is recommended.
*You can skip this and setup the mail under the “Configuration Settings” once the installation completes.
11) Setup Cron
You’ll need to schedule cron jobs to keep things updated on the mautic instance.
a) from a command line type:
b) paste in the following lines:
*/5 * * * * php /var/www/outergain.com/public_html/content/app/console mautic:segments:update
*/5 * * * * php /var/www/outergain.com/public_html/content/app/console mautic:campaigns:rebuild
*/5 * * * * php /var/www/outergain.com/public_html/content/app/console mautic:campaigns:trigger
*/5 * * * * php /var/www/outergain.com/public_html/content/app/console mautic:emails:send
*/5 * * * * php /var/www/outergain.com/public_html/content/app/console mautic:iplookup:download
*/5 * * * * php /var/www/outergain.com/public_html/content/app/console mautic:social:monitoring
*Note: the above tells each job to run every 5 minutes. For some jobs, this is complete overkill, so schedule according to your needs. Also, you may not need all of these jobs. For example, if you haven’t setup mautic to queue mail, then you don’t need it to have email send as a cron job.
The cron layout is:
c) Save the file and then type:
To check the status of your cron jobs, type this in a terminal window:
Would you like to learn more?
Get free marketing tips from Outer Gain! We help people sell beyond their reach!