RaspberryPi2

From DreamFactory
Jump to: navigation, search
(Install Apache, MySQL, and PHP)
 
(13 intermediate revisions by the same user not shown)
Line 3: Line 3:
 
Since DreamFactory relies on PHP and Laravel frameworks, the existing Raspbian distribution needs to be upgraded from Wheezy to Jessie. The upgrade process involves some manual work, including updating the package sources for Jessie and building PHP 5.6 from the sources. [https://ubuntu-mate.org/ Ubuntu Mate] is a stable, easy-to-use Debian distribution that can run on Raspberry Pi 2. Since it comes with PHP 5.6, it is easy to install all the required dependencies through simple apt-get install commands.
 
Since DreamFactory relies on PHP and Laravel frameworks, the existing Raspbian distribution needs to be upgraded from Wheezy to Jessie. The upgrade process involves some manual work, including updating the package sources for Jessie and building PHP 5.6 from the sources. [https://ubuntu-mate.org/ Ubuntu Mate] is a stable, easy-to-use Debian distribution that can run on Raspberry Pi 2. Since it comes with PHP 5.6, it is easy to install all the required dependencies through simple apt-get install commands.
  
'''Here is a step-by-step guide to install DreamFactory on Raspberry Pi 2.'''
+
'''Here's a step-by-step guide to install DreamFactory on Raspberry Pi 2.'''
  
 
==Install Ubuntu Mate on Raspberry Pi 2==
 
==Install Ubuntu Mate on Raspberry Pi 2==
Line 20: Line 20:
  
 
* '''Open the terminal window and run the following commands''':
 
* '''Open the terminal window and run the following commands''':
 
 
  
 
<source lang=bash>
 
<source lang=bash>
Line 27: Line 25:
 
mcrypt php5-mcrypt php5-gd php5-mysqlnd mysql-server mysql-client git
 
mcrypt php5-mcrypt php5-gd php5-mysqlnd mysql-server mysql-client git
 
</source>
 
</source>
 
 
  
 
You may be prompted to enter the password for MySQL root user.  
 
You may be prompted to enter the password for MySQL root user.  
Line 34: Line 30:
 
* '''Once that's done, open Firefox in Ubuntu Mate Desktop and visit http://localhost to confirm the installation of Apache. You should see the default Apache2 Ubuntu page.'''
 
* '''Once that's done, open Firefox in Ubuntu Mate Desktop and visit http://localhost to confirm the installation of Apache. You should see the default Apache2 Ubuntu page.'''
  
====Install phpMyAdmin====
+
==Install phpMyAdmin==
  
 
'''Note''':phpMyAdmin will be a handy tool that we can use later. Installing it will confirm that the LAMP stack is properly configured. You can setup phpMyAdmin with just one command:
 
'''Note''':phpMyAdmin will be a handy tool that we can use later. Installing it will confirm that the LAMP stack is properly configured. You can setup phpMyAdmin with just one command:
 
 
  
 
<source lang=bash>
 
<source lang=bash>
Line 44: Line 38:
 
</source>
 
</source>
  
 
+
==Set Up the DreamFactory Database in MySQL==
 
+
====Set up the DreamFactory database in MySQL====
+
  
 
'''Note''':DreamFactory expects a database to be in place during the installation. Run the following commands to set up the database in MySQL:
 
'''Note''':DreamFactory expects a database to be in place during the installation. Run the following commands to set up the database in MySQL:
 
 
  
 
<source lang=bash>
 
<source lang=bash>
 
$  mysql -u root –p
 
$  mysql -u root –p
 
</source>
 
</source>
 
  
 
* '''Within the MySQL environment, run the following SQL commands''':
 
* '''Within the MySQL environment, run the following SQL commands''':
 
 
  
 
<source lang=bash>
 
<source lang=bash>
Line 70: Line 57:
  
 
With all the prerequisites in place, you're now ready to set up DreamFactory. Run the below commands to clone the GitHub repo.
 
With all the prerequisites in place, you're now ready to set up DreamFactory. Run the below commands to clone the GitHub repo.
 
  
 
<source lang=bash>
 
<source lang=bash>
Line 78: Line 64:
 
$ cp .env-dist .env
 
$ cp .env-dist .env
 
</source>
 
</source>
 
  
 
We need to point the DreamFactory environment variables to the MySQL database. To do this, we copied the .env-dist file .env. If you created a user with a different name than df_admin, you need to update the database settings section of the .env file. Otherwise, you need not make any changes to the file.
 
We need to point the DreamFactory environment variables to the MySQL database. To do this, we copied the .env-dist file .env. If you created a user with a different name than df_admin, you need to update the database settings section of the .env file. Otherwise, you need not make any changes to the file.
  
 
'''The directory needs appropriate permissions to function properly. Run the following commands to configure them''':
 
'''The directory needs appropriate permissions to function properly. Run the following commands to configure them''':
 
 
  
 
<source lang=bash>
 
<source lang=bash>
Line 92: Line 75:
 
</source>
 
</source>
  
 
+
==Install Composer==
====Install Composer====
+
  
 
DreamFactory uses Composer to manage dependencies. Let’s go ahead and install it.
 
DreamFactory uses Composer to manage dependencies. Let’s go ahead and install it.
 
  
 
<source lang=bash>
 
<source lang=bash>
Line 103: Line 84:
 
$ sudo mv composer.phar /usr/local/bin/composer
 
$ sudo mv composer.phar /usr/local/bin/composer
 
</source>
 
</source>
 
 
  
 
With Composer in place, it’s time for us to run the update tool.
 
With Composer in place, it’s time for us to run the update tool.
 
  
 
<source lang=bash>
 
<source lang=bash>
Line 113: Line 91:
 
$ sudo composer update
 
$ sudo composer update
 
</source>
 
</source>
 
 
  
 
This will take about 10 minutes to download and configure all the dependencies required by DreamFactory. Before moving to the next step, make sure that Composer is not reporting any errors.
 
This will take about 10 minutes to download and configure all the dependencies required by DreamFactory. Before moving to the next step, make sure that Composer is not reporting any errors.
  
====Configure Apache 2 to run DreamFactory====
+
==Configure Apache 2 to Run DreamFactory==
  
 
There are only a few more steps before we can launch DreamFactory. We need to register the site with Apache, update the ServerName variable, and finalize the configuration.
 
There are only a few more steps before we can launch DreamFactory. We need to register the site with Apache, update the ServerName variable, and finalize the configuration.
 
 
  
 
<source lang=bash>
 
<source lang=bash>
 
$ sudo cp /opt/dreamfactory/server/config/apache/etc/apache2/sites-available/dsp.local.conf  /etc/apache2/sites-available/dreamfactory.conf
 
$ sudo cp /opt/dreamfactory/server/config/apache/etc/apache2/sites-available/dsp.local.conf  /etc/apache2/sites-available/dreamfactory.conf
 
</source>
 
</source>
 
  
 
* '''Edit the dreamfactory.conf file and update the ServerName with the local IP address of Raspberry Pi 2. Replace the DocumentRoot and Directory entries with the actual location of DreamFactory - /opt/dreamfactory/public. Your configuration file should look like this''':
 
* '''Edit the dreamfactory.conf file and update the ServerName with the local IP address of Raspberry Pi 2. Replace the DocumentRoot and Directory entries with the actual location of DreamFactory - /opt/dreamfactory/public. Your configuration file should look like this''':
 
 
  
 
<pre>
 
<pre>
Line 155: Line 126:
 
</VirtualHost>
 
</VirtualHost>
 
</pre>
 
</pre>
 
 
  
 
* '''Run the commands below to finalize the installation process. The final step is to restart Apache.'''
 
* '''Run the commands below to finalize the installation process. The final step is to restart Apache.'''
 
 
  
 
<source lang=bash>
 
<source lang=bash>
Line 168: Line 135:
 
$ sudo service apache2 restart
 
$ sudo service apache2 restart
 
</source>
 
</source>
 
 
  
 
Test the DreamFactory installation by typing the IP address of Raspberry Pi 2.0. After a brief wait of a few seconds, which is required for the first run of DreamFactory, you should see the sign up screen.
 
Test the DreamFactory installation by typing the IP address of Raspberry Pi 2.0. After a brief wait of a few seconds, which is required for the first run of DreamFactory, you should see the sign up screen.

Latest revision as of 19:07, 14 July 2016

DreamFactory can be installed and configured on Raspberry Pi 2 as an open source IoT gateway.

Since DreamFactory relies on PHP and Laravel frameworks, the existing Raspbian distribution needs to be upgraded from Wheezy to Jessie. The upgrade process involves some manual work, including updating the package sources for Jessie and building PHP 5.6 from the sources. Ubuntu Mate is a stable, easy-to-use Debian distribution that can run on Raspberry Pi 2. Since it comes with PHP 5.6, it is easy to install all the required dependencies through simple apt-get install commands.

Here's a step-by-step guide to install DreamFactory on Raspberry Pi 2.

Install Ubuntu Mate on Raspberry Pi 2

Follow the same procedure as setting up Raspbian for installing Ubuntu Mate on Raspberry Pi 2. Download the image, uncompress it, and write it to a SD card. You can take the help of Pi Filler to burn the .img file to the SD card. Boot Raspberry Pi with the SD card and follow the on-screen instructions. Make sure that the operating system is successfully installed.

Pi-filler.png

Pi Filler prompting to insert the SD card

Ubuntu-mate.png

Ubuntu Mate Desktop on Raspberry Pi 2

Install Apache, MySQL, and PHP

  • Open the terminal window and run the following commands:
$ sudo apt-get install –y curl apache2 php5 php5-common php5-cli php5-curl php5-json 
mcrypt php5-mcrypt php5-gd php5-mysqlnd mysql-server mysql-client git

You may be prompted to enter the password for MySQL root user.

  • Once that's done, open Firefox in Ubuntu Mate Desktop and visit http://localhost to confirm the installation of Apache. You should see the default Apache2 Ubuntu page.

Install phpMyAdmin

Note:phpMyAdmin will be a handy tool that we can use later. Installing it will confirm that the LAMP stack is properly configured. You can setup phpMyAdmin with just one command:

$ sudo apt-get install phpmyadmin

Set Up the DreamFactory Database in MySQL

Note:DreamFactory expects a database to be in place during the installation. Run the following commands to set up the database in MySQL:

$  mysql -u root –p
  • Within the MySQL environment, run the following SQL commands:
mysql> create database dreamfactory;
mysql> grant all privileges on dreamfactory.* to df_admin'@'localhost' identified by df_admin';
mysql> quit
  • Clone DreamFactory repo

With all the prerequisites in place, you're now ready to set up DreamFactory. Run the below commands to clone the GitHub repo.

$ cd /opt
$ git clone https://github.com/dreamfactorysoftware/dreamfactory.git
$ cd dreamfactory
$ cp .env-dist .env

We need to point the DreamFactory environment variables to the MySQL database. To do this, we copied the .env-dist file .env. If you created a user with a different name than df_admin, you need to update the database settings section of the .env file. Otherwise, you need not make any changes to the file.

The directory needs appropriate permissions to function properly. Run the following commands to configure them:

$ sudo chown -R www-data:www-data /opt/dreamfactory/
$ sudo chmod -R 777 /opt/dreamfactory/storage/
$ sudo chmod -R 777 /opt/dreamfactory/bootstrap/cache

Install Composer

DreamFactory uses Composer to manage dependencies. Let’s go ahead and install it.

$ cd /opt/dreamfactory
$ sudo curl -sS https://getcomposer.org/installer| php
$ sudo mv composer.phar /usr/local/bin/composer

With Composer in place, it’s time for us to run the update tool.

$ cd /opt/dreamfactory
$ sudo composer update

This will take about 10 minutes to download and configure all the dependencies required by DreamFactory. Before moving to the next step, make sure that Composer is not reporting any errors.

Configure Apache 2 to Run DreamFactory

There are only a few more steps before we can launch DreamFactory. We need to register the site with Apache, update the ServerName variable, and finalize the configuration.

$ sudo cp /opt/dreamfactory/server/config/apache/etc/apache2/sites-available/dsp.local.conf  /etc/apache2/sites-available/dreamfactory.conf
  • Edit the dreamfactory.conf file and update the ServerName with the local IP address of Raspberry Pi 2. Replace the DocumentRoot and Directory entries with the actual location of DreamFactory - /opt/dreamfactory/public. Your configuration file should look like this:
<VirtualHost *:80>
        ServerAdmin webmaster@localhost
        ServerName <RPi2_IP_ADDRESS>

        DocumentRoot "/opt/dreamfactory/public"

        <Directory "/opt/dreamfactory/public">
                Options -Indexes +FollowSymLinks -MultiViews
                AllowOverride All
        Require all granted
        </Directory>

    ErrorLog ${APACHE_LOG_DIR}/dsp.error.log

        # Possible values include: debug, info, notice, warn, error, crit,
        # alert, emerg.
        LogLevel info

        CustomLog ${APACHE_LOG_DIR}/dsp.access.log combined
</VirtualHost>
  • Run the commands below to finalize the installation process. The final step is to restart Apache.
$ sudo a2ensite
$ sudo a2enmod rewrite 
$ sudo php5enmod mcrypt
$ sudo service apache2 restart

Test the DreamFactory installation by typing the IP address of Raspberry Pi 2.0. After a brief wait of a few seconds, which is required for the first run of DreamFactory, you should see the sign up screen.