OpenFlights Installation

OpenFlights is an open-source tool that lets you map your flights around the world. Here are the steps I followed to install it on my server.

Update 2015-09-27: Updated nginx configuration to allow extensionless php files.

After the initial setup of my new server, installation of OpenFlights was simple. Create the database, configure Nginx, download, install and configure WordPress itself.

OpenFlights Install

Firstly I created a new directory for the site:

mkdir -p /var/www/flights.illallangi.com

Then I downloaded and extracted the latest version of OpenFlights:

curl –L -o /tmp/openflights.zip https://github.com/jpatokal/openflights/archive/master.zip
unzip /tmp/openflights.zip -d /var/www/flights.illallangi.com
mv /var/www/flights.illallangi.com/openflights-master /var/www/flights.illallangi.com/openflights

Database Creation

Create an account and a database for OpenFlights:

mysql -p
Enter password:
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 5340 to server version: 3.23.54
 
Type 'help;' or '\h' for help. Type '\c' to clear the buffer.
 
mysql> CREATE DATABASE flights;
Query OK, 1 row affected (0.00 sec)
 
mysql> GRANT ALL PRIVILEGES ON flights.* TO "flights"@"localhost"
    -> IDENTIFIED BY "password";
Query OK, 0 rows affected (0.00 sec)
  
mysql> FLUSH PRIVILEGES;
Query OK, 0 rows affected (0.01 sec)

mysql> EXIT
Bye

Create OpenFlights tables:

cat /var/www/flights.illallangi.com/openflights/sql/create.sql | grep -v CREATE\ [UD] | grep -v GRANT | grep -v CONNECT | mysql -D flights -p

Import initial data:

perl -pi -e "s/data\//\/var\/www\/flights.illallangi.com\/openflights\/data\//g" /var/www/flights.illallangi.com/openflights/sql/load-data.sql
perl -pi -e "s/locale\//\/var\/www\/flights.illallangi.com\/openflights\/locale\//g" /var/www/flights.illallangi.com/openflights/sql/load-data.sql
cat /var/www/flights.illallangi.com/openflights/sql/load-data.sql | mysql -D flights -p --local-infile

Nginx Configuration

I created the /etc/nginx/conf.d/flights.illallangi.com.conf file:

server {
 listen 80;
 server_name flights.illallangi.com;

 index index.php index.html;
 include /etc/nginx/default.d/*.conf;
 root /var/www/flights.illallangi.com/openflights;

 location / {
 try_files $uri $uri/ @php;
 }

 location @php {
 fastcgi_param SCRIPT_FILENAME "$document_root$uri.php";
 fastcgi_param PATH_TRANSLATED "$document_root$uri.php";
 fastcgi_param QUERY_STRING $args;

 include fastcgi_params;
 fastcgi_pass 127.0.0.1:9000;
 fastcgi_index index.php;
 }
}

Restart the nginx service:

systemctl restart nginx

OpenFlightsConfiguration

Create the wp-config.php file and configured it, stealing some code from a gist I found to do it on the command line (rather than editing the file in nano):

cp /var/www/flights.illallangi.com/openflights/php/config.php.sample /var/www/flights.illallangi.com/openflights/php/config.php
perl -pi -e "s/flightdb2/flights/g" /var/www/flights.illallangi.com/openflights/php/config.php
perl -pi -e "s/openflights/flights/g" /var/www/flights.illallangi.com/openflights/php/config.php
perl -pi -e "s/\"\"/\"password\"/g" /var/www/flights.illallangi.com/openflights/php/config.php

File and Directory Permissions

Set permissions on files:

find /var/www/flights.illallangi.com/openflights -type f -exec chmod 664 {} +
find /var/www/flights.illallangi.com/openflights -type d -exec chmod 775 {} +
chown -R apache.nobody /var/www/flights.illallangi.com/openflights

Next Steps

At this point the OpenFlights installation was complete. I pointed DNS for flights.illallangi.com to the new server and browsed to it in Chrome. OpenFlights displayed its initial login.

I could also have restored my database from backup at this point.

Featured Image: “Contrail Indicated” by Zach Stern on flickr.

3 Comments

  1. Andrei
    2015-10-08

    Unfortunately, it seems that with PHP 5.6 it is not working anymore.

    • 2015-10-08

      Yep – running PHP 5.4 on my server. What exactly happens under 5.6?

  2. Andrei
    2015-10-09

    A lot of undefined indexes. My PHP knowledge is quite limited so I cannot figure it how to solve it…

    [09-Oct-2015 13:08:19 Europe/Helsinki] PHP Notice: Undefined index: locale in /mnt/data1/www/openflights/php/locale.php on line 12
    line 12 is:$locale = $_SESSION[“locale”];;

    [09-Oct-2015 13:08:19 Europe/Helsinki] PHP Notice: Undefined index: user in /mnt/data1/www/openflights/php/map.php on line 12
    $user = $_GET[“user”];
    [09-Oct-2015 13:08:19 Europe/Helsinki] PHP Notice: Undefined index: trid in /mnt/data1/www/openflights/php/map.php on line 16
    $trid = $_GET[“trid”];
    [09-Oct-2015 13:08:19 Europe/Helsinki] PHP Notice: Undefined index: bb_userid in /mnt/data1/www/openflights/php/map.php on line 20
    $bb_uid = $_COOKIE[“bb_userid”];
    [09-Oct-2015 13:08:19 Europe/Helsinki] PHP Notice: Undefined index: uid in /mnt/data1/www/openflights/php/map.php on line 38
    [09-Oct-2015 13:08:19 Europe/Helsinki] PHP Notice: Undefined index: guestpw in /mnt/data1/www/openflights/php/map.php on line 58
    [09-Oct-2015 13:08:19 Europe/Helsinki] PHP Notice: Undefined index: xkey in /mnt/data1/www/openflights/php/filter.php on line 12
    [09-Oct-2015 13:08:19 Europe/Helsinki] PHP Notice: Undefined index: xvalue in /mnt/data1/www/openflights/php/filter.php on line 13
    [09-Oct-2015 13:08:19 Europe/Helsinki] PHP Notice: Undefined index: units in /mnt/data1/www/openflights/php/map.php on line 137
    [09-Oct-2015 13:08:19 Europe/Helsinki] PHP Notice: Undefined variable: elite in /mnt/data1/www/openflights/php/map.php on line 142
    [09-Oct-2015 13:08:19 Europe/Helsinki] PHP Notice: Undefined variable: editor in /mnt/data1/www/openflights/php/map.php on line 143

Comments are closed.