Radu Cojocaru Blog
Web development (RubyOnRails) and iPhone development.-
How to setup a VPS with Ubuntu
Posted on July 29th, 2009 1 commentSteps:
- Add user with admin rights
adduser radu visudo
add line:
radu ALL=(ALL) ALL
- Secure SSH access
nano /etc/ssh/sshd_config
add lines:
Port 380 X11Forwarding no AllowUsers radu PermitRootLogin no - Update packages sources
sudo aptitude update
- Set system locale
sudo locale-gen en_GB.UTF-8 sudo /usr/sbin/update-locale LANG=en_GB.UTF-8
- Update system
sudo aptitude safe-upgrade sudo aptitude full-upgrade sudo aptitude install build-essential
- Install Apache and PHP
sudo aptitude install apache2 apache2.2-common apache2-mpm-prefork apache2-utils libexpat1 ssl-cert sudo aptitude install libapache2-mod-php5 php5 php5-common php5-curl php5-dev php5-gd php5-imagick php5-mcrypt php5-memcache php5-mhash php5-mysql php5-pspell php5-snmp php5-sqlite php5-xmlrpc php5-xsl
- Install mysql
sudo aptitude install mysql-server mysql-client libmysqlclient15-dev libmysql-ruby1.8 -y
- Install DNS tools
sudo apt-get install bind9 sudo apt-get install dnsutils
- Install Webmin
wget http://puzzle.dl.sourceforge.net/sourceforge/webadmin/webmin_1.441_all.deb sudo apt-get install libnet-ssleay-perl libauthen-pam-perl libio-pty-perl libmd5-perl sudo dpkg --install webmin_1.441_all.deb
Tips:
# check Ubuntu version cat /etc/lsb-release # restart apache sudo /etc/init.d/apache2 reload # restart apache without closing existing connections sudo apache2ctl graceful # compress tar -cvzf file.tar.gz dir/ # decompress tar -xvzf file.tar.gz # reload SSH configuration /etc/init.d/ssh reload
- Add user with admin rights
-
Generate PDFs in Rails using Prawn
Posted on June 9th, 2009 No commentsI needed recently the ability the generate PDFs from a Rails application (for a personal project). I decided to try Prawn library and it was quite enjoyable: all the code to generate PDFs goes into views (so you can use all your helpers) and it’s pretty easy to create PDFs with a custom layout (boxes in different positions on the page).
Here are some links to the resources I used:
- screencast from Railscasts: http://railscasts.com/episodes/153-pdfs-with-prawn
- Prawn docs: http://prawn.majesticseacreature.com/docs/prawn-core/
- Prawn layout docs, useful if you need to use tables: http://prawn.majesticseacreature.com/docs/prawn-layout/
- Prawnto - a plugin for Rails that allows you to have views with .prawn extension: http://www.cracklabs.com/prawnto
The PDFs that I need to generate were not so complicated (some text in boxes positioned in custom places on the page and a table) and Prawn was a very good solution for that. I’ll write a new post when I’ll use more advanced capabilities like the use of images and fonts.
-
How to Configure ActionMailer with a Gmail Account
Posted on May 2nd, 2009 4 commentsGmail authentication uses SSL and you need to have tlsmail gem installed:
gem install tlsmailActual configuration lines go into config/environments/production.rb:
1 2 3 4 5 6 7 8 9 10 11 12 13 14
# required by Gmail require 'tlsmail' Net::SMTP.enable_tls(OpenSSL::SSL::VERIFY_NONE) # ActionMailer configuration config.action_mailer.perform_deliveries = true config.action_mailer.delivery_method = :smtp config.action_mailer.default_charset = "utf-8" config.action_mailer.raise_delivery_errors = true ActionMailer::Base.smtp_settings = { :domain => "DOMAIN-HERE.COM", :user_name => 'USERNAME-HERE', :password => 'PASSWORD-HERE', :address => 'smtp.gmail.com', :tls => true, :port => 587, :authentication => :login }
Don’t forget to replace the credentials above with the credentials from your account.



