Installation Ubuntu 16
Contents
Automated Ubuntu Installer
We strongly recommend using our automated Ubuntu installer. You can learn more about the installer here. While the below instructions are still valid, using the installer will save you a great deal of time.
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. In this tutorial we will be using PHP 7.4.
Prerequisites
DreamFactory requires certain applications for install and other functionality.
- Install git, curl, zip, unzip
-
$ sudo apt-get install git curl zip unzip
-
PHP
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.
Get the 7.4 Repo
-
$ sudo add-apt-repository ppa:ondrej/php
-
$ sudo apt-get update
Install for Apache
-
$ sudo apt-get install php7.4 php7.4-common php7.4-xml php7.4-cli php7.4-curl php7.4-json php7.4-mcrypt php7.4-mysqlnd php7.4-sqlite php7.4-soap php7.4-mbstring php7.4-zip php7.4-bcmath
Install for Nginx
Install
-
$ sudo apt-get install php7.4-fpm php7.4-common php7.4-xml php7.4-cli php7.4-curl php7.4-json php7.4-mcrypt php7.4-mysqlnd php7.4-sqlite php7.4-soap php7.4-mbstring php7.4-zip php7.4-bcmath
Configure PHP FPM
You will need a text editor for this task. The instructions use Nano which comes installed in Ubuntu
- Edit the php-fpm php.ini file
-
sudo nano /etc/php/7.4/fpm/php.ini
- Find the line that reads
;cgi.fix_pathinfo=1
- Change it to read
cgi.fix_pathinfo=0
- Save and exit (Ctrl+x, Y, <Enter>)
-
PHP MongoDB Extension
- The version of php-mongodb in the APT repositories is no longer high enough to satisfy the requirements of the mongodb repos used. Please install using PECL.
- Make sure you have all the required packages
-
$ sudo apt-get install php7.4-dev php-pear build-essential libsslcommon2-dev libssl-dev libcurl4-openssl-dev pkg-config
-
- Install from PECL
-
$ sudo pecl install mongodb
-
- Create the ini file
-
$ sudo sh -c 'echo "extension=mongodb.so" > /etc/php/7.4/mods-available/mongodb.ini'
-
- Enable the extension
-
$ sudo phpenmod mongodb
-
Composer
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 dfuser. Anywhere you see this username substitute your own.
- Make a bin directory in your home directory if it doesn't already exist.
-
$ cd ~
-
$ mkdir bin
-
- Get the setup file from composer
-
$ php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');"
-
- Install composer to your bin directory
-
$ php composer-setup.php --install-dir=/home/dfuser/bin --filename=composer
-
- Restart your terminal app (if using Linux with a GUI) or log out and log back in.
Database
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.)
MariaDB
Install
- Install the server and client from Apt
- Please follow the instructions on the MariaDB Website to get the version you want. We recommend at least version 10.2.
Setup
- Start MariaDB
-
$ sudo service mariadb start
-
- Login to the database
- (use the root password you provided during installation)
$ mysql -u root -p
-
- 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;
-
- 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 YOUR_PASSWORD_HERE for the password field.
-
GRANT ALL PRIVILEGES ON dreamfactory.* to 'dfadmin'@'localhost' IDENTIFIED BY 'YOUR_PASSWORD_HERE';
-
- Flush privileges on the database and quit.
-
FLUSH PRIVILEGES;
-
quit
-
DreamFactory
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 dfuser. Anywhere you see this username substitute your own.
- 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 dfuser /opt/dreamfactory
-
- Navigate to the working directory and use git to clone the dreamfactory repo
-
$ cd /opt/dreamfactory
-
$ git clone https://github.com/dreamfactorysoftware/dreamfactory.git ./
-
- 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 --ignore-platform-reqs
- Setup the DreamFactory system database connection
- Note: Previously this command was
dreamfactory:setup
ordf:setup
. As of DF 2.7.0 the command is changed todf: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.
- Note: Previously this command was
- Reset permissions on the storage and cache directories.
-
$ sudo chown -R www-data:dfuser storage/ bootstrap/cache/
-
$ sudo chmod -R 2775 storage/ bootstrap/cache/
-
- 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.
Nginx
- Install Nginx from Apt
-
$ sudo apt-get install nginx
-
- Navigate to the configuration directory
-
$ cd /etc/nginx/sites-available
-
- Backup the default config
-
$ sudo cp default default.bak
-
- Edit the default site configuration
- If you have other websites running on your Nginx installation you will need to follow the standard procedure for creating a new virtualhost. Please consult the Nginx documentation for this.
-
$ sudo nano default
- The entire file should look like this when complete:
-
server { listen 80 default_server; listen [::]:80 default_server ipv6only=on; root /opt/dreamfactory/public; index index.php index.html index.htm; server_name server_domain_name_or_IP; gzip on; gzip_disable "msie6"; gzip_vary on; gzip_proxied any; gzip_comp_level 6; gzip_buffers 16 8k; gzip_http_version 1.1; gzip_types text/plain text/css application/json application/javascript text/xml application/xml application/xml+rss text/javascript; location / { try_files $uri $uri/ /index.php?$args; } error_page 404 /404.html; error_page 500 502 503 504 /50x.html; location = /50x.html { root /usr/share/nginx/html; } location ~ \.php$ { try_files $uri =404; fastcgi_split_path_info ^(.+\.php)(/.+)$; fastcgi_pass unix:/var/run/php/php7.4-fpm.sock; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; include fastcgi_params; } }
-
- Save the file and exit.
- Restart PHP-FPM and Nginx
-
$ sudo service php7.4-fpm restart && sudo service nginx restart
-
- Confirm your DreamFactory instance is installed by loading the IP address of your server in a browser. You should be directed to the login page of the admin application.
Apache
- Install Apache from Apt
-
$ sudo apt-get install apache2 libapache2-mod-php7.4
-
- Enable the rewrite engine
-
$ sudo a2enmod rewrite
-
- Navigate to the site configuration and backup the default config
-
$ cd /etc/apache2/sites-available
-
$ sudo cp 000-default.conf 000-default.conf.bak
-
- Edit the default config.
-
$ sudo nano 000-default.conf
- Edit the file so that it looks like the following config
-
<VirtualHost *:80> DocumentRoot /opt/dreamfactory/public <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>
- Save the file and exit
-
- Restart Apache
-
$ sudo service apache2 restart
-
- Confirm that Apache is properly configured by loading the server's IP or hostname in your browser.