The setup in this guide is demonstrated in below video as well if you want to watch and follow the guide at the same time!
This guide relies heavily on Vagrant and assumes some previous knowledge of how to use and/or troubleshoot vagrant.
Recommended: Vagrant host-updater plugin - this is useful to avoid having to update /etc/hosts by hand
VirtualBox - Note: Windows users may be required to Enable VT-X (Intel Virtualization Technology) in the computer's bios settings, disable Hyper-V on program and features page in the control panel, and install the VirtualBox Extension Pack (installation instructions here.)
PHP >=7.0 <7.2 - if you are using Platform V4.0.0
PHP >=7.1 <7.4 - if you are using Platform V4.1.0 or later
PHP >=7.2 <7.4 - if you are using Platform V4.4.0 or later
Clone the repository (this will create a directory named platform)
git clone https://github.com/ushahidi/platform.git
Go into the platform directory
Switch to the develop branch
git checkout develop
Once you have the code, the next step is to prepare a web server. For this part, we will use vagrant, with the Vagrant and Homestead.yml files that ship with Ushahidi.
First up we need to install the PHP dependencies. In the platform directory, run:
composer install --ignore-platform-reqs
Bring up the vagrant server. Since this is the first time you run it, it will also provision the machine from scratch:
Our vagrant box is built on top of Laravel's Homestead, a pre-packaged Vagrant box that provides a pre-built development environment. Homestead includes the Nginx web server, PHP 7.1, MySQL, Postgres, Redis, Memcached, Node, and all of the other goodies you might need.
Verify that Vagrant and VirtualBox are up to date.
Verify that the VirtualBox Guest Additions were installed (and fix it if they weren't)
vagrant ssh (to ssh into the machine. If you get an error like 'the path to your private key does not exist' when doing
vagrant ssh, you need to generate a key, or if you already have one, double-check the path in the file "Homestead.yaml" . One good guide on generating keys is found here: https://help.github.com/en/github/authenticating-to-github/generating-a-new-ssh-key-and-adding-it-to-the-ssh-agent#generating-a-new-ssh-key)
lsmod | grep vboxguest
If this command doesn't return anything, VB Guest additions are likely not installed correctly. A fix for this is to install the vbguest vagrant plugin.
if you are in the vagrant box, type
exit and hit the return key to exit it
vagrant plugin install vagrant-vbguest
vagrant up --provision to continue
If that doesn't work, and you are in a linux or MacOS environment (this is not compatible with Windows!):
open the Homestead.yml file
type: "nfs" to the two directory mappings as shown below
-map: "./"to: /vagranttype: "nfs"-map: "./"to: /home/vagrant/Code/platform-apitype: "nfs"
sudo update-alternatives --set php /usr/bin/php7.1
192.168.33.110 platform-api192.168.33.110 api.ushahidi.test
At this point you should have a running web server, but your deployment isn't set up yet. We still need to configure the database and run the migrations.
Copy the configuration file
.env.example to make sure the platform can connect to the database.
cp .env.example .env
Run the migrations. This is required to be able to use your deployment, since it includes basic data such as an initial "admin" user, roles, the database schema itself, etc.
Go to http://192.168.33.110 in your browser to check the API is up and running. You should see some JSON with an API version, endpoints and user info.
Congratulations! You have set up the API. You may want now to build and install the web client for a full experience.