Installing FRAPI

As FRAPI is currently under active beta development, the installation process
isn't quite as smooth as we'd like it to be. This chapter intends to make installing
FRAPI as simple and pain free as possible. You might want to give the document a read-through
before you begin the install.

Requirements and Dependencies

FRAPI

(Enabled by default and strongly recommended)APC: Required for caching of actions, errors, etc. See the Caching Adapters section for more details on other caching mechanisms available.

(Required by the admin interface)PHP Gettext is used for multilingualism in the administration interface. On Ubuntu Linux, install the package php-gettext.

(Required by the admin interface)XMLWriter is used to write all of the configuration files. This extension is enabled by default in PHP core but it is known to be disabled in some PHP packages.

Redis

(Not required by default)PHP Redis: FRAPI uses APC as the default caching mechanism, therefore, the phpredis extension is not required in FRAPI by default. However, if your favourite caching mechanism is Redis, and you want to use it with FRAPI and exploit the built-in caching benefits, then, the phpredis library is required.

Downloading the Tarball

Uncompress the tar using the tar -xzvf frapi-frapi-VERSION.tar.gz command.

Setting Directory and File Permissions

You're about see a lot of references to something called
FRAPI_PATH. This is simply a shorthand way of saying, "Where
you've chosen to install FRAPI." If you've placed the FRAPI codebase in /var/www/frapi,
then you should read FRAPI_PATH as /var/www/frapi.

Directory Ownership

Since FRAPI is a web application, the web-user will need to have varying
levels of access to FRAPI_PATH. This user is sometimes apache,
nobody, www-data, or some other user (please refer to the documentation for
your web server and operating system to determine the appropriate user if you
are not sure). During development and testing (including production, in some
cases) you will need access to those files as well.

First, determine the web-user's group. This is usually named the same as the web-user

Finally, issue the chown command to change ownership of FRAPI_PATH to yourself and the web-user group

chown -R username.web-user FRAPI_PATH

Directory Permissions

You need to make sure that both
FRAPI_PATH/src/frapi/custom/Action/ and
FRAPI_PATH/src/frapi/custom/Config are readable,
writable, and executable by the web-user, but only readable and executable to
everyone else (0775). You also want to make sure that the XML
files in FRAPI_PATH/src/frapi/custom/Config are
readable and writable by the web-user, but only readable to everyone else
(0664).

If you're using Linux you could run the FRAPI_PATH/setup.sh script. The setup.sh script will
initialize the ArmChair submodule and set directory permissions with the commands you see above.

sudo sh setup.sh

Configuring Apache

Setting up FRAPI's Administration Interface Virtual Host

In order to setup FRAPI's admin interface, you'll need to setup a virtual
host with the following configuration:

<VirtualHost *:80>
ServerName admin.frapi
DirectoryIndex index.php
ServerAdmin admin@api.frapi
# This should be omitted in the production environment
SetEnv APPLICATION_ENV development
DocumentRoot FRAPI_PATH/src/frapi/admin/public
<Directory FRAPI_PATH/src/frapi/admin/public>
AllowOverride All
Order deny,allow
Allow from All
</Directory>
</VirtualHost>

Make sure the server name (hostname of your api – if developing
locally you may want to add admin.frapi to your /etc/hosts file) and the
FRAPI_PATH (Defined in Setting Directory and File Permissions) are correct then restart Apache.

If you open your browser to http://admin.frapi you should now see a
screen with a login and password (Username: admin, password:
password)

Setting up the API frontend

The API frontend is the API that third party developers will be accessing. Very
much like the administration interface, add a new site to your available sites
in Apache with the following configuration:

<VirtualHost *:80>
ServerName api.frapi
ServerAdmin admin@api.frapi
DocumentRoot FRAPI_PATH/src/frapi/public
# This should be omitted in the production environment
SetEnv APPLICATION_ENV development
<Directory FRAPI_PATH/src/frapi/public>
AllowOverride All
Order deny,allow
Allow from All
</Directory>
</VirtualHost>

Again, make sure the server name (hostname of your api – if developing
locally you may want to add api.frapi to your /etc/hosts file) and the
FRAPI_PATH (Defined in Setting Directory and File Permissions) are correct then restart Apache.

If you open your browser to http://api.frapi you should now see an XML payload that has an error that has the code
ERROR_INVALID_ACTION_REQUEST

Configuring Nginx

NOTE: At echolibre we run nearly all our FRAPI services
under Nginx for performance reasons. We therefore recommend using Nginx instead
of Apache whenever possible when it comes to FRAPI.

Before we Start

This documentation section assumes that you have Nginx setup to run with
PHP as FastCGI. If you haven't setup
php-fastcgi and Nginx, please read this blog
post as it will be vital to your understanding and fulfillment of
this setup.

FastCGI Parameters

Here's a list of the parameters you'll need in your fastcgi_params in order
for Nginx and FRAPI to work nicely together:

Make sure the server name (hostname of your api – if developing
locally you may want to add admin.frapi to your /etc/hosts file) and the
FRAPI_PATH (Defined in Setting Directory and File Permissions) are correct then restart Nginx.

If you open your browser to http://admin.frapi you should now see a
screen with a login and password (Username: admin, password:
password)

Setting up the API frontend

The API frontend is the API that third party developers will be accessing. Very
much like the administration interface, add a new site to your available sites
in Nginx with the following configuration:

Again, Make sure the server name (hostname of your api – if developing
locally you may want to add api.frapi to your /etc/hosts file) and the
FRAPI_PATH (Setting Directory and File Permissions) are correct then restart Nginx.