Setting up Xibo using Vagrant on OS X

Setting up Xibo using Vagrant on OS X

Vagrant is a powerful tool for spinning up a dev or test environment quickly and easily. If you have no clue what you are doing like I do currently you may run into trouble.

Why am I using vagrant?

Well, I didn’t WANT to use vagrant but I wanted to try Xibo the open source digital signage project to see if I can use it at work for a project we’re working on. I’ve never used vagrant before but I have heard about it from my friend at Orange County WordPress meetup, folks there use it all the time to get their project running in the environment of their choosing on their local computer. I was looking at the install instructions for Xibo and noticed they had a vagrantfile to use so I thought I’d jump in head first and start learning.

Let’s begin

The docs over at https://github.com/xibosignage/xibo-cms assume you know how to use Vagrant so they don’t give much info on how to get it working. I’m using a mac and chose to use VirtualBox as my VM of choice. I did the following:

  1. Downloaded VirtualBox
  2. Installed VirtualBox
  3. Downloaded Vagrant
  4. created a new folder in my home directory called ‘vagrants’, no idea if this is best practices or not. $ mkdir vagrants
  5. Clone the xibo repro using git
    $ cd vagrants
    $ git clone https://github.com/xibosignage/xibo.git
  6. Created a ‘library’ directory for the files to live, the install will ask for this so we might as well do it now.
    $ mkdir library
  7. Now it’s time to edit the Vagrantfile that xibo provides, this one doesn’t allow for the apache user to write to the “shared folders” so the install would fail. Here is what mine looks like:
    # -*- mode: ruby -*-
    # vi: set ft=ruby :
    
    # Vagrantfile API/syntax version. Don't touch unless you know what you're doing!
    VAGRANTFILE_API_VERSION = "2"
    
    $script = <<SCRIPT
    apt-get -y update
    apt-get -y install libapache2-mod-xsendfile
    apt-get -y install libcurl3 php5-curl
    SCRIPT
    
    $ip = <
    ifconfig
    IP
    
    Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
     config.vm.box = "avenuefactory/lamp"
     config.vm.provision "shell", inline: $script
     config.vm.provision "shell", inline: $ip, run: "always"
    # config.vm.network :private_network, type: "dhcp"
     config.vm.network "public_network", :bridge => "en0: Wi-Fi (Airport)", :ip => "192.168.1.200"
     config.vm.synced_folder "./", "/var/www/html",
     owner: "vagrant",
     group: "www-data",
     mount_options: ["dmode=775,fmode=664"]
     config.vm.synced_folder "../library/", "/var/www/library",
     owner: "vagrant",
     group: "www-data",
     mount_options: ["dmode=775,fmode=664"]
    end

    In a earlier attempt to get this running, the $script part would get stuck since it was asking if I wanted to update [y/N] and the script would fail during the automation. I added in -y to force it to be installed/updated/overwritten.

    apt-get -y update
    apt-get -y install libapache2-mod-xsendfile
    apt-get -y install libcurl3 php5-curl

    Other parts I changed were the WiFi so that the IP address of my vm would be 192.168.1.200 (using the WiFi (Airport) Interface. The first line below is commented so you can see what I changed.

    # config.vm.network :private_network, type: "dhcp"
     config.vm.network "public_network", :bridge => "en0: Wi-Fi (Airport)", :ip => "192.168.1.200"

    I also made changes to the synched folders so that their group permissions would be “www-data”

     config.vm.synced_folder "./", "/var/www/html",
     owner: "vagrant",
     group: "www-data",
     mount_options: ["dmode=775,fmode=664"]
     config.vm.synced_folder "../library/", "/var/www/library",
     owner: "vagrant",
     group: "www-data",
     mount_options: ["dmode=775,fmode=664"]

    That seemed to fix the issue that I was having with not being able to get the install to work. In my example here we’re using 192.168.1.200 that will be the ip address you’ll use to access the install file, more on that in a bit.

  8. Once I set all that up I started vagrant
    $ vagrant up
  9. Vagrant will grab all the stuff that it needs and get things installed.
  10. Now it’s time to access the web interface to install xibo load up a web browser and go to http://192.168.1.200/install.php (or whatever you set it to if your network scope is different from mine)
  11. All of the important checks will be checked and it will let you complete the install.

I’ll be adding more info to this document as I complete my install, check back once I add more info here.