Article

Table of Contents
Theme:
Was this article helpful?
Try Vultr Today with

$50 Free on Us!

Want to contribute?

You could earn up to $600 by adding new articles.

How to Install DreamFactory Open Source on CentOS 7

Last Updated: Fri, Feb 10, 2017
CentOS Linux Guides Server Apps Web Servers

DreamFactory is an open source program which can turn any database into a RESTful API platform.

DreamFactory can be deployed on various platforms. In this article, we will be installing DreamFactory Open Source Edition on a CentOS 7 server.

Prerequisites

  • A CentOS 7 x64 server instance.

  • A sudo user.

Step 1: Update the system

Log into your system as a sudo user from an SSH terminal, and then update the system as follows:

sudo yum install epel-release -y

sudo yum update -y

sudo shutdown -r now

Step 2: Install Apache

As required by DreamFactory, you need to install the Apache web server using YUM:

sudo yum install httpd -y

Remove the default Apache welcome page:

sudo sed -i 's/^/#&/g' /etc/httpd/conf.d/welcome.conf

Disable Apache’s public directory and file listing:

sudo sed -i "s/Options Indexes FollowSymLinks/Options FollowSymLinks/" /etc/httpd/conf/httpd.conf

Start the Apache service and enable it on system boot:

sudo systemctl start httpd.service

sudo systemctl enable httpd.service

Step 3: Install MariaDB

For this tutorial, we will be using MariaDB 10.1 as the database server DreamFactory will be using.

3.1 Setup the MariaDB 10.1 YUM repo

Use the following code segment to create the MariaDB 10.1 YUM repo:

cat <<EOF | sudo tee -a /etc/yum.repos.d/MariaDB.repo

# MariaDB 10.1 CentOS repository list - created 2017-01-14 03:11 UTC

# http://downloads.mariadb.org/mariadb/repositories/

[mariadb]

name = MariaDB

baseurl = http://yum.mariadb.org/10.1/centos7-amd64

gpgkey=https://yum.mariadb.org/RPM-GPG-KEY-MariaDB

gpgcheck=1

EOF

3.2 Install MariaDB 10.1 using YUM

sudo yum install MariaDB-server MariaDB-client -y

3.3 Start and enable the MariaDB service

sudo systemctl start mariadb.service

sudo systemctl enable mariadb.service

3.4 Secure the installation of MariaDB

sudo /usr/bin/mysql_secure_installation

Answer questions as follows, and be sure to enter your own MariaDB root password.

  • Enter current password for root (enter for none): Just press the Enter button

  • Set root password? [Y/n]: Y

  • New password: <your-password>

  • Re-enter new password: <your-password>

  • Remove anonymous users? [Y/n]: Y

  • Disallow root login remotely? [Y/n]: Y

  • Remove test database and access to it? [Y/n]: Y

  • Reload privilege tables now? [Y/n]: Y

3.5 Create a MariaDB database for DreamFactory

Log into the MySQL shell as root:

mysql -u root -p

Enter the MariaDB root password you set in step 3.4 in order to log in.

In the MySQL shell, create a database dreamfactory, a database user dreamfactoryuser, and its password yourpassword as follows.

Note: For security purposes, you MUST replace the three sample parameters mentioned above with your own ones.

CREATE DATABASE dreamfactory;

CREATE USER 'dreamfactoryuser'@'localhost' IDENTIFIED BY 'yourpassword';

GRANT ALL PRIVILEGES ON dreamfactory.* TO 'dreamfactoryuser'@'localhost' IDENTIFIED BY 'yourpassword' WITH GRANT OPTION;

FLUSH PRIVILEGES;

EXIT;

Step 4: Install PHP 7.x and Composer

4.1 Install PHP 7.1 and necessary extensions

On CentOS 7, you can install PHP 7.1 and necessary PHP extensions using the Webtatic YUM repo:

sudo rpm -Uvh https://mirror.webtatic.com/yum/el7/webtatic-release.rpm

sudo yum install mod_php71w php71w-common php71w-cli php71w-gd php71w-mbstring php71w-mcrypt php71w-xml php71w-mysqlnd php71w-pecl-mongodb -y

