Skip to main content

Setting Up Known on Ubuntu

4 min read

I'm assuming that both both apache2 and php5 are installed on your server (Ubuntu 14) already.  But that you've done nothing more than get those two things setup using the very simple instructions at the ubuntu documentation.  In setting mine up I only ran the following commands:

sudo apt-get install php5 libapache2-mod-php5

Next up I used the basic list of system requirements at the known site to start getting the other stuff that isn't installed by default with php.

Before you can install the various extensions you're going to need PEAR which is a package manager for

sudo apt-get install php-pear

I am using mongodb as my backend for Known so next up I have to install mongo and the mongo extension for PHP:

sudo apt-get install mongodb
apt-get install php5-dev
sudo pecl install mongo
You'll notice that I also installed php5-dev; that's because the pecl install of mongo uses it to build the mongo extension for PHP as it installs it.  When you do install the mongo extension it will ask if it should build with enterprise authentication support - I said no.  You have to make your own decision.
After you get the mongo extension installed you need to tell php about it.  Go to /etc/php5/apache2/ and edit php.ini and add:
extension=mongo.so
Now, running down the list of required components the following should exist without you having to do anything:
  • date
  • dom
  • fileinfo
  • gd
  • json
  • libxml
  • mbstring
  • reflection
  • session
You will need to manually install the others like so:
  • curl - sudo apt-get install curl libcurl3 libcurl3-dev php5-curl 
  • intl - sudo apt-get install php5-intl
  • oauth - this is tricky.
So oauth should just install with sudo pecl install oauth but it probably will fail for you.  First I needed to install the PCRE libraries; 
sudo apt-get install libpcre3-dev
Then I could install oauth
sudo pecl install oauth
And, just like with the mongodb extension before you have to tell php about it by editing the php.ini file and adding extension=oauth.so.
 
Once you have all of those things installed you should restart your apache service:
sudo service apache2 restart
Now, for me, I wanted to pull Known from git and run that copy instead of downloading the zip file.  This way I could make changes to the code and submit pull requests.  So first I forked the repo at git and then I pulled down my own copy.  Honestly, how you get the known source on your server is up to you.  If you use git to pull the repo make sure you pull all the submodules as well by using the --recursive switch!  If you don't you're going to have a bad time.

The installation instructions claim that mongo stuff will work without you having to do anything - but if you have mysql and mongo installed that wasn't true for me.  I had to create a config.ini file in the root of my Known install with the following info in it:
dbstring=mongodb://localhost
dbname=Known
Once that was there I could try to install Known using the installation wizard.  If the install wizard loads the "/begin" page but it says 404 page not found you don't have URL rewriting turned on.  Make sure mod rewrite is enabled and then try again:
sudo a2enmod rewrite
sudo service apache2 restart
 
Note: if you try to do this on a vagrant box with port forwarding you'll have problems.  The site does a lot of redirects and it doesn't keep the port number in the url.  For instance I have it running on port 80 on the vagrant box but had port 80 exposed as port 8080 to my host machine.  When I tried to visit known from my host machine it redirected me to port 80 and it didn't work properly.  There is probably something you can do in the .htaccess file or something to fix this but I'm not very solid with redirect logic so I won't delve into that here.  I just turned off my normal webserver and changed the exposed port mapping so I could test these instructions.