Lately, I have been writing apps in ruby instead of PHP, as it has a low learning curve especially if you know bash scripting and an awesome framework called Rails. Ruby on Rails was so easy to work with that I got my app up and running in 48 hours. You can check it out here github.com/Leo-G/Rails-DNS. I know it’s no big deal, but it was fun to build and easy to, Ruby makes programming fun, You can learn it here http://ruby.learncodethehardway.org/
Installing Ruby 2.2.2 via RVM
I recommend using RVM, to install Ruby on Linux, this helps you to install and use multiple versions of ruby without having to uninstall and reinstall them.
#Install curl [leo@linux-vps ~]$ sudo yum install curl #Install rvm and ruby [leo@linux-vps ~]$ curl -sSL https://get.rvm.io | bash -s stable --ruby #Run rvm scripts [leo@linux-vps ~]$ source /usr/local/rvm/scripts/rvm
This may take time but will install ruby version 2.1.2 as well as RubyGems, a ruby package manager.
Below is a list of rvm command line arguments to troubleshoot issues.
#List installed ruby versions [leo@linux-vps ~]$rvm list #Install specific ruby versions [leo@linux-vps ~]$rvm install 2.1.2 #Find the Directory where gems are installed. [leo@linux-vps ~]$rvm gemdir #Use rvmsudo to install gems instead of sudo to avoid enviroment issues. [leo@linux-vps ~]$rvmsudo gem install sqlite3 -v '1.3.9'
You will need to install sqlite and nodejs for the Ruby on Rails framework.
[leo@linux-vps ~]$sudo yum install sqlite-devel [leo@linux-vps ~]$rvmsudo gem install sqlite3 -v '1.3.9' [leo@linux-vps ~]$ sudo yum install nodejs
#Install rails via the gem package manager [leo@linux-vps ~]$gem install rails
Once rails is installed create a new rails app and follow the instructions here if you are just getting started with Rails.
#By default Rais will connect to sqllite, you can use -d for mysql [leo@linux-vps ~]$rails new appname -d mysql
Rails has its own server which you can use for testing your app, but for a live app I highly recommend installing Phusion Passenger, easy to install and can handle a high number of connections.
Installing Phusion Passenger
#Install Phusion Passenger [leo@linux-vps ~]$rvmsudo gem install passenger #start passenger on port 80 in daemon mode [leo@linux-vps ~]$rvmsudo passenger start --daemonize --port 80 --user=leo_g #Check passenger status [leo@linux-vps ~]$ rvmsudo passenger status --port 80 Stop passenger [leo@linux-vps ~]$ rvmsudo passenger stop --port 80
Once you have your application server up and running, you are going to need a good email server to deliver your emails. I have been using postfix for all my servers and below is the configuration I generally use. Installation of Postfix on CentOS 6 yum install postfix Sendmail is installed by default, so it... Read More »
Whenever I setup a Linux VPS, the first thing I do is install a firewall. I have noticed an increase in attacks on my servers, especially from China. I use Config Server Firewall (CFG) and Login Failure deamon (LFD) because they are easy to set up and provide additional features like suspicious file reporting and... Read More »
In my last Shell Scripting tutorial, I used “inotifywait” along with rsync to create a real time file syncing script called backup. This script will run till I manually kill it or till I close my terminal, if I run it as a background process. Now I cannot keep my terminal open forever, but I... Read More »
In my last example of Bash if statements we created a backup script which would run “rsync” as per the time set in a cron. But wouldn’t it be nice if we could run our “rsync” script only if there was a change to the files in our directory instead of running a cron every... Read More »
In my earlier post on linux memory management, I showed you how you can get the exact memory usage of your script by using py_mem.py. This script, without any options will run once and give you the current memory usage of the system. But what if you wanted real time memory usage?, In other words,... Read More »
Last week I was reading up on awk and was fascinated by its text processing capabilities despite been written more than 3 decades ago. Let’s take a simple example of awk on the following “/etc/passwd” file. leog:x:502:502::/home/leog:/bin/bash leo:x:506:506::/home/leo:/bin/bash awk:x:911:911::/home/awk:/sbin/nologin This file has fields separated by colons. If I wanted to print only the GID and... Read More »
In my previous post we looked at a simple bash backup script example, which would sync data between servers using “rsync” and then send us an email. The only problem with this script is if “rsync” fails, we would still get a successful email. Now I am sure you don’t want to find out on... Read More »
Puppet is an automation tool which allows you to automate the configuration of software like apache and nginx across multiple servers. Puppet installation In this tutorial we will be installing Puppet in the Puppet/Agent mode.You can install it in a Stand Alone mode as well. OS & software Versions Centos 6.5 Linux kernel 2.6.32 Puppet... Read More »
A Brief Introduction Bash or Bourne again shell is a replacement to the original unix shell written by Stephen Bourne at Bell Labs. It offers vast improvements over the original shell, which include Integer arithmetic, Indexed arrays, Command line editing, Unlimited command history. Bash scripts are available by default on most Linux distributions. To find... Read More »