Installation Ubuntu 16

From DreamFactory
Jump to: navigation, search
DreamFactoryAPTUbuntu 16.04Installation Ubuntu 16

Prerequisites

DreamFactory requires certain applications for install and other functionality.

  1. 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.

Install for Apache

  1. $ sudo apt-get install php php-mbstring php-zip php-curl php-mongodb php-sqlite3 php-mysql


Install for Nginx

Install

  1. $ sudo apt-get install php-fpm php php-mbstring php-zip php-curl php-mongodb php-sqlite3 php-mysql

Configure PHP FPM

You will need a text editor for this task. The instructions use Nano which comes installed in Ubuntu

  1. Edit the php-fpm php.ini file
    • sudo nano /ect/php/7.0/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>)


Composer

Composer is a PHP dependency manager and is required for installing DreamFactory.

  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('https://getcomposer.org/installer', 'composer-setup.php');"
  3. Install composer to your bin directory
    • $ php composer-setup.php --install-dir=/home/username/bin --filename=composer
  4. 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. We recommend MariaDB for this. Other supported system databases are SQLite, PostgreSQL, and Microsoft SQL.

MariaDB

Install

  1. Install the server and client from Apt
    • $ sudo apt-get install mariadb-server mariadb-client

Setup

  1. Login to the database
    • $ sudo mysql
  2. 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;
  3. 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';
  4. 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.

  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 dfuser /opt/dreamfactory
  2. Navigate to the working directory and use git to clone the dreamfactory repo
    • $ cd /opt/dreamfactory
    • $ git clone https://github.com/dreamfactorysoftware/dreamfactory.git ./
  3. Use composer to get dependencies
    • Note for commercial users Copy your commercial license files into the working directory at this point.
    • $ composer install --no-dev
  4. Setup the DreamFactory system database connection
    • $ php artisan dreamfactory:setup
      • Select option 1 for MySQL. Answer the onscreen prompts regarding database connection and credentials (which you set in the Database section.)
    • $ php artisan dreamfactory:setup
      • Answer the onscreen prompts to create your first admin user for the system.
  5. Reset permissions on the storage and cache directories.
    • $ sudo chown -R dfuser:www-data 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.

Nginx

  1. Install Nginx from Apt
    • $ sudo apt-get install nginx
  2. Navigate to the configuration directory
    • $ cd /etc/nginx/sites-available
  3. Backup the default config
    • $ sudo cp default default.bak
  4. 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.0-fpm.sock;
                fastcgi_index index.php;
                fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
                include fastcgi_params;
            }
        }
    • Save the file and exit.
  5. Restart PHP-FPM and Nginx
    • $ sudo service php7.0-fpm restart && sudo service nginx restart
  6. 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.