Last update: 2017-04-26
As part of my project to make it easier to contribute I’m setting up a Vagrant virtual machine and provisioning it with all dependencies to build Network Weathermap. In this post I’ll be documenting everything I add to it, in a way that you could use if you’d like to install your own development machine instead. This first post will be updated along the way as I add things. Eventually this might be lifted to the wiki.
The operating system - Ubuntu 16.04 LTS
For the Vagrant I’m using Ubuntu 16.04 LTS, so that’s what these instructions are for.
Why Ubuntu 16.04?
- It’s ‘newbie friendly’, has a good community for people new to Linux and is well documented.
- The LTS releases are supported for 5 years
- It’s very commonly used
- It’s easy to set up with both php 5.6 and 7
- It’s got most of the packages needed in its repositories and the ones not in there work well on Ubuntu
I won’t deal with installing the base OS itself in this post. You will find downloads, documentation and a very helpful community on https://www.ubuntu.com/.
We need GIT to download the Network Weathermap repository. This guide does not cover how to download a copy of the git repo for Network Weathermap (yet) or how to use git, but I will assume that you will download it to a folder named ‘network-weathermap’ in your home folder. Installing git is easy:
sudo apt-get install git
PHP 5 repository
Network Weathermap is in the process of being modified to work on PHP 7, but for now, we need PHP 5.6.
Unfortunately PHP 5.6 is not in the native repos on Ubuntu 16.04 so we need to add one that contains it:
sudo add-apt-repository ppa:ondrej/php sudo apt-get update -y
Installing MySQL is easily done like so:
sudo apt-get install mysql-server-5.7
You may need to choose a root password for MySQL during the installation. Make sure that you can remember it!
Due to changes in MySQL compared to earlier versions, you need to change some settings for backwards compatability to make it work with Cacti 0.x. We’ll add a cacti user and database at the same time. Feel free to change the password in the “identified by”-section, but make sure that you remember it.
sudo mysql -uroot <<EOF SET GLOBAL sql_mode = 'ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION'; create database cacti; grant all on cacti.* to cactiuser@localhost identified by 'cactiuser'; flush privileges; EOF
All the stuff needed to run Cacti and Newtork Weathermap
The headline says most of it. These are the packages that we need to run Cacti 0.8.x and Network Weathermap.
sudo apt-get install snmp rrdtool php7.0 php5.6 php5.6-common php5.6-cli php5.6-mysql apache2 libapache2-mod-php5.6 libapache2-mod-php7.0 php5.6-snmp php5.6-gd php-gettext php5.6-mbstring php-xdebug php5.6-xml unzip
Bower and Composer
When building Network Weathermap there are a lot of dependencies and tools needed. These are fairly simple to get, but we need two tools for that: Bower and Composer. They are basically like small package managers that take care of downloading the correct versions of things that we need. (If you’re like me and never heard of them before, here’s a quick explanation of what the difference between them are. Also note that we use npm to install Bower, since that is mentioned here as well: http://stackoverflow.com/questions/22918517/npm-bower-composer-differences)
First, some dependencies so that we can run these tools, and also a few things already in the Ubuntu repos that we’ll need:
sudo apt-get install -y make xsltproc imagemagick zip curl phpunit nodejs nodejs-legacy npm pandoc
Then, to install Bower:
sudo npm install -g bower
Then we go to the Network Weathermap git folder and let Bower do its magic:
cd ~/network-weathermap bower install
Now onwards to Composer. Download the installer and run it:
curl -sS https://getcomposer.org/installer -o composer-setup.php sudo php composer-setup.php --install-dir=/usr/local/bin --filename=composer
And then we do some more magic:
cd ~/network-weathermap composer install
In vagrant where we have no swap partition and not a lot of memory, Composer can be a bit grumpy. If it hangs during “composer install” we can create a temporary swap partition like this:
sudo /bin/dd if=/dev/zero of=/var/swap.1 bs=1M count=1024 sudo /sbin/mkswap /var/swap.1 sudo /sbin/swapon /var/swap.1
Then try running “composer install” again.
Not done by far!
This post is a work in progress. It is not done by far, but please let me know what you are missing. It should cover all things in the vagrant provisioning script when I’m done. You can find the script here: https://github.com/malgoe/network-weathermap/blob/dev-tools/dev/Vagrant/vagrant-cacti-develop.sh
I’ll edit this post and update it when I find time and energy