From DreamFactory
Jump to: navigation, search

Important Notes

This tutorial walks you through installing a web server stack (LAMP/LEMP) and assumes a more or less blank server. If you have existing resources installed on the server you will need to work around them. For example this tutorial assumes that DreamFactory will be the only/default web app on this server. If you have other sites (virtual hosts) you will need to adjust the configuration accordingly.


DreamFactory requires certain applications for install and other functionality.

  1. Install git, curl, zip, unzip
    • $ sudo yum install git curl zip unzip


These instructions will install PHP 7 with various modules. DreamFactory requires the mbstring, zip, curl, mongodb, and sqlite3 php modules. Additionally php-fpm is installed if you will be running Nginx as your web server (recommended.) Finally, the mysql php module needs to be installed if you will be using MySQL or MariadDB, which these instructions recommend for the system database. Other database types will require their php modules to be installed for use within DreamFactory. This is covered in the Drivers and Modules section.

Remove Previous Versions

  1. $ sudo yum remove httpd* php*

Install for Apache

  1. $ sudo yum install httpd24 php71 php71-common php71-mbstring php71-mysqlnd php71-pdo php71-mcrypt php71w-bcmath

PHP MongoDB Extension

  • This module is required even if you are not using MongoDB in order to satisfy the installation requirements of various packages that will be imported.
  1. Make sure you all the required packages
    • $ sudo yum install php71-devel php7-pear gcc openssl-devel
  2. Install from PECL
    • $ sudo pecl7 isntall mongodb
  3. Enable the extension
    • $ sudo sh -c 'echo "" > /etc/php-7.1.d/40-mongodb.ini'


Composer is a PHP dependency manager and is required for installing DreamFactory. In these instructions, we will assume you are logged in as a user named ec2-user. Anywhere you see this username substitute your own.

  1. Make a bin directory in your home directory if it doesn't already exist.
    • $ cd ~
    • $ mkdir bin
  2. Get the setup file from composer
    • $ php -r "copy('', 'composer-setup.php');"
  3. Install composer to your bin directory
    • $ php composer-setup.php --install-dir=/home/ec2-user/bin --filename=composer
  4. Restart your terminal app (if using Linux with a GUI) or log out and log back in.


You'll need a database for the system to store configuration information. This tutorial will walk you through installing and using MariaDB (a MySQL clone.) Other supported system databases are SQLite, PostgreSQL, and Microsoft SQL (requires a product subscription.) If you intend to use one of these other databases, you can skip this section. When it comes time to install DreamFactory, just give the install the appropriate connection information for your other database (during php artisan df:env.)



  1. Install the server and client from Yum
    • Please follow the instructions on the MariaDB Website to get the version you want. For Amazon Linux we recommend you use the CentOS 6 instructions with MariaDB 10.2 on the aforementioned link.


  1. Start MariaDB
    • $ sudo service mysql start
  2. Login to the database
    • $ sudo mysql
  3. Create a database. You can name it whatever you like. Just make sure you save this information. For the example we called it dreamfactory.
    • CREATE DATABASE dreamfactory;
  4. Create a user with all privileges on that database. You can name the user and password whatever you like. Just make sure you save this information. For the example we used dfadmin for both the user and the password.
    • GRANT ALL PRIVILEGES ON dreamfactory.* to 'dfadmin'@'localhost' IDENTIFIED BY 'dfadmin';
  5. Flush privileges on the database and quit.
    • quit


Installing DreamFactory involves getting the required code via git and composer and then using the Laravel artisan command to set up the system. In these instructions, we will assume you are logged in as a user named ec2-user. Anywhere you see this username substitute your own.

  1. Create a directory for installation and make your user the owner of the directory. This will be the working directory for the remainder of this section.
    • $ sudo mkdir /opt/dreamfactory
    • $ sudo chown -R ec2-user /opt/dreamfactory
  2. Navigate to the working directory and use git to clone the dreamfactory repo
    • $ cd /opt/dreamfactory
    • $ git clone ./
  3. Use composer to get dependencies
    • Note for commercial users: Copy your commercial license files into the working directory before running this command.
    • $ composer install --no-dev
  4. Setup the DreamFactory system database connection
    • Note: Previously this command was dreamfactory:setup or df:setup. As of DF 2.7.0 the command is changed to df:env
    • $ php artisan df:env
      • Select option 1 for MySQL. Answer the onscreen prompts regarding database connection and credentials (which you set in the Database section.)
    • IMPORTANT. Before running the df:setup command again you need to edit the .env file.
      • $ nano .env
      • Uncomment (remove the ##) the two lines that read ##DB_CHARSET=utf8 and ##DB_COLLATION=utf8_unicode_ci
      • Save and exit (Ctrl+x, Y, <Enter>)
    • $ php artisan df:setup
      • Answer the onscreen prompts to create your first admin user for the system.
  5. Reset permissions on the storage and cache directories.
    • NOTE for Apache users: If you did not install Apache (httpd24) with PHP at the beginning you will need to skip this step and return to it after installing Apache.
    • $ sudo chown -R apache:ec2-user storage/ bootstrap/cache/
    • $ sudo chmod -R 2775 storage/ bootstrap/cache/
  6. Clear the application cache
    • $ php artisan cache:clear

Web Server

DreamFactory relies on a web server application to serve the REST endpoints as well as the admin application to users. Options are Nginx and Apache.

  1. Turn off selinux.
    • If you are comfortable configuring selinux, you may choose to do so, but for the purposes of this tutorial, we will simply turn it off.
    • $ sudo setenforce 0


  1. Install Apache from Yum (if you did not do this in the PHP steps.)
    • $ sudo yum install httpd24
  2. Start Apache
    • $ sudo service httpd start
  3. Navigate to the site configuration and backup the default config
    • $ cd /etc/httpd/conf/
    • $ sudo cp httpd.conf httpd.conf.bak
  4. Edit the default config.
    • $ sudo nano httpd.conf
    • Edit the file.
    • Set the DocumentRoot to /opt/dreamfactory/public
    • Find the area marked <Directory "/var/www">. Delete it.
    • Find the area marked <Directory "/var/www/html">. Edit it so it reads:
      • <Directory "/opt/dreamfactory/public">
            AddOutputFilterByType DEFLATE text/plain text/css application/json application/javascript text/xml application/xml application/xml+rss text/javascript
            Options -Indexes +FollowSymLinks -MultiViews
            AllowOverride All
            AllowOverride None
            Require all granted
            RewriteEngine on
            RewriteBase /
            RewriteCond %{REQUEST_FILENAME} !-f
            RewriteCond %{REQUEST_FILENAME} !-d
            RewriteRule ^.*$ /index.php [L]
            <LimitExcept GET HEAD PUT DELETE PATCH POST>
                Allow from all
    • Save the file and exit
  5. Restart Apache
    • $ sudo service httpd restart
  6. Go back to /opt/dreamfactory and perform the permissions edit step if it was previously skipped.
  7. Confirm that Apache is properly configured by loading the server's IP or hostname in your browser.