Apt

From DreamFactory
Jump to: navigation, search
Line 1: Line 1:
## PHP
+
==PHP==
Install PHP and dependencies
+
* '''Install PHP and dependencies'''
 
<source lang=bash>$ sudo apt-get install git curl php5 php5-common php5-cli php5-curl php5-json php5-mcrypt php5-gd</source>
 
<source lang=bash>$ sudo apt-get install git curl php5 php5-common php5-cli php5-curl php5-json php5-mcrypt php5-gd</source>
  
Be sure to enable mcrypt
+
* '''Be sure to enable mcrypt'''
 
<source lang=bash>$ sudo php5enmod mcrypt</source>
 
<source lang=bash>$ sudo php5enmod mcrypt</source>
  
You'll also want to make sure you install the php drivers for your database of choice. The following db driver types are installable from Apt with no configuration required.
+
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
 
DB Type | Package Name
 
--- | ---
 
--- | ---
Line 17: Line 17:
 
<source lang=bash>$ sudo apt-get install php5-mysql php5-sqlite php5-pgsql php5-sybase</source>
 
<source lang=bash>$ sudo apt-get install php5-mysql php5-sqlite php5-pgsql php5-sybase</source>
  
## Database
+
==Database==
###SQLite
+
===SQLite===
 
If you intend to use SQLite as the system database you only need to install php5-slite (see above.)
 
If you intend to use SQLite as the system database you only need to install php5-slite (see above.)
  
###MySQL/MariaDB
+
===MySQL/MariaDB===
 
If you intend to use MySQL/MariaDB as the system database you will need to install database server package and a client.
 
If you intend to use MySQL/MariaDB as the system database you will need to install database server package and a client.
 
Example:
 
Example:
 
<source lang=bash>$ sudo apt-get install mysql-server mysql-client</source>
 
<source lang=bash>$ sudo apt-get install mysql-server mysql-client</source>
  
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.
+
* '''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.'''
 
<source lang=bash>
 
<source lang=bash>
 
$ mysql -u root -p
 
$ mysql -u root -p
Line 40: Line 40:
  
  
## Web Server
+
===Web Server===
  
### Nginx
+
===Nginx===
  
Install the packages for nginx and php-fpm
+
* '''Install the packages for nginx and php-fpm'''
 
<source lang=bash> $ sudo apt-get install nginx php5-fpm</source>
 
<source lang=bash> $ sudo apt-get install nginx php5-fpm</source>
  
Line 50: Line 50:
 
You should see a page indicating successful installation.
 
You should see a page indicating successful installation.
  
Now you will need to configure php-fpm
+
* '''Now you will need to configure php-fpm'''
 
Edit the file /etc/php5/fpm/php.ini
 
Edit the file /etc/php5/fpm/php.ini
 
Find the line that says <pre>;cgi.fix_pathinfo=1</pre> and change it to be <pre>cgi.fix_pathinfo=0</pre>
 
Find the line that says <pre>;cgi.fix_pathinfo=1</pre> and change it to be <pre>cgi.fix_pathinfo=0</pre>
 
Restart php-fpm <source lang=bash>$ sudo service php5-fpm restart</source>
 
Restart php-fpm <source lang=bash>$ sudo service php5-fpm restart</source>
  
Configure Nginx to use PHP FPM
+
* '''Configure Nginx to use PHP FPM'''
 
We'll be editing the default site server block. The file is /etc/nginx/sites-available/default.
 
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
 
If you want to edit a different virtual host you will need to create a new server block
Line 91: Line 91:
 
</pre>
 
</pre>
  
Restart nginx
+
* '''Restart nginx'''
 
<source lang=bash>$ sudo service nginx restart</source>
 
<source lang=bash>$ sudo service nginx restart</source>
  
If you have not already done so make sure the web server can read and write to dreamfactory storage/ and bootstrap/cache/ folders
+
* '''If you have not already done so make sure the web server can read and write to dreamfactory storage/ and bootstrap/cache/ folders'''
 
<source lang=bash>
 
<source lang=bash>
 
$ sudo chown -R {www user}:{your user group} /path/to/dreamfactory/storage/ /path/to/dreamfactory/bootstrap/cache/
 
$ sudo chown -R {www user}:{your user group} /path/to/dreamfactory/storage/ /path/to/dreamfactory/bootstrap/cache/
Line 100: Line 100:
 
</source>
 
</source>
  
### Apache
+
===Apache===
  
For more information, see [Ubuntu's guide](https://help.ubuntu.com/lts/serverguide/httpd.html#http-installation);
+
For more information, see the Ubuntu guide [https://help.ubuntu.com/lts/serverguide/httpd.html#http-installation here]
  
 
<pre>
 
<pre>
Line 108: Line 108:
 
</pre>
 
</pre>
  
Enable the apache2 rewrite engine.
+
* '''Enable the apache2 rewrite engine.'''
  
> $ sudo a2enmod rewrite
+
<pre> $ sudo a2enmod rewrite </pre>
  
Enable Site
+
* '''Enable site'''
  
 
Finally, we need to configure Apache to connect to the DreamFactory application.
 
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.
 
Below are the instructions to change the default site on Apache. For instructions on setting up virtual hosts, review the Apache documentation.
  
In this example we will edit the Apache default configuration file.
+
* '''Edit the Apache default configuration file.'''
  
> $ sudo nano /etc/apache2/sites-available/000-default.conf
+
<pre> $ sudo nano /etc/apache2/sites-available/000-default.conf </pre>
  
Change the DocumentRoot and the Directory settings
+
* '''Change the DocumentRoot and the Directory settings'''
  
 
<pre>
 
<pre>
Line 145: Line 145:
 
</pre>
 
</pre>
  
Restart the web server
+
* '''Restart the web server'''
  
> $ sudo service apache2 restart.
+
<pre> $ sudo service apache2 restart. </pre>
  
 
Your DreamFactory Application should now be active, and available by entering the DNS name or IP address of your server into a web browser.
 
Your DreamFactory Application should now be active, and available by entering the DNS name or IP address of your server into a web browser.

Revision as of 16:30, 6 February 2016

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

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

MySQL/MariaDB

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.