cPanel: How to disable mod_security2 for account or path

To disable mod_security2 from cPanel server,

1. Create the following folder.

/usr/local/apache/conf/userdata/std/2/username/domain.com

2. Create a file name disabled_modsec2.conf in the above path.
3. Enter the following line if you want to disable mod_security2 for whole domain.

<IfModule mod_security2.c>
SecRuleEngine Off
</IfModule>

For specific path,

<LocationMatch your_path>
<IfModule mod_security2.c>
SecRuleEngine Off
</IfModule>
</LocationMatch>

4. Run the following script from root access.

/scripts/ensure_vhost_includes –user=username

 Alternatively,
Edit the following file,

/usr/local/apache/conf/modsec2.conf

Enter the information below,

SecRule SERVER_NAME "domain.com" phase:1,nolog,allow,ctl:ruleEngine=off

Replace the domain.com will do.

How to Install Redmine 1.4 with cPanel 11.32

The reason I repost this article is because my previous article is old enough and I still can see the demand on this task.

Requirement:
– Ruby On Rails 1.8.x enabled, please downgrade to 1.8.7, 1.9.2 or 1.9.3 if your are running higher than that. To check the Ruby version, type “ruby -v” from shell.
– Shell Access(SSH) enabled
– MySQL Enabled
– Rubygems <= 1.8

Pre-Step:
1. Install gem rails version 2.3.14(exact version), from SSH shell, run

gem install rails -v=2.3.14

2. Install gem rack version 1.1.3, from SSH shell, run

gem install rack -v=1.1.3

3. Install gem rubygems 1.8.23(or higher version, not >= 1.8), from SSH shell, run

rubygems-update

If it is not working, refer to http://www.mickgenie.com/how-to-update-rubygems/.
4. Create MySQL database from your cPanel and I assume that you are using the database as detail below.
Database Name: mickgenie_redmine
Username: mickgenie_redmine
Password: StR0NgPa$$w0Rd

Installation Step:
1. Log into the cPanel, click on Ruby On Rails.
2. In the App Name, enter Redmine, environment session select Production and create the App.
3. Click on Create Rewrite button and enter the subdomain or path that needed, then save it.
4. Download Redmine from RubyForce.
5. Upload through File Manager according to the path that you created from the Ruby On Rails.
6. Extract the file to the RoR Apps.
7. Install bundler gem by enter,

gem install bundler

8. Now, run the following command to install all the required gem from Redmine,

bundle install --without development test postgresql

9. Rename the in config/database.yml.example to config/database.yml.
10. Open the database.yml file and look for the production section.
11. Modify the production section as detail below.
production:
adapter: mysql
database: mickgenie_redmine
host: localhost
username: mickgenie_redmine
password: StR0NgPa$$w0Rd

(These information is create as above).
12. Create session store secret.

rake generate_session_store

13. Create the database structure.

RAILS_ENV=production rake db:migrate

14. Create default data.

RAILS_ENV=production rake redmine:load_default_data

15. You have done the installation, just go to cPanel and start the mongrel.

Final Step:
You may now log into Redmine with detail below,
Username: admin
Password: admin

how to update Rubygems

Today, I got another challenge from @thebosscat to help out the Ruby on Rails case.

Symptoms: the server using RubyGems 1.2.0 and all of the ruby gems could not able updated through “gem update” or even “gem update –system”.

To overcome the problem, I was trying to update the rubygems as step below.
1. Download rubygems version from URL below.
http://rubyforge.org/frs/?group_id=126
2. Extract the file (in this case, I used the version 1.3.1).

tar -xvf rubygems-1.3.1.tgz

3. Then enter to the path,

cd rubygems-1.3.1

4. Run the setup.

ruby setup.rb

5. Verify from the shell again.

gem environment

Install CDONTS to 64 bits Windows server

Today I found out 1 of the server do not have CDONTS installed at all and the server found to be 64bits Windows Server 2008 server.

Firstly, I did not discover that this is a 64 bits server and I have directly copy the cdonts.dll to the C:\Windows\System32 folder and try to register it but failed.

Then I found out it is a 64 bits server. Hmm.. Then I try to move the cdonts.dll to C:\Windows\SysWow64 folder and trying to register it. Step will be as detail below.

1. Open a command prompt with Administrator privilege.
2. Go to the path of C:\Windows\SysWow64, cd C:\Windows\SysWow64.
3. Register the library, regsvr32 cdonts.dll.
4. Try to send the email and it is working fine 🙂

How to install Redmine with cPanel

Although Redmine do provide the installation guide as URL as below, however it might not work if you are using cPanel.
http://www.redmine.org/wiki/redmine/RedmineInstall

With this article, you may get a complete guide to install Redmine to cPanel server with Ruby on Rails running.

Requirement:
– Ruby On Rails 1.8.x enabled, please downgrade to 1.8.x if your are running higher than that. To check the Ruby version, type “ruby -v” from shell.
– Shell Access(SSH) enabled
– MySQL Enabled

Pre-Step:
1. Install gem rails version 2.3.5(exact version), from SSH shell, run “gem install rails -v=2.3.5”.
2. Install gem rack version 1.0.1(or higher version), from SSH shell, run “gem install rack”.
3. Install gem rubygems 1.3.1(or higher version), from SSH shell, run “rubygems-update”. If it is not working, refer to http://www.mickgenie.com/how-to-update-rubygems/.
4. Create MySQL database from your cPanel and I assume that you are using the database as detail below.
Database Name: mickgenie_redmine
Username: mickgenie_redmine
Password: StR0NgPa$$w0Rd

Installation Step:
1. Log into the cPanel, click on Ruby On Rails.
2. In the App Name, enter Redmine, environment session select Production and create the App.
3. Click on Create Rewrite button and enter the subdomain or path that needed, then save it.
4. Download Redmine from RubyForce.
5. Upload through File Manager according to the path that you created from the Ruby On Rails.
6. Extract the file to the RoR Apps.
7. Log into the SSH, run “rake gems:install” from the Ruby Apps path, for more information, please refer to URL at here.
8. Rename the in config/database.yml.example to config/database.yml.
9. Open the database.yml file and look for the production section.
10. Modify the production section as detail below.
production:
adapter: mysql
database: mickgenie_redmine
host: localhost
username: mickgenie_redmine
password: StR0NgPa$$w0Rd

(These information is create as above).
11. Run “rake generate_session_store” to create session store secret.
12. Next, run “RAILS_ENV=production rake db:migrate” to get the database structure.
13. Then you may run “RAILS_ENV=production rake redmine:load_default_data” to get the default data.
14. You have done the installation, just go to cPanel and start the mongrel.

Final Step:
You may now log into Redmine with detail below,
Username: admin
Password: admin

For Redmine 1.4, please refer to the URL as below,
http://www.mickgenie.com/how-to-install-redmine-1-4-with-cpanel-11-32/

Install SSL through Shell

Today, I’m about to guide you how to install the SSL key and it will a bit tricky compare to generate the SSL CSR key.

To install the SSL key through Shell, refer to the step as below.
1. Go to path /usr/share/ssl/certs.
$ mickgenie@mickgenie.com[/]# cd /usr/share/ssl/certs
2. Check if the domain.com.csr and domain.com.cabundle existed, else create them and enter the code.
3. Go to path /usr/share/ssl/private.
$ mickgenie@mickgenie.com[/]# cd /usr/share/ssl/private Continue reading Install SSL through Shell

exclude folder from cPanel backup

Many of the cPanel user do not know that their server administrator could exclude any of their folder from the cPanel cpbackup process and those folder could be exclude from backup to safe the disk space usage.

Or you could exclude any of your dynamic file(possible that you host some dump services such as RapidLeech) and you do not want to backup them.

You may actually exclude them easily from include the path to cpbackup-exclude.conf file.

Step:
1. Edit the file cpbackup-exclude.conf  from your /home/user folder.
2. Add the folder that wish to exclude from backup from cpbackup-exclude.conf  file.
3. You have done it.

How to repair your MySQL databases

If you are using MySQL databases as your database engine, you surely ever get the error message as below if your database grown day by day.

Table “table” is marked as crashed and should be repaired.

To understand MySQL database table with MyISAM type, you will have .frm, .MYI and .MYD type, so the data stored from MyISAM type is storing to .MYI file extension.

To repair the database, open your SSH Console, type the following command.

myisamchk -o /path_to_mysql/database_name/table_name.MYI

where the table_name is the table name.

If you got tmp drive too low, you may add the following command from the my.ini or my.cnf.

[mysqldump]
tmpdir = /home/mysql/tmp

assume you assign the path to /home/mysql/tmp/.

Your website shall working without any issue now.