+1 571-297-6383 | info@sonjara.com

Installing Fakoli on Linux

This chapter will guide you through setting up Fakoli on a Linux server. For the purposes of this tutorial we will assume that the server is a new generic install. We are also initially going to assume an Ubuntu or Debian server for the sake of simplicity. I will add instructions for Red Hat and CentOS later, and if anyone would like to contribute installation instructions for other linux and Unix flavors I would be most appreciative.

Step 1 - Install Pre-requisites

First you will need to install the pre-requisite software.

Install Apache 2 and enable mod_rewrite

sudo apt-get install apache2
sudo a2enmod rewrite

Install PHP 7

sudo apt-get install php
sudo apt-get install php-pear

Install Mysql 5 and PDO Extension

sudo apt-get install mysql-server
sudo apt-get install mysql-client
sudo apt-get install php-mysql

Install the Alternative PHP Cache

Fakoli makes extensive use of caching to improve performance. With older versions of PHP (prior to 5.5) this was handled via the Alternative PHP Cache module. If you are using PHP 5.5 or older, use the following command to install APC.

sudo apt-get install php-apc

From PHP 5.5 onward, APC has been deprecated as the Zend OpCache opcode cache was integrated into PHP's core. However, an equivalent to the userland cache provided by APC was not included as part of this integration. In order to provide this feature for Fakoli when running PHP 5.5+, install the following module instead, which provides the userland caching from APC while being compatible with Zend Opcache.

sudo apt-get install php-apcu

Install other common modules

Some other modules are commonly used by Fakoli applications.

sudo apt-get install php-gd php-curl php-mbstring

If you are wanting to make use of Fakoli's PDF generation component, you will need to install the wkhtmltopdf application.

sudo apt-get install wkhtmltopdf

If you are running on a headless Linux server without X Windows, you will need to also install the xvfb utility to allow wkhtmltopdf to render correctly.

sudo apt-get install xvfb

Step 2 - Install Fakoli Library Files

First you will need to decide where your web related files are going to live. Common choices are /srv/www or /var/www. I will be using /srv/www in this tutorial as I generally find it leaves the file system a little less cluttered (there are a lot of other things already in var, such as logs, locks, etc).

First, create a directory for your PHP libraries to live in:

mkdir /srv/www/phplibs

Next, unpack the Fakoli library into a sub-directory within this directory using one of the two following methods:

1) Install Via Subversion

Installing from Subversion is our recommended mode of deployment. It will help you keep your Fakoli installation up-to-date. First, if you don't have Subversion installed on your server, run the following:

sudo apt-get install subversion

Then check out from our Sourceforge repository:

cd /srv/www/phplibs
sudo svn checkout https://svn.code.sf.net/p/fakoli/code/trunk fakoli

The above is the command for the most recent stable build. You can also check out specific versioned builds by tag.

2) Installing From Tarball

cd /srv/www/phplibs
sudo wget -c https://downloads.sourceforge.net/project/fakoli/Stable Release/fakoli_3.1.0.tgz
tar xvfz fakoli_3.1.0.tgz

(Obviously you will have to update the version number based on the current Fakoli release).

Step 3 - Update the include_path in php.ini

Next you will need to update the include_path variable in your php.ini file. On an Ubuntu system this file lives in /etc/php5/apache/. On CentOS and most other Linux variants the file lives in either /etc or /etc/php. Edit the file using nano (or your favorite editor) and change the include_path line to:

include_path = ".:/srv/www/phplibs/fakoli:/srv/www/phplibs"

After saving the file, run

sudo apachectl restart

to make sure the changes are picked up by Apache.

Step 4 - Create a blank Fakoli web site from Skeleton files

Next we need to create a web folder for our new Fakoli web site containing just the Fakoli web support files. The easiest way to do this is as follows (assuming in the commands below that your new site is to be called fakoli.mydomain.com):

cd /srv/www/
sudo mkdir vhosts
cd /srv/www/vhosts
sudo wget -c https://downloads.sourceforge.net/project/fakoli/Web Site Skeleton/fakoli_web_files.tgz
sudo tar xvzf fakoli_web_files.tgz
sudo mv fakoli_web_files fakoli.mydomain.com
chown -R www-data fakoli.mydomain.com
chgrp -R www-data fakoli.mydomain.com

Step 5 - Create a writable Document Upload area and a Logging area

Some Fakoli components including the standard document library and image gallery require a writable area outside of the application's web root. To do this we run the following:

cd /srv/www
sudo mkdir uploads
cd uploads
mkdir fakoli.mydomain.com
mkdir fakoli.mydomain.com/documents
chown -R www-data fakoli.mydomain.com
chgrp -R www-data fakoli.mydomain.com
chmod -R 664 fakoli.mydomain.com

Whilst we are at it we might as well also create a logging directory for our trace files:

cd /srv/www
sudo mkdir logs
chown -R www-data logs
chgrp -R www-data logs
chmod -R 664 logs

Step 6 - Create an empty database schema instance

First log into MySQL using your root account.

mysql -u root -p

You will be prompted for the root password - note that this is the MySQL root password, not the password for your root user (these should always be different). Once you are logged in, issue the following commands:

create database fakoli;
grant all on fakoli.* to fakoli@localhost identified by 'abc123';
quit;

Note - the database schema, user and password do not have to be called fakoli and abc123. This is just an example setup.

Step 7 - Configure the Fakoli site's include files

There are two main files within your Fakoli application's web directory that contain all the configuration information the application will need to operate. Those files are in the include sub-folder and are called config.inc and connection.inc.

