The ideal Dreamfactory deployment

Hey there!

Ok, this will be a first technical oriented post on this blog and it will be related to DreamFactory deployment, because that’s what I did recently.

A bit of a background…

DreamFactory is a free, open source software package that provides a complete REST API for mobile, web, and IoT applications. And we think DF is a great tool which makes easier to develop any web-based or mobile applications.

So I’ve received a request to (re)build a DreamFactory environment from scratch in a kind of “secure” way.

Current situation

The current environment was installed using Bitnami, which is a package containing all the (un)neccessary packages, software, libraries to easily get DF up and running. I decided to install the software on CentOS because it’s popular and the original server was CentOS, too. At the time I did not know what a pain it’s going to be to use CentOS 7 as OS running DF.

New installation

To successfully install DF, you need to have c++, gcc, python, git, php and few other packages installed. For CentOS 7, most of them are older versions in repo than what’s required, so the compilation part had to happen. It took so much time and the result still did not look promising. E.g. v8js was almost impossible to get installed properly.

So after few days I gave up and went for Debian, my favorite one. The installation was very smooth and quick, my decision was to install it on Apache. I installed all the packages from repo, got the DF up and running within an hour. So when you’re considering what OS to build DreamFactory platform on, Debian is a hot candidate.

Here’s my procedure

I will quickly describe steps I have taken to install DF including some of the tools.

1. Install packages that we will need to run DF platform

apt-get install -y apache2 binutils python git curl php5 php5-mysqlnd php5-common php5-cli php5-curl php5-json php5-gd php5-sqlite php5-mssql

2. Enable mod rewrite, and restart Apache

a2enmod rewrite ssl
service apache2 restart

3. Install composer, that we will need, too

curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer

4. If you are planning to run server side JS scripts, install v8js and restart Apache again

apt-get install -y php-pear php5-dev libv8-dev g++ cpp
pecl install v8js-0.1.3
echo "extension=v8js.so" > /etc/php5/mods-available/v8js.ini
php5enmod v8js
service apache2 restart

5. Now we will get the DF from git repo, install all the dependencies. I will install the DF into /opt/dreamfactory. I’m not going to need MongoDB, so I will use “–ignore-platform-reqs” switch.

cd /opt

git clone https://github.com/dreamfactorysoftware/dreamfactory
cd dreamfactory
composer install --no-dev --ignore-platform-reqs

6. Run commands below on the server where you plan to place your database. Can be either the same server (not recommended) or another one.

apt-get install -y mariadb-server

You will be asked for root password, make sure it’s a secure one!

Now create MySQL DB and user

mysql -u root -p

mysql> create database dreamfactory;
mysql> grant all privileges on dreamfactory.* to 'new_user'@'localhost' identified by 'YourNewPassword';
mysql> flush privileges;
mysql> quit;

7. Following command you will run twice, for the first time, you will enter all the information about DB, user etc and then re-run

php artisan dreamfactory:setup

8. Ok, so far so good! Now we will just create a virtual host on the Apache pointing to our DF and we should be ready!

touch /etc/apache2/sites-available/001-dreamfactory.conf

Insert following content inside the file

<VirtualHost *:80>

DocumentRoot /opt/dreamfactory/public
ServerName your-server.com

<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
</LimitExcept>

</Directory>
</VirtualHost>

And create a symlink

ln -s /etc/apache2/sites-available/001-dreamfactory.conf /etc/apache2/sites-enabled/001-dreamfactory.conf

9. Now restart Apache, visit the URL of your server and your DF should appear right there!

service apache2 restart

 

Have a good day,

Robot(ICT) guy

Published by

Lukas Vu

I started in IT with my own business since high school providing automated and centralized hosting solutions to end customers. Nowadays I'm focusing on corporate area, analyzing, managing and improving customer's IT environments. My main focus nowadays is automation and architectural improvements.

Leave a Reply

Your email address will not be published.