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.

This post was published quite some time ago and likely contains out of date information.

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/

Then I downloaded and extracted the latest version of OpenFlights:

curl –L -o /tmp/
unzip /tmp/ -d /var/www/
mv /var/www/ /var/www/

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)
Query OK, 0 rows affected (0.01 sec)

mysql> EXIT

Create OpenFlights tables:

cat /var/www/ | grep -v CREATE\ [UD] | grep -v GRANT | grep -v CONNECT | mysql -D flights -p

Import initial data:

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

Nginx Configuration

I created the /etc/nginx/conf.d/ file:

server {
 listen 80;

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

 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_index index.php;

Restart the nginx service:

systemctl restart nginx


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/ /var/www/
perl -pi -e "s/flightdb2/flights/g" /var/www/
perl -pi -e "s/openflights/flights/g" /var/www/
perl -pi -e "s/\"\"/\"password\"/g" /var/www/


File and Directory Permissions

Set permissions on files:

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

Next Steps

At this point the OpenFlights installation was complete. I pointed DNS for 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.

Be First to Comment

Leave a Reply

Your email address will not be published. Required fields are marked *