4.2 Install Composer

Install the latest release of Composer, which is 1.3.1 at the time of writing, as below.

Note: The instructions above may change in should Composer update their installation instructions. As such, you should always check out the official Composer download page in order to get the most up-to-date installation instructions.

cd

php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');"

php -r "if (hash_file('SHA384', 'composer-setup.php') === '55d6ead61b29c7bdee5cccfb50076874187bd9f21f65d8991d46ec5cc90518f447387fb9f76ebae1fbbacf329e583e30') { echo 'Installer verified'; } else { echo 'Installer corrupt'; unlink('composer-setup.php'); } echo PHP_EOL;"

php composer-setup.php

php -r "unlink('composer-setup.php');"

4.3 Make Composer globally available

sudo mv composer.phar /usr/local/bin/composer

Step 5: Install Git and DreamFactory

5.1 Install Git

sudo yum install git -y

5.2 Install DreamFactory

Download the latest stable release of DreamFactory, which is 2.4.2 at the time this article was written, then install DreamFactory and dependencies as follows:

cd

wget https://github.com/dreamfactorysoftware/dreamfactory/archive/2.4.2.tar.gz

tar -zxvf 2.4.2.tar.gz

cd dreamfactory-2.4.2

composer install --no-dev

sudo mv ~/dreamfactory-2.4.2 /opt

sudo chown -R root:root /opt/dreamfactory-2.4.2

sudo chown -R apache:apache /opt/dreamfactory-2.4.2/storage/ /opt/dreamfactory-2.4.2/bootstrap/cache/

sudo chmod -R 2775 /opt/dreamfactory-2.4.2/storage/ /opt/dreamfactory-2.4.2/bootstrap/cache/

cd /opt/dreamfactory-2.4.2

Use the following command to create a .env file to store DreamFactory configurations:

sudo php artisan dreamfactory:setup

When prompted, input database settings as follows:

  Which database would you like to use for system tables? [sqlite]:

  [0] sqlite

  [1] mysql

  [2] pgsql

  [3] sqlsrv

 > 1



 Enter your mysql Host:

 > localhost



 Enter your database name:

 > dreamfactory



 Enter your database username:

 > dreamfactoryuser



 Enter your database password:

 > yourpassword



 Re-enter your database password:

 > yourpassword



 Enter your Database Port [3306]:

 > 3306

Run the same command again in order to setup the first admin user:

sudo php artisan dreamfactory:setup

When prompted, input credentials as follows:

Creating the first admin user...



 Enter your first name:

 > John



 Enter your last name:

 > Doe



 Enter display name:

 > John Doe



 Enter your email address?:

 > admin@example.com



 Choose a password:

 > <your-admin-password>



 Re-enter password:

  > <your-admin-password>

5.3 Prepare for web access

Set up a virtual host for DreamFactory. Use the following code segment to setup a virtual host. Remember to replace the values of ServerAdmin, ServerName, ServerAlias, Errorlog, and CustomLog with your own ones.

cat <<EOF | sudo tee -a /etc/httpd/conf.d/dreamfactory.conf

<VirtualHost *:80>

ServerAdmin admin@example.com

DocumentRoot /opt/dreamfactory-2.4.2/public/

ServerName dreamfactory.example.com

ServerAlias www.dreamfactory.example.com

<Directory /opt/dreamfactory-2.4.2/public/>

Options FollowSymLinks

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

</LimitExcept>

</Directory>

ErrorLog /var/log/httpd/dreamfactory.example.com-error_log

CustomLog /var/log/httpd/dreamfactory.example.com-access_log common

</VirtualHost>

EOF

Put your modifications into effect by restarting the Apache service:

sudo systemctl restart httpd.service

Modify firewall rules in order to allow web access:

sudo firewall-cmd --zone=public --permanent --add-service=http

sudo firewall-cmd --reload

Step 6: Access DreamFactory

Point your web browser to http://203.0.113.1 to access DreamFactory, and then use the admin email address and password you set earlier to log in.

This concludes our tutorial. Thanks for reading.

Want to contribute?

You could earn up to $600 by adding new articles.