How to Install DreamFactory Open Source on CentOS 7

DreamFactory is a free and open source solution that enables you to convert any database into a REST API service.

This tutorial explains how to set up the Open Source Edition of DreamFactory on a CentOS 7 server.

Requirements

  • A CentOS 7 x64 server instance
  • A user with sudo privileges

Step 1: Perform System Updates

Start by logging in via SSH as a sudo-enabled user. Update your system with the following commands:

sudo yum install epel-release -y
sudo yum update -y
sudo shutdown -r now

Step 2: Set Up Apache Web Server

DreamFactory requires Apache. You can install it using the YUM package manager as shown below:

Then, remove the default welcome page of Apache:

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

Prevent Apache from displaying directory contents publicly:

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

Activate Apache and ensure it starts on boot:

sudo systemctl start httpd.service
sudo systemctl enable httpd.service

Step 3: Install and Configure MariaDB

We will use MariaDB 10.1 as the backend database for DreamFactory.

3.1 Create the MariaDB 10.1 Repository

Use this snippet to define the YUM repository for MariaDB 10.1:

3.2 Install MariaDB Using YUM

 

Now install MariaDB server and client packages with this command:

sudo yum install MariaDB-server MariaDB-client -y

3.3 Enable and Launch MariaDB

Start MariaDB and make sure it launches on system boot:

sudo systemctl start mariadb.service
sudo systemctl enable mariadb.service

 

3.4 Secure MariaDB Installation

Run the built-in MariaDB script to apply essential security settings:

sudo /usr/bin/mysql_secure_installation

Follow the prompts with the following responses. Be sure to substitute your own secure password where required:

  • Enter current password for root (enter for none): Press Enter
  • 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 DreamFactory Database in MariaDB

Use the following steps to create the required database and user for DreamFactory. First, log into MariaDB as root:

Enter the root password set in the previous step. Inside the MySQL shell, run the following commands to set up the DreamFactory database and user. Be sure to replace the sample credentials with your own secure values:

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 Required Extensions

To install PHP 7.1 and the necessary modules on CentOS 7, use the Webtatic YUM repository as follows:

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 Download and Install Composer

To install Composer version 1.3.1, execute the following sequence of commands. Please be aware that Composer’s installation process might change in the future, so it’s best to consult their official site for the most recent steps:

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 Move Composer to a Global Path

Make Composer accessible system-wide with this command:

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

Step 5: Install Git and DreamFactory

5.1 Install Git

Use the following command to install Git on CentOS 7:

5.2 Download and Install DreamFactory

Download the most recent stable version of DreamFactory (2.4.2 at the time of writing) and proceed with installation using the commands below:

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

To generate the environment configuration file, run the setup command:

sudo php artisan dreamfactory:setup

Provide the requested database details as shown:

  • Choose database type: 1 (for MySQL)
  • MySQL Host: localhost
  • Database Name: dreamfactory
  • Username: dreamfactoryuser
  • Password: yourpassword
  • Database Port: 3306

Now repeat the same command to set up the first admin user:

sudo php artisan dreamfactory:setup

Use the following information when prompted:

  • First name: John
  • Last name: Doe
  • Display name: John Doe
  • Email: admin@example.com
  • Password: <your-admin-password>

5.3 Configure DreamFactory for Web Access

Create a virtual host configuration file for DreamFactory. Replace the placeholder values with your own details:

Restart Apache to apply the configuration:

sudo systemctl restart httpd.service

To allow external web access, update the firewall settings:

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

Step 6: Access DreamFactory Web Interface

Open your browser and navigate to http://203.0.113.1. You can then log in with the admin email and password you set during setup.

Conclusion

By following this comprehensive guide, you’ve successfully installed the DreamFactory Open Source Edition on a CentOS 7 server. You’ve configured Apache, MariaDB, PHP, Composer, and DreamFactory itself, as well as secured your database and web environment. You can now begin building RESTful APIs with DreamFactory and connect your applications to virtually any backend database through a streamlined, scalable interface.

 

Source: vultr.com

Create a Free Account

Register now and get access to our Cloud Services.

Posts you might be interested in: