--- layout: page title: Manual installation --- # Manual Installation
The following instructions describe the step-by-step process for installing Alaveteli. You don't necessarily need to do it this way: it's usually easier to use the installation script or the Amazon EC2 AMI.
Note that there are [other ways to install Alaveteli]({{ site.baseurl }}docs/installing/). gem install bundler --no-rdoc --no-ri
## Configure Database
There has been a little work done in trying to make the code work with other
databases (e.g., SQLite), but the currently supported database is PostgreSQL
("postgres").
Create a `foi` user from the command line, like this:
sudo -u postgres createuser -s -P foi
_Note:_ Leaving the password blank will cause great confusion if you're new to
PostgreSQL.
We'll create a template for our Alaveteli databases:
sudo -u postgres createdb -T template0 -E UTF-8 template_utf8
echo "update pg_database set datistemplate=true where datname='template_utf8';" > /tmp/update-template.sql
sudo -u postgres psql -f /tmp/update-template.sql
rm /tmp/update-template.sql
Then create the databases:
sudo -u postgres createdb -T template_utf8 -O foi alaveteli_production
sudo -u postgres createdb -T template_utf8 -O foi alaveteli_test
sudo -u postgres createdb -T template_utf8 -O foi alaveteli_development
## Configure email
You will need to set up an email server – or Mail Transfer Agent (MTA) – to
send and receive emails.
Full configuration for an MTA is beyond the scope of this document -- see the guide for [configuring the Exim4 or Postfix MTAs]({{ site.baseurl }}docs/installing/email/).
Note that in development mode mail is handled by [`mailcatcher`](http://mailcatcher.me/) by default so
that you can see the mails in a browser. Start mailcatcher by running `bundle exec mailcatcher` in the application directory.
## Configure Alaveteli
Alaveteli has three main configuration files:
- `config/database.yml`: Configures Alaveteli to communicate with the database
- `config/general.yml`: The general Alaveteli application settings
- `config/newrelic.yml`: Configuration for the [NewRelic](http://newrelic.com) monitoring service
Copy the configuration files and update their permissions:
cp /var/www/alaveteli/config/database.yml-example /var/www/alaveteli/config/database.yml
cp /var/www/alaveteli/config/general.yml-example /var/www/alaveteli/config/general.yml
cp /var/www/alaveteli/config/newrelic.yml-example /var/www/alaveteli/config/newrelic.yml
chown alaveteli:alaveteli /var/www/alaveteli/config/{database,general,newrelic}.yml
chmod 640 /var/www/alaveteli/config/{database,general,newrelic}.yml
### database.yml
Now you need to set up the database config file so that the application can
connect to the postgres database.
Edit each section to point to the relevant local postgresql database.
Example `development` section of `config/database.yml`:
development:
adapter: postgresql
template: template_utf8
database: alaveteli_development
username: foi
password: secure-password-here
host: localhost
port: 5432
Make sure that the user specified in `database.yml` exists, and has full
permissions on these databases.
As the user needs the ability to turn off constraints whilst running the tests
they also need to be a superuser (clarification: a Postgres superuser,
not an Alaveteli
superuser).
If you don't want your database user to be a superuser, you can add this line
to the `test` section in `database.yml` (as seen in `config/database.yml-example`):
constraint_disabling: false
### general.yml
We have a full [guide to Alaveteli configuration]({{ site.baseurl }}docs/customising/config/) which covers all the settings in `config/general.yml`.
_Note:_ If you are setting up Alaveteli to run in production, set the [`STAGING_SITE`]({{ site.baseurl }}docs/customising/config/#staging_site) variable to `0` in `/var/www/alaveteli/config/general.yml` now.
STAGING_SITE: 0
The default settings for frontpage examples are designed to work with
the dummy data shipped with Alaveteli; once you have real data, you should
certainly edit these.
The default theme is the ["Alaveteli" theme](https://github.com/mysociety/alavetelitheme). When you run `rails-post-deploy` (see below), that theme gets installed automatically.
### newrelic.yml
This file contains configuration information for the New Relic performance
management system. By default, monitoring is switched off by the
`agent_enabled: false` setting. See New Relic's [remote performance analysis](https://github.com/newrelic/rpm) instructions for switching it on
for both local and remote analysis.
## Deployment
You should run the `rails-post-deploy` script after each new software upgrade:
sudo -u alaveteli RAILS_ENV=production \
/var/www/alaveteli/script/rails-post-deploy
This installs Ruby dependencies, installs/updates themes, runs database
migrations, updates shared directories and runs other tasks that need to be run
after a software update, like precompiling static assets for a production install.
That the first time you run this script can take a *long* time, as it must
compile native dependencies for `xapian-full`.
Create the index for the search engine (Xapian):
sudo -u alaveteli RAILS_ENV=production \
/var/www/alaveteli/script/rebuild-xapian-index
If this fails, the site should still mostly run, but it's a core component so
you should really try to get this working.
RAILS_ENV=production
. Use
RAILS_ENV=development
if you are installing Alaveteli to make
changes to the code.
nginx-ssl.conf.example
has the path to Alaveteli set as /var/www/alaveteli/alaveteli
– you will need to manually change this to /var/www/alaveteli
, or to the root of your Alaveteli install
nginx.conf.example
has the path to Alaveteli set as /var/www/alaveteli/alaveteli
– you will need to manually change this to /var/www/alaveteli
, or to the root of your Alaveteli install
config/rails_env.rb
, which is used to force the rails environment to production, and edit your .bundle/config
file to remove the BUNDLE_WITHOUT
line that excludes development dependencies. After you have done this, as the alaveteli user, run bundle install
. You will also need to make alaveteli the owner of /var/www/alaveteli/log/development.log
, and run the database migrations.
chown alaveteli:alaveteli /var/www/alaveteli/log/development.log
sudo -u alaveteli bundle exec rake db:migrate
You should then be able to run the tests. Don't forget to restore config/rails_env.rb
when you're done. You will probably see some errors from cron jobs in the meantime, as they'll be running in development mode.