Hi there, This post I want to write as a log of my success on configuring Postgresql database to production for my Rails application. 
Let’s get started. I’ve installed Postgresql 8.4 through apt-get.
The first step I do is to change the password of ‘postgres’ user.
Run the command on root shell.
passwd postgres
And I usually allow remote access into my Postgresql database. So, I have to edit the file ‘/etc/postgresql/8.4/main/pg_hba.conf’ by seeing this line.
local all all ident
and change it to…
local all all md5
Then restart the service.
/etc/init.d/postgresql-8.4 restart
The second step I usually do is to install the admin pack.
su - postgres psql template1 < /usr/share/postgresql/8.4/contrib/adminpack.sql psql -d template1 -c "ALTER USER postgres WITH PASSWORD 'newpassword';"
The next step is to create a new database and user to be used by your application. Assume the application is named ‘Social Dating’.
createdb socialdatingdb createuser socialdatinguser --pwprompt psql socialdatingdb GRANT ALL TO socialdatinguser
Then you can test CRUD on the database with…
psql -U socialdatinguser -W socialdatingdb
Enjoy Postgresql!
Please share this page to anyone who think it is helpful for them.
Hi guys,
This thread was written by me to be used as a future reference of mine and I would like to share here for some people who is struggling with setting up Rails applications on their own Linode cloud VPS.
First of all, let me introduce what is Linode and why I choose it over its alternatives.
Linode is a cloud VPS provider which is quite well known by people who is working on cloud technology.
Linode offer various cheap plans when compared to competitors and its performance is still better from them. (based on the benchmark I found from here)
With just $19.95/mo, I got 20GB disk space, 200GB outgoing bandwidth (now incoming bandwidth is free) and 512MB of memory.
This entry level offer is unbeatable while compared to Slicehost (now bought and managed by Rackspace), Amazon EC2 or Prgmr.
Let’s me say that before I decide to go with Linode, I’ve research a lot about Rails application hosting which finally ends up with Heroku because my project has a short time of development and deployment so I can’t waste my time setting up a box for it.
When the app is live and running smoothly, now I want to improve my ROI and want to make it more cost effective when I demand for more resources.
That’s the reason why I’m moving out from Heroku and ends up with Linode.
That’s a short introduction why I ends up with Linode and now let’s get started seeing how do I set up a Rails application on Linode cloud VPS successfully.
How to set-up Rails application on Linode.
1st, Sign-up for Linode
Just pick a plan you think it is fit for your needs. For me, the Linode 512 is more than enough by now.
After picked up a plan, you will be asked to enter credit card and choose the data center location, just pick one that close to your target visitors. I saw last time there is Asia data center, anyway, I choose Newark, NJ, USA as my target will be in USA.
2nd, Create your Linux node
After sign-up was completely, now I’m going to create a new node by choosing a linux distribution to be use with. I choose Ubuntu 10.0.4 LTS which is 32-bit because there are many sources saying that 32-bit performance is better than 64-bit of Ubuntu.
Just allocate the disk space and swap size that you think it will fits your needs. For me, I just choose the maximum because I need to setup only single node. If you want to separate database server from your web server, just remain some space for your second node.
After the node was built, just push the “Boot” button to start your node now.
3rd, connect to your node using SSH
Now click on the “Remote Access” tab from your dashboard to see the IP address of your node.
Let’s see the “SSH Access” field, it should have some text like “ssh root@11.22.33.44″.
This is the command being used to connect to your node remotely.
Let’s say you are using Mac OSX or Linux, you can use terminal to execute the command.
Then, enter your specified password and you will ends up connected to your node completely.
Note that, you can remote access into your Linode without entering password by appending your computer’s public key to Linode’s authorized keys. This can be done by…
- Open up your terminal
- If you don’t have an existing public key (the file ‘id_rsa.pub’ in ‘~/.ssh/’ folder), then you should do it by issuing this command
</div> <div>ssh-keygen -t rsa -C "youremail@email.com"</div> <div># Note that you will be asked to enter the passphrase. Just enter and remember it.</div> <div>
- Run this command to copy the content of your public key to the clipboard ‘cat ~/.ssh/id_rsa.pub | pbcopy’
- Now connect to your Linode through ssh
- Create a file ‘~/.ssh/authorized_keys’ and paste the content of your public key there, then save
4th, basic configuration
Begin with updating system, run these commands.
apt-get update apt-get upgrade --show-upgraded
Next is to set the host name. This is not actually a host name or domain name you want your Linode to host. It can be anything. Let’s say I’ve named it ‘mickey’.
Run the following commands. (don’t forget to change ‘mickey’ to your own host name)
echo "mickey" > /etc/hostname hostname -F /etc/hostname
Now it’s time to update your /etc/hosts file to let them know your host name.
I issue the command ‘vi /etc/hosts’ to edit the file.
Add the following lines into the file. (you have to enter your Linode’s IP address in the first line, and the IPv6 in the second line, also don’t forget to change ‘mickey’ and host name with your desired name)
12.34.56.78 mickey.example.com mickey 1234:1234::1234:1234:1234:1234 mickey.example.com mickey
Next, it’s time to configure the time zone. I usually set UTC as my time zone for all of my Linodes.
dpkg-reconfigure tzdata
Select UTC from the list, or just select your desired time zone.
Then you need to make a symbolic link to your time zone info.
ln -sf /usr/share/zoneinfo/UTC /etc/localtime
If you are using any other time zone than UTC, then you should find your time zone info in the ‘/usr/share/zoneinfo/’ directory.
Ok, let’s go to the next step. I hate ASCII, so I configure my box to use UTF-8 by editing the ‘~/.bashrc’ file to include these lines.
export LANG="en_US.UTF-8" export LC_CTYPE="en_US.UTF-8"
The basic configuration is completed now.
5th, installing Ruby
First, you need to install some pre-requisite libraries.
apt-get install build-essential bison openssl libreadline6 libreadline6-dev libcurl4-openssl-dev git-core zlib1g zlib1g-dev libssl-dev libyaml-dev libsqlite3-0 libsqlite3-dev sqlite3 libxml2-dev libxslt-dev autoconf libc6-dev curl
Note that the above is a single line command.
If you are using MySQL, you need to execute the following command.
apt-get install mysql-server mysql-client
Also, if you are using Image Magick library, run this command.
apt-get install libmagickwand-dev imagemagick
Now it’s time to install Ruby. I choose to use RVM as it can handle multiple versions of Ruby installation. Run this shell command.
bash < <(curl -s https://raw.github.com/wayneeseguin/rvm/master/binscripts/rvm-installer)
Check if the RVM was installed correctly.
type rvm | head -1
It should output ‘rvm is a function’. This prove you are correct in this step.
Now I decide to install the latest version of Ruby.
rvm install ruby
If you want to install the specific version of Ruby, you can do it by…
rvm install ruby-1.9.2
Wait a few minutes and it’s time to configure the default version of Ruby to be used by the Linode.
rvm --default use 1.9.2-p290 rvm gem set use global # install gems to this gemset gem install rdoc gem install bundler
Now it’s time to install Passenger and Nginx and make it start up at boot.
gem install passenger rvmsudo passenger-install-nginx-module rvm wrapper 1.9.2-p290@global passenger curl -L http://bit.ly/nginx-ubuntu-init-file > /etc/init.d/nginx chmod +x /etc/init.d/nginx update-rc.d nginx defaults /etc/init.d/nginx start
Wooo Hooo, now my Linode is ready to run Rails app and serve web visitors.
However, for my Linode, I need Postgresql as my production database server. So, I would required to run…
apt-get install postgresql postgresql-contrib apt-get install libpq-dev gem install pg
Now the box we created is fully packed with Ruby, Nginx, Passenger, it’s ready now.
6th, time to deploy your Rails application
We will deploy using another user than root regards to security reason. Let’s add one by…
adduser deploy adduser deploy rvm
Then, logout from current ssh session and re-login using the deploy user.
As I’m using GitHub as my Git server, I need to create a public key for deploy user and add the key to GitHub account.
So, I create a public key by…
ssh-keygen -t rsa -C "youremail@email.com"
Then login to GitHub account and add the key (~/.ssh/id_rsa.pub) to the GitHub account.
Also, I copy the token of my GitHub account.
Then I configure my Git.
git config --global user.name 'FirstName LastName' git config --global user.email 'myemail@email.com' git config --global github.user 'githubusername' git config --global github.token 012345678901234567890 #change the long digit to your GitHub's token
Now get back to your workstation which you are using to develop your Rails application. (The following steps not being run at your Linode box!)
This step is not sure if it required or not, so please try at your own risk.
Create a file ‘setup_load_paths.rb’ in the ‘config’ directory of your Rails application. Then add the following content.
if ENV['MY_RUBY_HOME'] && ENV['MY_RUBY_HOME'].include?('rvm')
begin
rvm_path = File.dirname(File.dirname(ENV['MY_RUBY_HOME']))
rvm_lib_path = File.join(rvm_path, 'lib')
$LOAD_PATH.unshift rvm_lib_path
require 'rvm'
RVM.use_from_path! File.dirname(File.dirname(__FILE__))
rescue LoadError
# RVM is unavailable at this point.
raise "RVM ruby lib is currently unavailable."
end
end
ENV['BUNDLE_GEMFILE'] = File.expand_path('../Gemfile', File.dirname(__FILE__))
require 'bundler/setup'
Then add ‘capistrano’ into your Gemfile and run ‘bundle install’.
Now it’s time to prepare capistrano.
capify .
Then prepend the following lines in the file ‘Capfile’ which was created by the above ‘capify’ command.
# Add RVM's lib directory to the load path.
$:.unshift(File.expand_path('./lib', ENV['rvm_path']))
# Load RVM's capistrano plugin.
require "rvm/capistrano"
# Set it to the ruby + gemset of your app, e.g:
set :rvm_ruby_string, 'ruby-1.9.2-p290@global'
load 'deploy' if respond_to?(:namespace) # cap2 differentiator
# Uncomment if you are using Rails' asset pipeline
# load 'deploy/assets'
Dir['vendor/gems/*/recipes/*.rb','vendor/plugins/*/recipes/*.rb'].each { |plugin| load(plugin) }
load 'config/deploy' # remove this line to skip loading any of the default tasks
Then edit the file ‘deploy.rb’ in the ‘config’ directory with this content.
set :user, 'deploy'
set :domain, 'myrailsapp.com'
set :application, "myrailsapp"
set :repository, "git@github.com:username/repo.git" # Your clone URL
set :scm, "git"
set :branch, "master"
set :scm_verbose, true
set :deploy_via, :remote_cache
set :scm_passphrase, "password" # The deploy user's password
set :deploy_to, "/home/#{user}/#{domain}"
set :use_sudo, false
require "bundler/capistrano"
default_run_options[:pty] = true
ssh_options[:forward_agent] = true
role :web, domain # Your HTTP server, Apache/etc
role :app, domain # This may be the same as your `Web` server
role :db, domain, :primary => true # This is where Rails migrations will run
namespace :deploy do
task :start do ; end
task :stop do ; end
task :restart, :roles => :app, :except => { :no_release => true } do
run "#{try_sudo} touch #{File.join(current_path,'tmp','restart.txt')}"
end
end
after "deploy:migrations", "deploy:cleanup"
Note that you have to edit each parameters to fit your environment.
Then, you need to configure your Nginx to serve the specified domain name and map to the path to be deployed by capistrano.
Edit the file ‘/opt/nginx/conf/nginx.conf’ and add the following lines.
server {
listen 80;
server_name *.myrailsapp.com;
root /home/deploy/myrailsapp.com/current/public/;
passenger_enabled on;
}
Now it’s time to deploy your Rails application.
capistrano required you to setup for the first time, so you have to run this command for the first time only.
cap deploy:setup
Then, it is a time to deploy actual files.
cap deploy
If you are following the above instructions carefully. You should have a production of your Rails application running now.
Cheers!
Hi there,
Just want to share I’m going to get a new laptop for use on my presentation at client sites.
Here is criteria I’m using to select my new presentation weapon.
- Mainly for portability
- Should support for partial works on web development using Ruby on Rails
- Long life battery
- Looking good to great
- In a reasonable price tag
- 13″ screen, no smaller display because I used to do web development sometime
If you are using the same criteria as mine, you should ends up the same with what I’ve chosen.
It’s Apple Macbook Air 13″ (Mid 2011) because it ends up with these criteria well.
Here is its own strength points.
- Ultra portability, very slim and light weight
- Battery life is so good for me, maybe the help of Mac OSX
- Even the CPU is ULV series but its performance also gained by using SSD storage
- It’s fast enough for everyday use and satisfy for my Ruby on Rails web development
- Great display resolution for 13″ screen
- Price is fair
I will review more soon. Just write this short post to test a functionality in my new Facebook app.
Thanks,
Seree
Hi there,
Today I’m going to write a post about what I think on comparing between Corona SDK by anscamobile and Cocos2d framework.
As I’m planning to launch a new project that based on mobile platform primarily on Apple iOS 5, I’m considering between Corona SDK and cocos2d and I decide to avoid the native iOS framework because I need to build an app that can differentiate from normal app.
Also, productivity is the point too as these two frameworks can be boost productivity while comparing to the original iOS framework by Apple.
After I’ve upgraded my Snow Leopard to Lion, I found many things regard to my development environment doesn’t work anymore.
This is including the process to compile the library readline 6.2 which is a need to be done before installing the latest Ruby. (1.9.2-p290)
When I try to make, I got the error like this.
gcc version 4.2.1 (Based on Apple Inc. build 5658) (LLVM build 2336.1.00)
i686-apple-darwin11-llvm-gcc-4.2: -compatibility_version only allowed with -dynamiclib
make[1]: *** [libreadline.6.2.dylib] Error 1
make: [shared] Error 2 (ignored)
I wonder why it doesn’t work because I just did the same to install Ruby 1.9.2-p181 on my old Snow Leopard.
Then, after I research some information through Google.
I found this solution to make it works.
After configured the source code with ./configure –prefix=/usr/local
Follow this…
cd shlib sed -e 's/-dynamic/-dynamiclib/' Makefile > Makefile.good mv Makefile.good Makefile cd .. make sudo make install
This works for me and I’m fairly sure it will works for you too.
As you might known that I’ve posted about one of my top SEO tool in my arsenal is ScrapeBox.
Last few days, I feel like ScrapeBox is hogging almost of my home network connection’s resource.
So I decide to move ScrapeBox from home PC to work on VPS.
After I’ve research some to find out where is the best VPS provider that fits for ScrapeBox and it doesn’t cost too high to invest.
And I found XSServer.eu is in the case, it is proven to be able to use ScrapeBox and many white-to-black marketers are using its service.
Then, I pick up a $35/month plan immediately for unmetered bandwidth + 1GB ram which I think it is best fit for ScrapeBox while another plan such as $25 for 512MB of ram also fit for tiny use of ScrapeBox as well but I think I will be a hardcore user so I decide to get at least 1GB of ram. Minimal.
After an hour since I’ve made a payment to XSServer, I got an email notified that they created my VPS machine successfully.
I’m a bit happy for their quick response to create a VPS. Anyway, I think they can make it quicker too.
Now I open up my Mac OS X Lion and open Microsoft RDC and connect my VPS remotely. Success.
Anyway, after I’ve uploaded my ScrapeBox archive file into my VPS, I can’t run it successfully.
ScrapeBox show me that it might have some thing block ScrapeBox or some application tampered the TCP data.
If you got the same error like mine, you can have a test by going to Help->Test Server menu and see the result.
For me, I got 5 green lights and red light on the server 1′s Access Test.
This mean I’m getting a problem with ScrapeBox now.
Can’t make it works, so I guess it should be some issue with VPS environment because I didn’t installed any other softwares on it and it is pure vanilla.
So I begin to create a support ticket with XSServer.eu support department.
Well worth, like what I’ve heard from research, they response very quickly. If you are in front of me, I would say… “It’s f*ck’n fast response!”
Anyway, even they have fast response time, but their information not so helpful for my case because finally they want me to contact ScrapeBox to troubleshoot the thing and said it’s not the problem with VPS.
Ok, ok, then I try to contact ScrapeBox. If you are trying to contact ScrapeBox at their contact page, you will ends up seeing it let you contact by sending email to scrapeboxhelp (a) gmail.com.
Anyway, from what I’ve tried myself, I suggest you to use support (a) scrapebox.com instead of the one on gmail.
They do response on the second one much quicker.
And it is awesome!
Their support staff is very very informative, helpful and get straight into the core issue.
They are very professional. Even I don’t know who is the person I communicate with but I would like to say he/she is very professional and impress me.
Even the second license transfer fee, they waived for me.
Finally it works…
By a prove from ScrapeBox log that it is some issue with VPS environment itself, not the ScrapeBox itself.
So I send this information to XSServer.eu support staff, and they response with a very good effort.
They create a pure new VPS in the another node of their network to help me immediately.
And it is working like a charm now! New license is transferring to my new VPS and I can’t wait to get ScrapeBox running now.
6 green lights are great. I really love it.
If you read ’til this line, then I quite sure you already know how to make a great support like this. Right?
Thanks,
Hi folks,
As I’ve written about how backlinks still affects to your website ranking on SERP last time at this post.
Today I can say, it still works, not just works normally but still working great!
Because I just got ranked on the top of Google today. (actually, it might be yesterday or 2-3 days before now)
So, I can say that generating backlinks still be a great thing to invest for your online business today.
If you want to discover how I ranked #1 on this keyword, the essentials are just two factors.
- Keyword matching domain name (exact keyword as domain name)
- Build as many as possible backlinks (I did 1xx,xxx backlinks)
Hi Internet marketer folks,
Today I would like to share with you guys how the result I produced from generating more back links to my few web sites to prove on the popular & myth question…
Does generating more back links still work for your sites to get higher ranking on Google SERP today?
Let me show you one of my few sites I used to test this topic.
I’m using a keyword which have 201,000 global monthly search, low-to-medium competition.
At the first week, I ranked well on page #7, then it is climbing up everyday until I got on the 1st page, but I never get it in the top 5 area. (Actually, I do on ranked #8 and #9)
The second week, I realize that Google might be dancing because sometime, Market Samurai can’t found my site on all indexed pages on Google SERP.
Anyway, sometime it get back to page #1, still in #8, #9 and sometime it disappeared like I got de-indexed, but actually it still in Google index but don’t know why my site is showing on the so so so long pages that no one can browse to that page.
From this point of time, the rank is steadily on #8 and #9 and never get better. It is the same about 2-3 weeks.
So, this is the time to test how back links affect to my site for Google SERP today.
I begin by launching my golden SEO weapon. Scrapebox (if you really serious about SEO, you can’t live without it easily)
Then load up my personal list of websites that do auto approve comments and I begin fast posting through Scrapebox.
Until now, the Scrapebox still running and did successfully post about 51,894 comments. (almost taken 2 days)
So, I launch up another golden SEO weapon, Market Samurai, and doing rank checker.
Wow!
My Market Samurai report that my site ranked on #4 now!
So, you know the answer of this myth question right now?
Back links still get much credits from Google, I believe it should stay the same credibility for back links until Google found out a new method how to detect the popularity of each site in the balance of quality too.
It should not be easy for Google to ignore the power of back links because it is somewhat a nature of web site.
If a website is popular, it should have growing more and more back links.
From my thought, I will do about 100,000 back links and stop adding more back links,
Then I will try to index as much as possible of my back links URLs and see the result. (expected about 30% of it)
When the rank is steadily, I will test the power of social networking to see how it affects to my sites ranking.
Well, I will report here again after the next milestone of my personal test.
Thanks,
Here is a short list of my tactics I’m going to use in my CPA sites to boost my profit.
If you are going to use one of them, few of them or all of them. Please let me know if it works well for you or not.
Upsell tactic #1
The generic strategy of most CPA marketers is to have the only offer so the visitor will not lack of focus and concentrate on the targeted offer.
However, while the concentration is good but you probably lose a chance to do some upsell-like for them.
So, I decide to place related offers to let them see too but the scenario in my head are…
How to put related offers while the main CPA offer still be able to force visitor to fully concentrate on them?
Luckily, I cracked the code…
What I did are…
- When I got laser targeted traffic for the main CPA offer, I will show only the main offer. Only***
- I will change the link to real offer to use some type of pop-over to force visitor to stay on my side while they are taking action (like doing survey)
- When they completed taken action on the main offer, they close the pop-over
- Now the page will zoom out the main CPA offer and display related offers in the bottom area of it
Exit offer tactic #2
Continuity tactic #3
This is by far the only one tactic you have to use on all of your CPA pages or sites.
Yes, I talk about list building, why don’t you ignore this most effective approach to make money continuity from your existing clients?
Hi there,
Today I just want to share how do I copy my purchased Kindle eBooks into my Sony Reader Touch Edition. (PRS-600)
Well, after I’ve purchased ebooks from my Kindle app on iPad, I got too less available time to read the ebooks on my iPad because my son always playing with it.
So, I decide to copy the purchased ebooks from Kindle to my Sony Reader.
Anyway, it is not easy as I think, even I’ve some experienced with Calibre.
After I’ve did some research, I found a working solution to do this.
Here are requirements
- My iDevice, in case of mine, it is iPad and iPhone, just pick one device
- Calibre, download here
- DRM Tools, download here
- Your e-Reader, in case of mine, it is Sony Reader PRS-600 Touch Edition
- Extract the downloaded DRM Tools Archive
- Open Calibre, go to Preferences and select to add new plug-in
- Select the file ‘K4MobiDeDrmXX.zip’ in ‘Calibre_Plugins’ folder
- Then click on customize the plug-in button, it will ask for your PID
- Open your browser and visit http://kindletools.prestonlee.com/
- Connect your iPad/iPhone to your computer, open iTunes and see its UUID, it will be a 40 hex characters
- Enter your email address and your UUID in the ‘Reader Serial’ textbox and click ‘Calculate’
- Copy your generated PID
- Back to Calibre, paste your PID here
- Restart Calibre
- Now you can drag and drop the .azw files into Calibre library without doing any extra tasks, the Calibre will automatically remove DRM protection from the eBooks you dropped by
- Now just convert the ebooks and send to your device as usual via Calibre
It should works for you too.
**PS: I don’t provide this information to support illegal activities, please purchase the books and don’t relate to piracy, all books are worth its own content and I do not responsible how you use this information.
Archives
- November 2011
- October 2011
- September 2011
- August 2011
- July 2011
- June 2011
- May 2011
- March 2011
- February 2011
- January 2011
- September 2010
- August 2010
- July 2010
- June 2010
- May 2010
- April 2010
- January 2010
- December 2009
- October 2009
- August 2009
- July 2009
- December 2008
- November 2008
- October 2008
- September 2008
- August 2008
- July 2008
- June 2008
- May 2008
- April 2008
- March 2008
- January 2008
- December 2007
- November 2007
- October 2007
- September 2007
- August 2007
- June 2007
Tags
.net 2008 asp.net asp.net mvc asus eee c# corona cpa doctrine dom eee eee pc Internet Marketing ios iPad iphone iPhone development iphone sdk javascript make money netbook online marketing pagerank passion php playstation playstation 3 ps3 ranking ror ruby on rails self help Self Improvement self motivation seo sql success symfony take action the secret ultra compact laptop ultra compact notebook vb.net web development wordpress









