How To Install The IHSN National Data Archive Software on an Ubuntu Linux Server

How To Install The IHSN National Data Archive Software on an Ubuntu Linux Server

From DataFirst

Jump to: navigation, search

Introduction

Software has been designed by the International Household Survey Network (IHSN)[1] to facilitate the archiving and dissemination of survey microdata produced by National Statistics Offices (NSO's). The software is open source and can be downloaded for free from the IHSN website.

Documentation for the installation of the NADA software on Windows servers is available on the IHSN website [2]. What follows is a description of how to install the software on an Ubuntu Linux Server.


Requirements

This How To assumes that the Ubuntu Linux Server operating system has been installed. If you have not installed the operating system then the guides found at the URL below should help you:

https://help.ubuntu.com/

Choose the guide for the version of Ubuntu you are installing.

Ubuntu Server 64bit 9.04 (Jaunty) was used for this installation, but this guide should apply to other versions of Ubuntu (and probably Debian) as well.

You will also need to have the following installed:

  1. Apache webserver
  2. Mysql, Postgres or Sqlite - this guide will describe the installation using Mysql
  3. PHP 4.4 or above
  4. The NADA 2.0 application available from [3]
  5. NB You will need to have root or super-user rights to install this software -ask your server administrator for help if you do not have the necessary rights to install this software.


Installation

This guide assumes that your server does not have any of the above software installed and provides a step-by-step guide to the installation of the required software. If you already have an Apache server, Mysql and PHP installed then you can skip to the configuration section.

The Apache Web Server, Mysql and PHP can be installed simultaneously by installing the LAMP software bundle.

To install LAMP type the following command from the command line (if you are using a graphical environment then first open up a terminal window):

sudo tasksel

You will be prompted for the root password. Enter this password and the following screen will appear.

File:Tasksel-LAMP.gif

Use the arrow key to move the curser to the option LAMP Server then press the space bar to select it for installation. Press the tab key to highlight the OK button and press enter. The software will begin installing.

During installation you will be prompted to enter a password for the root Mysql account.

File:LAMP-Mysql.gif

You should do so and make a note of this password as you will need it later! Once the installation is complete the program will exit to the command line. You now have the Apache web server, Mysql and PHP installed.

To test if Apache is installed go to a web browser and type localhost as the URL. If the Apache web server is running you will be greeted with the IT WORKS! message.

To test if PHP is correctly installed create a text file called info.php with the following contents and save it to /var/www/

sudo nano /var/www/info.php

enter the following text into the file

<?php echo phpinfo(); ?>

Save the file with the following command

Ctrl O then enter to confirm.
Ctrl X to exit

Now open a web browser and browse to http://localhost/info.php from the local machine. If you are accesing the server from another machine enter the ip address or your site's web address followed by /info.php.


If PHP is correctly installed you will see a screen like this:

File:Php_info.gif


Configuration

Now that the required software is installed you need to configure PHP with the necessary extensions to run the NADA software as well as create a Mysql database for the NADA installation.

  • PHP Extension installation

The NADA application requires the following extensions:

xml xsl mysql sqlite

Installation of these is easy with Ubuntu- type at the command line:

sudo apt-get install php5-mysql php5-sqlite php5-xsl

Then restart the Apache Server

sudo /etc/init.d/apache2 restart

Now make a few changes to the File_upload size settings in the PHP configuration file php.ini

sudo nano /etc/php5/apache2/php.ini

In the file find the line upload_max_filesize = 2M and change the 2M to at least 8M

Then press Ctrl O and then enter to save the file then Ctrl x to exit. Note the section on settings for php.ini in the official IHSN documentation for the NADA application is also relevant for Linux - so if you want to know more about this then read that section of the guide.

Note that unlike Windows and some other distributions under Ubuntu you do not need to 'activate' the extensions in php.ini. This is all automatically handled by the Ubuntu intaller.


  • Create a Mysql database and user for the nada installation

At the command line type:

mysql -u root -p

Enter your root password you set when you installed the LAMP server.

To create a database called nada for the NADA application type and then hit enter.

mysql> CREATE DATABASE nada;

Now create a Mysql user called nada who has permission to access the nada database created above.

mysql> GRANT SELECT, INSERT, UPDATE, DELETE, CREATE, DROP, INDEX, ALTER, CREATE TEMPORARY TABLES,
LOCK TABLES ON nada.*  TO 'nada'@'localhost' IDENTIFIED BY 'yourpassword';
mysql> exit


'yourpassword' can be anything you choose. nada is the name of the database the user gets access to. localhost is the location which gets access to your database. Note as before remember this password you will need it later!

Install the NADA Application:

Make a directory for the nada software in the /var/www folder (or wherever your web server files are stored if you have configured your Apache web directory in a different location) and download the NADA software to it. You could also download the software from the link below using your browser and then copy it (as root - i.e. sudo) to /var/www/nada

cd /var/www/
sudo mkdir nada
cd /var/www/nada/
sudo wget http://www.ihsn.org/nada/downloads/nada2.0_20090806.zip

Then unzip the file:

sudo unzip nada2.0_20090806.zip

Now you need to change the permissions on some of the nada sub-directory folders to allow writing to those directories:

sudo chmod -R a+rwx /var/www/nada/stock/datasets
sudo chmod -R a+rwx /var/www/nada/pages

You should now have all the required programs and permissions set to run the NADA application. If you would like to test that all is in order before continuing you can copy the contents of the following PHP script Status.php and save it to a text file called status.php in the root of your nada folder on your server. You can overwrite the existing status.php as some changes have been made to the supplied one.

Open status.php in your web browser http://localhost/nada/status.php.

If all is well then you should see a yes next to the extensions mysql,xsl,mysql as well as yes next to the write permissions on the /pages and /stock/datsets directories. Your max file upload settings should also match or exceed the recommended settings. If any of the above say no then go back to the relevant section above and check you completed all the steps. Ignore the No's next to sqlite,mssql,pgsql and the pdo's -we don't need them for our installation.

Your output should look like this:


File:Status.gif

  • Configure the NADA software

Open the NADA configuration file:

cd /var/www/nada
sudo nano inc_config.php

The section in the official IHSN guide on this applies:

Change the following lines to match your site and server:

define ("WEBSITE_TITLE",'National Data Archive');//website title e.g. National Data Archive of <>
define ("WEBSITE_URL",'http://yourwebsite.org/nada');//website url. no ending slashes
define ("WEBSITE_WEBMASTER_EMAIL", 'webmaster@yourwebsite.org');//website webmaster email
define ("WEBSITE_WEBMASTER_NAME", 'webmaster');//website webmaster email

Change the SMTP settings to match your server's settings - change SMTP authentication to false if you don't require authentication.

//SMTP SETTINGS
define('SMTP_HOST','mail.yourwebsite.org');//smtp host
define('SMTP_PORT',25);
define('SMTP_AUTH',true); //true, false depending on your SMTP server requires authentication or not
define('SMTP_USERNAME','user@yourwebsite.org');
define('SMTP_PASSWORD',);

In the section on //DATABASE SETTINGS change the following line:

define ("DB_TYPE",'sqlite'); //database driver e.g. mssql, mysql, sqlite, postgres

to

define ("DB_TYPE",'mysql'); //database driver e.g. mssql, mysql, sqlite, postgres

as we are using the Mysql database.

Change the following line

define ('DB_USER','ihsn');//database username for connecting to the database

to

define ('DB_USER','nada');//database username for connecting to the database

The database user we defined above

Change the following line:

 define ('DB_PASS',);//database user password

to

define ('DB_PASS','yourpassword');//database user password 

Change your language settings if you are not using English -otherwise you are done. Save the file (Ctrl O) enter then (Ctrl X) to exit.

Now open a web browser and type:

http://localhost/nada/install/mysql.php


If the NADA database installation has been succesful then your output should look like this:

File:NADA-mysql.gif

If you see errors related to connecting to the database check your database settings in inc_config.php and make sure the username and password lines in the Database settings are correct.

You have completed the installation! Browse to http://localhost/nada and you should see the following:

File:NADA-done.gif

Closing remarks

  1. You should now customise your NADA site as described in the official documentation available on the IHSN website.
  2. On a production server you may wish to read the following article to set up Apache in a more "secure" manner [[4]]. The above will get your NADA site up and running, but for production environments you will need to read more specific documents on Apache security and setup on Linux servers.