Edit config.inc

First, issue the following command to go to the configuration directory:

cd /srv/www/vhosts/fakoli.mydomain.com/include

(Where fakoli.mydomain.com is replaced with the name of your site). Now edit the config.inc file in your favorite editor. It will initially look something like this:

<?php
/**
 * Application configuration variables.
 */
$config = array(

    "sitename"      => "%{SITENAME}",
    "homedir"       => "%{HOMEDIR}",
    "uploadbase"    => "%{UPLOADBASE}",
    "uploaddir"     => "documents", 		/* Directory for uploads */
    "email_from"    => "%{EMAIL_FROM}", 	/* From address for generated emails */
    "http_host"	    => "%{HTTP_HOST}",		/* URL for this server */

    "email_contact" => "%{EMAIL_CONTACT}", 	/* Email Address for contact */
    "email_name"    => "%{EMAIL_NAME}", 	/* Name of contact */
    
    "trace_path"    => "%{TRACE_PATH}",		/* File path to trace output log */
    "trace_level"   => 3,			/* Debugging trace level (0-5) */
    "trace_detail"  => TraceDetailHigh,		/* Detail level for trace output */

    // Application specific settings - migrate to ApplicationSettings?
    "enable_user_login"		=>	true,
    "thumbnail_size"		=>	75,
    "prettyURLs"		=>	true,
    "admin_SSL"			=>	false
);

$auto_form_defaults = array(

	"labelCSS"	=> "label",
	"buttonCSS"	=> "button",
	"componentPath"	=> "/fakoli"
);


require_once realpath(dirname(__FILE__))."/connection.inc";
require_once realpath(dirname(__FILE__))."/defaults.inc";
require_once "framework/functions.inc";

/**
 * Pull out a simple reference to the request method
 */
$method = $_SERVER["REQUEST_METHOD"];
?>

You can see all the fields you need to update are nicely picked out for you with %{}. It's almost like someone was in the middle of writing an installer, right? All you have to do is replace those paths with the paths to the folders we set up during our previous steps. The application name should be unique for the server, but is otherwise unimportant. Once we have updated all the values, the file should look something like this:

<?php
/**
 * Application configuration variables.
 */
$config = array(

    "sitename"      => "My New Fakoli Site",
    "homedir"       => "/srv/www/vhosts/fakoli.mydomain.com",
    "uploadbase"    => "/srv/www/uploads/fakoli.mydomain.com",
    "uploaddir"     => "documents", 		/* Directory for uploads */
    "email_from"    => "me@mydomain.com", 	/* From address for generated emails */
    "http_host"	    => "fakoli.mydomain.com", /* URL for this server */

    "email_contact" => "me@mydomain.com", 	/* Email Address for contact */
    "email_name"    => "Webmaster", 	/* Name of contact */
    
    "trace_path"    => "/srv/www/logs",		/* File path to trace output log */
    "trace_level"   => 3,			/* Debugging trace level (0-5) */
    "trace_detail"  => TraceDetailHigh,		/* Detail level for trace output */

    // Application specific settings - migrate to ApplicationSettings?
    "enable_user_login"		=>	true,
    "thumbnail_size"		=>	75,
    "prettyURLs"		=>	true,
    "admin_SSL"			=>	false
);

$auto_form_defaults = array(

	"labelCSS"	=> "label",
	"buttonCSS"	=> "button",
	"componentPath"	=> "/fakoli"
);


require_once realpath(dirname(__FILE__))."/connection.inc";
require_once realpath(dirname(__FILE__))."/defaults.inc";
require_once "framework/functions.inc";

/**
 * Pull out a simple reference to the request method
 */
$method = $_SERVER["REQUEST_METHOD"];
?>

Edit connection.inc

The connection.inc file contains the Database connection URL. Edit that and replace the parameters with the details of the database schema and user created in step 6. It should look something like this when done:

<?php

require_once "framework/connection_manager.inc";

ConnectionManager::$dsn = "mysql:dbname=fakoli;host=localhost";
ConnectionManager::$user = "fakoli";
ConnectionManager::$password = "abc123";
	 
?>

Step 8 - Add a site configuration file to Apache and a reference in /etc/hosts

To create a site configuration file that registers your new site with Apache, do the following:

cd /etc/apache2/sites-available
sudo nano fakoli.mydomain.com

and add the following content to the file:

<VirtualHost *:80>
ServerName fakoli.mydomain.com
DOcumentRoot /srv/www/vhosts/fakoli.mydomain.com
UseCanonicalName On
HostnameLookups Off
</VirtualHost>

Then run the commands

sudo a2ensite
sudo apachectl restart

Now edit your /etc/hosts file and add the line:

127.0.0.1    fakoli.mydomain.com

or arrange your DNS record with your ISP or DNS server.

Step 9 - Profit??

The site should now be correctly configured for first time access. Open a browser and go to http://fakoli.mydomain.com/. On first access Fakoli will detect that the schema has not been created and will bootstrap the installed component configuration to automatically build the database. A default administration user is created with the username admin and password admin. You can access the site administration screens from the url http://fakoli.mydomain.com/admin/. Your very first task should be to change that admin password.

And now you are ready to go. The following chapters will help you get started with configuring site templates and building out the components that will make up your own application. If this installation has felt long and arduous, then the good news is that to install another Fakoli site on this same server you will only have to start at Step 4 - you have already done the hard work of setting up everything so that the core Fakoli codebase can be shared and updated easily.


Installing Fakoli on Windows » « General Installation Concepts