Ruby on Rails and cPanel/WHM
The installation of Ruby on Rails in cPanel has two parts, first is installing Ruby itself, which can be accomplished by running
This script will install Ruby, RubyGems, Mongrel and the software that Ruby relies upon and activates the Ruby interface in your end user’s cPanel.
The second step in the installation is running.
/usr/local/cpanel/bin/ror_setup
This script will setup Ruby on Rails so that it will be activated when your system starts.
Ruby runs a separate server other than Apache for serving Ruby on Rails web applications, so setup for this requires a little more work. First you will need to login to your cPanel and click on the Ruby on Rails icon, to bring up the Ruby on Rails management interface that allows you to setup your Ruby environments. At this point, you will need to give your application a name and setup its path.
Note: If you set this path inside of your public_html directory your application’s source code and configuration files can be viewable by anyone on the web.
If you pay close attention to the URL used for the application, you will see that it has a number like :12001 at the end of it. This is because Ruby on Rails does not use the standard Apache web server, but rather uses its own, called Mongrel.
We can change these to be user-friendly. You will need to create a new subdomain or addon domain in cPanel, then click on the create rewrite button next to the Rails application name in cPanel, select the desired domain name from the drop down box, and now, whenever you go to this domain, it will display the RoR application
You will need to ensure that ports 12001 and up are open (we recommend making the max number of the open ports 12001 plus whatever the number of Ruby applications you expect to be running will be).
Sometimes the gems repos will go down. If this happens during the installation, you will need to re-run /scripts/installruby.
Tags: Cpanel/WHM, Ruby
Apache Handlers
Apache handlers allow you to control what Apache will do with certain file types. When Apache sees a file, it has an action built in for that file type, and will perform that action. If you wish Apache to do a different action, you will need to make a handler to tell Apache to perform that action. For example, if you use a file type that requires a special service to run it, such as a file with server side includes that is not named with a .shtml extension, you need to tell Apache to treat these files differently.
System Apache Handlers
Handler Extension(s)
cgi-script .cgi .pl .plx .ppl .perl
server-parsed .shtml
Tags: Apache Handlers
Extracting the MBR
To see the contents of your MBR, use this command:
# dd if=/dev/hda of=mbr.bin bs=512 count=1
# od -xa mbr.bin
The dd command, which needs to be run from root, reads the first 512 bytes from /dev/hda (the first Integrated Drive Electronics, or IDE drive) and writes them to the mbr.bin file. The od command prints the binary file in hex and ASCII formats.
Tags: MBR
Disable ping request to the server
Diable ping using the following type:
echo 1 >/proc/sys/net/ipv4/icmp_echo_ignore_all
or
As superuser, add the following lines to /etc/sysctl.conf
net.ipv4.icmp_echo_ignore_broadcasts = 1
net.ipv4.icmp_echo_ignore_all = 1
Then run the following command to cause the change to take effect immediately:
This change will persist following a reboot.
Tags: ping, server
How to encrypt file with passphrase
Mcrypt is a simple crypting program, a replacement for the old unix crypt(1). When encrypting or ecrypting a file, a new file is created with the extension .nc and mode 0600. The new file keeps the modification date of the original. The original file may be deleted by specifying the -u parameter. If no files are specified, the standard input is encrypted to the standard output.
$ mcrypt -uz file1
Enter the passphrase (maximum of 512 characters)
Please use a combination of upper and lower case letters and numbers.
Enter passphrase:
Enter passphrase:
File file1 was encrypted.
-d, –decrypt decrypts.
-z, –gzip Use gzip to compress files before encryption.
-u, –unlink Unlink the input file after encryption or decryption.
Tags: encrypt, mcrypt