-
Notifications
You must be signed in to change notification settings - Fork 97
Installation Instructions for Ubuntu 12.04 Precise
This page describes the process of running of the development version of Honolulu Answers site on your Ubuntu 12.04. The following guide has been tested on clean virtual machine.
The site is written on Ruby, so you need to set up the Ruby development environment with all the libraries (gems) necessary.
The following commands will set them up for you:
$ sudo apt-get install ruby1.9.1-dev # the Ruby itself
$ sudo apt-get install libxslt1-dev libsasl2-dev # libraries needed by gems we install later
$ sudo apt-get install g++ # to be able to compile native part of gems
$ sudo apt-get install postgresql-9.1 postgresql-server-dev-9.1 # The site is using PostgreSQL in production
$ sudo apt-get install sqlite3 libsqlite3-dev # sqlite is used for testing
$ sudo apt-get install git-core # Need git to easily get the code on your system.
The main article describes the process in detail. I used what is called 'alternative server setup there', which is useful when you don't want to connect to the PostgreSQL server from other machines.
##Original Postgres Config
After PostgreSQL server is installed (see above), we can connect to it (and do something with) only by user named postgres
. So use commands below to add yourself as a superuser for your server:
$ sudo -u postgres createuser --superuser $USER
$ sudo -u postgres psql
$ postgres=# \password $USER # <== here I had to write my own username by hand, environment variable didn't work for me
$ \q # <== Exit out of Postgres
$ sudo -u postgres createdb $USER
To say the site how to connect to your newly set database server, you also need to copy config/dblogin.yaml.sample
to config/dblogin.yaml
. I also had to write my Ubuntu username with Ubuntu user password there to make it work.
##Updated Postgres Config
Note: "createuser" will prompt you for a password for database user
$ sudo -u postgres createuser <<USER>> --no-createdb --no-superuser --no-createrole --pwprompt
$ sudo -u postgres createdb <<DB NAME>> --owner=<<USER>>
In order for your database to be created and populated, you also need to copy config/dblogin.yaml.sample
to config/dblogin.yaml
. Once copied, edit the file and enter in the db_name, user, and password you just created.
The application expects some local variables to be initialised during start-up. To prepare them, you need to copy .env.sample
file in the root of the sources to .env
file:
$ cp .env.sample .env
We will edit this file later.
Next, we need to setup keys to online services. The site uses Searchify in production, but that one only has paid plans. I used IndexDen service, which allows you to index up to 15000 documents with up to 5 indexes, with unlimited number of requests. As an alternative, you can add the searchify
addon to a Heroku app and copy the provided search API endpoint to your .env
file (see above). You can also run a local copy of Indextank (which is what Searchify is built on), or use another free-to-pay service, for example, HoundSleuth.
To use IndexDen, you need to register there and click on the Create index
link on the upper right corner of the page. Then copy the Private URL and put it to your .env
file, to SEARCHIFY_API_INDEX
value. Also put the name of the index you created to the SEARCHIFY_API_INDEX
value. All the variables already exist in the file.
The Honolulu Answers site also uses BigHugeThesaurus to enchance search queries. In order to run it in development you also need and API key. Just go by the link above and follow the instructions to receive it. After you got the key, put it to the BHT_API_KEY
variable value in the .env
file you have created.
Leave all other fields in the .env
file as they are for now.
The .env
and config/dblogin.yaml
files are added to .gitignore
, but you should check that twice to avoid committing of your secret keys and passwords :)
The last step we need to overcome is to setup the actual Ruby environment. To do so, execute the following commands from the root of the sources:
$ sudo gem install bundler
$ sudo gem install foreman
$ bundle install
If the last command is failed with yellow text, you probably miss some native dependencies (and this guide should be corrected). Just use the terminal output in couple with Google Search to figure out what dependency you need to install.
Now we need to setup the database. Use the following command from the root of the sources to create it:
$ rake db:create
$ rake db:schema:load
You can also want to set up some sample data to see how the site works. To do so, use the following command:
$ rake db:seed
After the process above is completed you can launch the site:
$ foreman start
The launch process is slow enough, don't worry. Default port is 3000, it is also set in your .env
file, so you can use the following address to connect: http://localhost:3000.
Please correct this Wiki page if you experience any troubles with this guide.