This is a little tutorial on how to deploy zena on alwaysdata servers.
Since their free accounts are limited to 10Mo you’ll have to create a paid account. You don’t have to pay right away which means that you’ll have one month to decide wether it’s worth the 9€/month or not.
account
First off you’ll have to create your own account. Your site will be available at [user].alwaysdata.net. Replace [user] anywhere in this tuto with you own login.
Note that every server at alwaysdata (ftp,mysql,...) end with a .com – only your site is available with a .net.
Take a little time to visit your admin back-end. You’ll wonder why you ever used cpanel. You’ll be able to use the same login/password for everything unless you provide one per app (ssh,sql,etc.).
install
Ready? Let’s go:
- Activate SSH in admin back-end.
- Connect with ssh
- Linux: (win: I suggest free bitvise tunnelier for that.)
# ssh [user]@ssh.alwaysdata.com
Create a local gems dir:
# mkdir gems
Add this dir to gem env: (once per session since the server doesn’t store your bash profile but only you bash commands)
# export GEM_PATH=/home/[user]/gems
You will be able to modify ~/.gemrc later on to add you path to you local gems.
Install rmagick:
# gem install --install-dir ~/gems/ --no-ri --no-rdoc rmagick
Install rails version 2.3.4:
gem install --install-dir ~/gems/ --no-ri --no-rdoc -v=2.3.4 rails
Install zena gem:
# gem install --install-dir ~/gems/ --no-ri --no-rdoc zena
Add gem/bin to your path: (once per session)
# PATH=$PATH:/home/[user]/gems/bin
Deploy your zena app:
zena new myapp --with-dispatchers
configure
Create a .htaccess file in /myapp/public containing this :
AddHandler fcgid-script .fcgi AddHandler cgi-script .cgi Options +FollowSymLinks +ExecCGI RewriteEngine On RewriteRule ^$ index.html [QSA] RewriteRule ^([^.]+?)/?$ $1.html [QSA] RewriteCond %{REQUEST_FILENAME} !-f RewriteRule ^(.*)$ dispatch.fcgi [QSA,L]
You can use emacs,vim,nano or admin back-end->footer->file browser/they use full featured net2ftp – prefer server-side editors since dos formated uploaded files will behave badly.
Edit /myapp/config/environment.rb and add these lines at the beginning:
ENV['GEM_PATH'] = ':/home/[user]/gems' RAILS_ENV = 'production'
In the admin interface, create a MySQL database named “zena” and a user named “db” and then change config/database.yml settings:
production: adapter: mysql database: [user]_zena host: mysql.alwaysdata.com port: 3306 username: [user]_db password: secretpassword
initialization
Cd to your app:
# cd myapp
Create your database:
rake db:create RAILS_ENV=production
Migrate:
rake zena:migrate RAILS_ENV=production
Create your site:
rake zena:mksite LANG=en RAILS_ENV=production PASSWORD=admin HOST=[user].alwaysdata.net
Edit /myapp/public/dispatch.fcgi. The first line must be this:
#!/usr/bin/ruby -w
In your admin back-end create a subdomain that points to /myapp/public.
In order to enable full page caching, you need to symlink the site’s “public” folder to the one apache is seeing:
cd /myapp/sites/[user].alwaysdata.net rm -rf public ln -sf ../../public
Fire up your browser:
comments
Thanks for the nice writeup, Manu !
I just added a few lines on MySQL database (see MySQL vs SQLite3 performance on why SQLite3 is not so good in production).
Hi Gaspard,
In the installation on “Dreamhost” tutorial you conlcude telling that there are some limitations on Zena’s functions and log file.
Do we also have limitations here with “Alwaysdata” installation? if yes, will they be fixed by intalling some gems?
Thanks!
I do not know the limitations with alwaysdata: Manu wrote the article. Some problems that you can have in a shared hosting environment: background worker, haproxy, sphinx indexing, ssl support, proper cache management, pdf, Latex, incompatible image library, etc. But these are advanced features (appart from the image library) and can be worked out by changing the hosting provider when the needs arise.