Apt

From DreamFactory
Jump to: navigation, search
(Redirected page to DreamFactory/APT)
 
Line 1: Line 1:
==PHP==
+
#REDIRECT [[DreamFactory/APT]]
* '''Install PHP and dependencies'''
+
<source lang=bash>$ sudo apt-get install git curl php5 php5-common php5-cli php5-curl php5-json php5-gd</source>
+
 
+
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.
+
{| class="wikitable" border="1"
+
|-
+
! DB Type
+
! Package Name
+
|-
+
| MySQL
+
| php5-mysqlnd
+
|-
+
| SQLite
+
| php5-sqlite
+
|-
+
| Postgres
+
| php5-pgsql
+
|-
+
| MS SQL/Sybase
+
| php5-sybase
+
|}
+
 
+
Example:
+
<source lang=bash>$ sudo apt-get install php5-mysqlnd php5-sqlite php5-pgsql php5-sybase</source>
+
 
+
==Database==
+
===SQLite===
+
'''Note''':If you intend to use SQLite as the system database you only need to install php5-sqlite (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:
+
<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.'''
+
<source lang=bash>
+
$ 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
+
</source>
+
 
+
 
+
==Web Server==
+
 
+
===Nginx===
+
 
+
* '''Install the packages for nginx and php-fpm'''
+
<source lang=bash> $ sudo apt-get install nginx php5-fpm</source>
+
 
+
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 <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>
+
 
+
* '''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)
+
<pre>
+
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;
+
 
+
    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/php5-fpm.sock;
+
        fastcgi_index index.php;
+
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
+
        include fastcgi_params;
+
    }
+
}
+
</pre>
+
 
+
* '''Restart nginx'''
+
<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'''
+
<source lang=bash>
+
$ 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/
+
</source>
+
 
+
===Apache===
+
 
+
For more information, see the Ubuntu guide [https://help.ubuntu.com/lts/serverguide/httpd.html#http-installation  here]
+
 
+
<pre>
+
$ sudo apt-get install apache2
+
</pre>
+
 
+
* '''Enable the apache2 rewrite engine.'''
+
 
+
<pre> $ sudo a2enmod rewrite </pre>
+
 
+
* '''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.'''
+
 
+
<pre> $ sudo nano /etc/apache2/sites-available/000-default.conf </pre>
+
 
+
* '''Change the DocumentRoot and the Directory settings'''
+
 
+
<pre>
+
<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>
+
</pre>
+
 
+
* '''Restart the web server'''
+
 
+
<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.
+

Latest revision as of 14:40, 7 December 2017

Redirect to: