Apt

From DreamFactory
Jump to: navigation, search

PHP

  • Install PHP and dependencies
$ sudo apt-get install git curl php5 php5-common php5-cli php5-curl php5-json php5-mcrypt php5-gd
  • Be sure to enable mcrypt
$ sudo php5enmod mcrypt

You'll also want to make sure you install the php drivers for your database of choice. The following db driver types are installed with Apt and no additional configuration is required. DB Type | Package Name --- | --- MySQL | php5-mysql SQLite | php5-sqlite Postgres | php5-pgsql MS SQL/Sybase | php5-sybase

Example:

$ sudo apt-get install php5-mysql php5-sqlite php5-pgsql php5-sybase

Database

SQLite

Note:If you intend to use SQLite as the system database you only need to install php5-slite (see above.)

MySQL/MariaDB

Note:If you intend to use MySQL/MariaDB as the system database you will need to install database server package and a client. Example:

$ sudo apt-get install mysql-server mysql-client
  • Then you will need to create a database for DreamFactory to use. You do not have to use the database name and credentials in this example.
$ mysql -u root -p
//enter your mysql root password
//create the database
mysql> create database dreamfactory;
//grant privileges to a user for the database
mysql> grant all privileges on dreamfactory.* to 'df_admin'@'localhost' identified by 'df_admin';
//flush privileges and quit
mysql> flush privileges;
mysql> quit


Web Server

Nginx

  • Install the packages for nginx and php-fpm
 $ sudo apt-get install nginx php5-fpm

Once the package is installed you can verify it is running by pointing your web browser to the server's IP address or resolvable hostname. You should see a page indicating successful installation.

  • Now you will need to configure php-fpm

Edit the file /etc/php5/fpm/php.ini

Find the line that says
;cgi.fix_pathinfo=1
and change it to be
cgi.fix_pathinfo=0
Restart php-fpm
$ sudo service php5-fpm restart
  • Configure Nginx to use PHP FPM

We'll be editing the default site server block. The file is /etc/nginx/sites-available/default. If you want to edit a different virtual host you will need to create a new server block We're going to give nginx instructions for where the root directory is, the server name, to look for php files as index, error handling, and php processing. When you're finished editing it should look like this (not including comments)

server {
    listen 80 default_server;
    listen [::]:80 default_server ipv6only=on;

    root /path/to/dreamfactory/public;
    index index.php index.html index.htm;

    server_name server_domain_name_or_IP;

    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/php5-fpm.sock;
        fastcgi_index index.php;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        include fastcgi_params;
    }
}
  • Restart nginx
$ sudo service nginx restart
  • If you have not already done so make sure the web server can read and write to dreamfactory storage/ and bootstrap/cache/ folders
$ sudo chown -R {www user}:{your user group} /path/to/dreamfactory/storage/ /path/to/dreamfactory/bootstrap/cache/
$ sudo chmod -R 2775 /path/to/dreamfactory/storage/ /path/to/dreamfactory/bootstrap/cache/

Apache

For more information, see the Ubuntu guide here

$ sudo apt-get install apache2
  • Enable the apache2 rewrite engine.
 $ sudo a2enmod rewrite 
  • Enable site

Finally, we need to configure Apache to connect to the DreamFactory application. Below are the instructions to change the default site on Apache. For instructions on setting up virtual hosts, review the Apache documentation.

  • Edit the Apache default configuration file.
 $ sudo nano /etc/apache2/sites-available/000-default.conf 
  • Change the DocumentRoot and the Directory settings
<VirtualHost *:80>
    DocumentRoot /opt/dreamfactory/public

    <Directory /opt/dreamfactory/public>
        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>
  • Restart the web server
 $ sudo service apache2 restart. 

Your DreamFactory Application should now be active, and available by entering the DNS name or IP address of your server into a web browser.