(→Install Ruby) |
m (→Create a database for QA Reports) |
||
| Line 121: | Line 121: | ||
mysql> create user 'qa-reports'@'localhost' identified by 'somepasswordofyourchoosing'; | mysql> create user 'qa-reports'@'localhost' identified by 'somepasswordofyourchoosing'; | ||
mysql> create database qa_reports_production character set 'utf8'; | mysql> create database qa_reports_production character set 'utf8'; | ||
| - | mysql> grant all privileges on qa_reports_production.* to ' | + | mysql> grant all privileges on qa_reports_production.* to 'qa-reports'@'localhost'; |
mysql> flush privileges; | mysql> flush privileges; | ||
mysql> exit | mysql> exit | ||
Contents |
Running and deploying QA Reports relies heavily on automated deployment scripts and version control repository. At high level, deployment process is following:
Capistrano enables you to automate also other administrative tasks like
To achieve all the goodness, you should set up the development environment on your workstation before continuing.
This guide has been written for vanilla Ubuntu 10.04 installation. You need to be logged in to the production server and have sudo rights to continue.
$ sudo aptitude install curl build-essential git-core openssh-server zlib1g-dev libssl-dev libreadline5-dev libcurl4-openssl-dev
$ sudo bash < <( curl -L http://bit.ly/rvm-install-system-wide )
rvm group, e.g.$ sudo adduser jakeskik rvm
$ source ~/.bashrc
$ rvm install ree
$ rvm use --default ree
$ gem install rails bundler --no-ri --no-rdoc #if you have proxy problem, plz refer to http://docs.rubygems.org/read/chapter/13#page51
Finally, enable rvm and Ruby Enterprise Edition to your deployment account, e.g. www-data
/etc/passwd and change www-data's shell from sh to bash. You might want to change the home directory also from /var/www to e.g. /home/www-data as shown belowwww-data:x:33:33:www-data:/home/www-data:/bin/bash
$ sudo adduser www-data rvm $ sudo -iu www-data $ cp ~jakeskik/.profile . $ cp ~jakeskik/.bashrc . $ exit
$ sudo apt-get install apache2 apache2-prefork-dev libapr1-dev libaprutil1-dev $ gem install passenger --no-ri --no-rdoc $ rvmsudo passenger-install-apache2-module # Follow the on-screen instructions and edit apache.conf $ sudo service apache2 restart
$ sudo apt-get install mysql-server libmysqlclient-dev
QA Reports sends email notifications for system administrators (you) in case the application throws an exception. To enable notifications, there needs to be a mail server configured on the production host.
$ sudo apt-get install postfix
The default configuration is fine and allows only delivery for emails originated from localhost. Just click through the installer.
After installing the software, run a sanity check for the environment by creating a 'hello world' rails project and corresponding virtual host:
$ sudo -iu www-data $ rails new hello $ cd hello/public && pwd /home/www-data/hello/public $ exit
Write a following virtual host declaration to /etc/apache/sites-available/hello:
<VirtualHost *:80>
ServerName hello.qa.leonidasoy.fi
DocumentRoot /home/www-data/hello/public
<Directory /home/www-data/hello/public>
AllowOverride all
Options -MultiViews
</Directory>
</VirtualHost>
Enable the virtual host
$ sudo a2ensite hello $ sudo service apache2 restart
Add the virtual host to /etc/hosts file:
127.0.0.1 hello.qa.leonidasoy.fi # Use the same domain as above
Now you should be able to access the 'hello world' project with a browser, e.g. lynx
$ lynx hello.qa.leonidasoy.fi
$ mysql -u root -p mysql> create user 'qa-reports'@'localhost' identified by 'somepasswordofyourchoosing'; mysql> create database qa_reports_production character set 'utf8'; mysql> grant all privileges on qa_reports_production.* to 'qa-reports'@'localhost'; mysql> flush privileges; mysql> exit
Write a following virtual host declaration to /etc/apache/sites-available/qa-reports:
<VirtualHost *:80>
ServerName qa-reports.qa.leonidasoy.fi
DocumentRoot /home/www-data/qa-reports.meego.com/current/public
<Directory /home/www-data/qa-reports.meego.com/current/public>
AllowOverride all
Options -MultiViews
</Directory>
</VirtualHost>
Enable the virtual host
$ sudo a2ensite qa-reports
$ sudo service apache2 restart # Don't mind the warning about missing dir,
# we'll deal with that one in a sec
QA Reports uses Capistrano to automate the deployments. The main benefit is to eliminate the risks of human errors and to enable easy and repeatable rollbacks. See Capistrano documentation for the details.
Capistrano is run from your development environment, so you should be now on your workstation with working QA Reports development environment to continue.
Set up public key authentication:
QA Reports uses following scripts to configure Capistrano
You might want to review all the files, but usually it's enough to update only config/deploy/production.rb according to your needs (servers, deployment account, ssh options). You can also create new deployment environment just by copying the production.rb, to e.g. internal.rb and modify it.
Once the Capistrano is updated according to your needs, run
$ cap production deploy:setup # or cap internal deploy:setup, if you created a new deployment environment
Setup command creates the folder hierarchy and the symbolic links required by Capistrano. During the setup it requests following information
Once the setup is complete, the deployment is as easy as it gets
$ cap production deploy:migrations
You should now have QA Reports up&running. Congrats!
git pull (In case there's changes in the deployment scripts)
cap production deploy:migrations
cap production deploy:rollback
Edit nginx configuration installation_path/conf/nginx.conf: