Thursday, 11 February 2016

INSTALL HOTSPOT YFI (part 1)


Note : 
Source of the original article : 
http://sourceforge.net/apps/trac/hotcakes/wiki/yfi_setup_cake
I have edited some parts according to my experience
YFI Hotspot Manager network

 Set-up CakePHP

This is last experience and 100% working properly:
Component
Description
Operating System
Ubuntu 10.04 (Lucid Lynx)
Web Server
LAMP Stack
CakePHP
CakePHP version 1.2.11
Coova Chilli
Coovachilli 1.0.14
Radius
FreeRADIUS Version 2.1.12

Install the LAMP stack

  • It is assumed that you have sudo rights on the Ubuntu machine which you want to install YFi Hotspot Manager on. 
  • From the terminal enter the following command:
sudo tasksel
  • Selecting LAMP from the list will install all the required packages. 
  • You will be required to supply a password for the root mysql user. (Hitting Esc each time will create a blank password) 
  • Ensure the PHP command line program is also installed by issuing the following command:
sudo apt-get install php5-cli
  • Install imagemagick which is used to scale graphic files
sudo apt-get install imagemagick
  • Install the following two PHP packages for new enhancements:
sudo apt-get install php5-gd php5-curl

Install Language Packs (optional)

  • From release Beta-3 upwards, YFi Hotspot Manager supports multiple languages
  • Install the following optional language packs in order to ensure proper working for the supported languages.
Language
Command to install language pack
Afrikaans
sudo apt-get install language-pack-af
French
sudo apt-get install language-pack-fr
Indonesian
sudo apt-get install language-pack-id
Malay
sudo apt-get install language-pack-ms
Netherlands
sudo apt-get install language-pack-nl
Thai
sudo apt-get install language-pack-th
Spanish
sudo apt-get install language-pack-es
Portuguese
sudo apt-get install language-pack-pt
German
sudo apt-get install language-pack-de
Danish
sudo apt-get install language-pack-da

  • Or just install them all at once
sudo apt-get install language-pack-af language-pack-fr language-pack-id \
language-pack-ms language-pack-nl language-pack-th language-pack-es \
language-pack-pt language-pack-de language-pack-da

Install CakePHP

  • Download the latest version of CakePHP (version 1.2.11)
  • Copy and extract it inside the directory that Apache is serving its content from (/var/www by default on Ubuntu)
wget https://github.com/cakephp/cakephp/archive/1.2.11.tar.gz
sudo cp cake_1.2.11.tar.gz /var/www
cd /var/www
sudo tar -xzvf cake_1.2.11.tar.gz
sudo ln -s ./cake_1.2.11 ./c2
  • Enable the rewrite Apache module, also enable the compression module and the module that modifies the HTTP headers, they are used to vastly improve speed and performance of the web application. Reload Apache's configuration.
sudo a2enmod rewrite
sudo a2enmod deflate
sudo a2enmod headers
sudo /etc/init.d/apache2 reload
  • Edit the following line in the '/etc/php5/apache2/php.ini' file 
sudo vi /etc/php5/apache2/php.ini
* Change [Line Number: 101]
output_buffering = Off
To
output_buffering = 4096
  • Also ensure short_open_tag is activated in '/etc/php5/apache2/php.ini' [Line Number: 83]
short_open_tag = On
  • Also ensure allow_call_time_pass_reference is set to On in '/etc/php5/apache2/php.ini' [Line Number: 164]
allow_call_time_pass_reference = On
  • Change Apache's configuration file to include the following: ('/etc/apache2/apache2.conf')
sudo vi /etc/apache2/apache2.conf
<Directory  /var/www/c2>
    AllowOverride All
</Directory>
#-------COMPRESS CONTENT-----------
# place filter 'DEFLATE' on all outgoing content
SetOutputFilter DEFLATE
# exclude uncompressible content via file type
SetEnvIfNoCase Request_URI \.(?:exe|t?gz|jpg|png|pdf|zip|bz2|sit|rar)$ no-gzip
#dont-vary
# Keep a log of compression ratio on each request
DeflateFilterNote Input instream
DeflateFilterNote Output outstream
DeflateFilterNote Ratio ratio
LogFormat '"%r" %{outstream}n/%{instream}n (%{ratio}n%%)' deflate
CustomLog /var/log/apache2/deflate.log deflate
# Properly handle old browsers that do not support compression
BrowserMatch ^Mozilla/4 gzip-only-text/html
BrowserMatch ^Mozilla/4\.0[678] no-gzip
BrowserMatch \bMSIE !no-gzip !gzip-only-text/html
#----------------------------------
 
#------ADD EXPIRY DATE-------------
<FilesMatch "\.(ico|pdf|flv|jpg|jpeg|png|gif|js|css|swf)$">
    Header set Expires "Thu, 15 Apr 2012 20:00:00 GMT"
</FilesMatch>
#----------------------------------
 
#--------Remove ETags --------------------
FileETag none
#-----------------------------------------
  • Reload Apache
sudo /etc/init.d/apache2 reload

 Install YFi CakePHP Application

  • YFi Hotspot Manager consists of two components: A CakePHP application and a Viewer.
  • Download the latest version of the YFi Cake application. (yfi_cake-Beta-5.tar.gz)
  • Extract it inside the '/var/www/c2' directory.
wget http://sourceforge.net/projects/hotcakes/files/YFi%20CakePHP%20Application/Beta-5/yfi_cake-Beta-5.tar.gz
sudo cp yfi_cake-Beta-5.tar.gz /var/www/c2/
cd /var/www/c2
sudo tar -xzvf yfi_cake-Beta-5.tar.gz
sudo chown -R www-data. /var/www/c2/yfi_cake/tmp
sudo chown -R www-data. /var/www/c2/yfi_cake/webroot/img/graphics
sudo chown -R www-data. /var/www/c2/yfi_cake/webroot/files

Configure the database

  • You need to create a database called 'yfi' and allow access to it for a username / password combination. 
  • It is good practice to change the default username / password combination. 
  • This can be changed inside the '/var/www/c2/yfi_cake/config/database.php' file. 
  • These sample commands assume the defaults.
mysql -u root
create database yfi;
GRANT ALL PRIVILEGES ON yfi.* to 'yfi'@'127.0.0.1' IDENTIFIED BY 'yfi';
GRANT ALL PRIVILEGES ON yfi.* to 'yfi'@'localhost' IDENTIFIED BY 'yfi';
exit;
  • Dump the sample database in the newly created yfi database.
mysql -u root yfi < /var/www/c2/yfi_cake/setup/db/yfi.sql

Test the CakePHP application

  • Verify that everything works as intended by doing the following test. 
  • Go to the followingURL.
http://127.0.0.1/c2/yfi_cake/users/
  • In my case, I can access from another computer, and browsing to
http://192.168.10.29/c2/yfi_cake/users/

Installing the YFi CakePHP Viewer Component

  • Get the latest viewer component of YFi Hotspot Manager. (version yfi-Beta-5.tar.gz).
  • Copy and extract it inside the directory that Apache is serving its content from (/var/www by default on Ubuntu)
wget http://nchc.dl.sourceforge.net/project/hotcakes/YFi%20Viewer%20Component/Beta-5/yfi-Beta-5.tar.gz
sudo cp yfi-Beta-5.tar.gz /var/www/
cd /var/www
sudo tar -xzvf yfi-Beta-5.tar.gz

Test the Viewer component

  • Go to the following URL http://127.0.0.1/yfi/  (you may need to replace 127.0.0.1 with the IP address of the server you installed the YFi Hotspot Manager on) 
  • You should get a splash page which, depending on the speed of your network connection, will change into a login page. 
  • Log in either as the administrator or as an Access Provider or as a permanent user. 
  • The following table displays the default username and password for each. 


    Role
    Username
    Password
    Administrator
    root
    admin
    Access Provider
    ap
    ap
    Permanent User
    dvdwalt@ri
    dvdwalt@ri