Friday, December 7, 2012

How to install java/jdk using WHM/Cpanel from RPM

If you simply want JDK and JRE just to run Java programs and also compile them then just go to in WHM : Software-> Install RPM and select from the list:

java-1.7.0-openjdk-devel

When you install the browser spits a bit of information.

On my Centos it is installed on something like /usr/lib/jvm/java-1.7.0-openjdk-1.7.0.9.x86_64/bin

So just add this path in .bashrc :

export PATH=$PATH:/usr/lib/jvm/java-1.7.0-openjdk-1.7.0.9.x86_64/bin

And then save it and run ". ~/.bashrc". Now you can type command java/javac etc.

So instead of install complete Tomcat server, this is simple way to install java using WHM/Cpanel.

Monday, November 19, 2012

Webhosts providing Semi-dedicated plans

I'm looking for shared high bandwidth hosting( also called semi-dedicated or enterprise web hosting) as my sites have exceeded shared hosting on Hostgator Baby plan. Here is some list I've prepared for quick reference.

Instead of moving to VPS it is better to see if any semi-dedicated web hosting plan can manage your site/sites. If it is, then nothing like it!

Managing VPS is not recommended as it requires management of lot servers, anti-spam techniques, security features etc. Remember all need to be done from scratch. Another hassle is that you will not have secondary name server and you'll need to make arragements to get make one. And if your single server stops working you all name resolution of all sites will fail and even email will bounce.

I've selected these companies as they look convincing. If you know any else then please let me know by placing them in comments!

Ntchosting

(www.ntchosting.com)

  • Cost: $35/$55
  • 24x7 support : Chat is supported
  • Backup: Daily
  • Max CPU Usage (per CPU) : 20%
  • Alexa : 19,000

Reseller Panel

(www.resellerspanel.com/semi-dedicated-servers/semi-dedicated-1.html)

  • Cost: $25
  • 24x7 support : Chat,Phone
  • Backup: Daily
  • Max CPU Usage (per CPU) : 30% CPU share and up to 90000 MySQL queries per hourAlexa : 19,000
  • Plan Pricing: Monthly
  • Control Panel: Hepsia
  • Alexa: 13400

Hawk Hosting

(www.hawkhost.com/semi-dedicated-hosting)

  • Cost: $20 and more
  • No Chat support
  • 50 mysql connections, 20 processes max(max 7 php)
  • Real 99.9% Uptime Guarantee
  • Cpanel
  • Alexa: 8200

MDD Hosting

(www.mddhosting.com)

Coupons of 50% discount available online

  • Cost: $25 and more
  • No Chat support
  • Cpanel
  • Maximum of 10 processes allowed
  • Alexa: 104000

Stable Host

(www.stablehost.com/enterprise-hosting.php)

Coupon of 50% discount available online

  • Cost: $20 and more
  • CPU/Ram X 4 times of normal
  • maximum 50 concurrent mysql connections, 25 concurrent processes
  • No Chat support
  • Alexa: 18600
Feature Shared Enterprise
Support Methods 24/7/365 Email Only 24/7/365 Phone/Email
Priority Support [More Info] No Yes
Accounts per Server 500+ 100
INODES/Files 250k 500k
CPU 15% of 1 CPU Core 100% of 2 CPU Cores
MySQL Connections 10 50
SLA 99.9% (43.2 minutes of downtime per month) 99.99 (4.32 minutes of downtime per month)
Script Troubleshooting No Yes
Hacked / Compromised Repair No Yes

Site Ground

(www.siteground.com/semi_dedicated_hosting.htm)

Hardly any coupons available

  • Cost: $30 and more
  • Chat support
  • Alexa: 2000

Glow Host

(http://glowhost.com/web-hosting-service/semi-dedicated-server-plans.html)

Hardly any coupons available

  • Cost: $70
  • No Chat support
  • Cpanel
  • Alexa: 79,000

I raised a ticket asking for the resource usage limits in Semi-dedicated server plan. This is what I got in the reply:

Here are no strict limits, all limits are depend on a server specification. Usually max mysql connections is set to 100, you can set memory limit on your own, but it shouldn't be more than RLimitMEM limit (usually this limit is 512 or more on Semi-Dedicated servers). You can read more about Semi-Dedicated plan here.

Sunday, September 30, 2012

How to send smtp mail in Perl on Shared Hosting(esp Hostgator) with authorization

Looking to send email using Perl in Smtp in Shared hosting( this is tested for Hostgator) on Centos/Linux/Unix?
This code does that. If you're on Hostgator Centos shared hosting server then this works:
#!/usr/bin/perl

use Net::SMTP;

$smtp = Net::SMTP->new('mail.mysite.com');
$smtp->auth( 'contactus+mysite.com', 'rmypassword' );
$smtp->mail('contactus@mysite.com');
$smtp->to('ragmyemail@gmail.com');

$smtp->auth( 'contactus+mysite.com', 'passowrd' );
$smtp->data();
$smtp->datasend('ragmyemail@gmail.com');
$smtp->datasend("From: Whats up?\n");
$smtp->datasend("To: Whats up?\n");
$smtp->datasend('Subject: Whats up1?');
$smtp->datasend("\n");
$smtp->datasend("Hello, this is test email.\n");
$smtp->dataend();

$smtp->quit;

Wednesday, February 8, 2012

How to email backup shared hosting site mysql database automatically


 Here is the bourne shell script on my Centos unix Hostgator shared hosting server placed in the crontab and runs once in a day at 3am my country time.

#!/bin/sh

cd /home/myname/www/tmp/all


mv *.sql j
rm *.gz

for i in  *dump*.sh
do
if ! sh $i
then
echo "Failed for $i"
exit
else
echo "$i success"
fi
done
d=`date|tr " :" --`
echo $d

ls -l *.sql

echo "Total files=" `ls -l *.sql|wc -l`
file="scripts.tar"
if ! tar cvf $file   *.sh *.php
then
echo "tar for file:$file has failed"
exit
fi
if ! gzip -9 $file
then
echo "gzip for file:$file has failed"
exit
fi
echo "...........................Success .... see the file below:"
ls -lh "$file.gz"


for i in *.sql
do
if ! gzip -9 $i
then
echo "gzip for file:$i failed"
exit 1
fi
done


echo "Emailing it"


for i in *.gz
do
if ! php email.php "$i"
then
echo "Email failed for $i"
fi
done

echo "Email sent successfully"
exit 0

-----------------------------------------------

Content on my sample mysqldump_adi.sh

mysqldump -h localhost   -u <dblogin> <dbname> -p<dbpasswd> outfile.sql
-------------------------------------------
Email.php: Here is the source code to send files by attachment using Smtp in Php.

Tuesday, August 2, 2011

Hostgator Shared Hosting Insights - do you know them?




Are you using HostGator's shared hosting? I'm using Hostgator's Hatchling plan and I'm very happy with my sites. Total number of visitors recently went up to 8000/day but my sites were still fine.

For backups better buy one hotfile account where you can upload CPanel backups daily. Or you can use free ones with Megashare.

Do you know HostGator's online chat is free and is excellent and best in the world I've ever seen! Even before buying you can as well chat with their technicians who will make sure you leave happily.

Insights


Sending emails
We can send large emails from our accounts( even 27 MB is allowed). Run a cron job daily night which will zip and email you the backup of all your databases. You can use this php code to send your backup in attachment.
HostGator system times
They are fairly accurate and synced by NT
How can I change server timezone to that of my country?
The server timezone is by default set to Central Standard. We can change the timezone to that of our country's so that all the php code gets time in our country's timezone. Read more for information.
CPanel Backup limits
They won't run if the total file size in my home directory in more than 4GB or total number of files(inodes) is more than 100,000. Also CPanel full backup can also be restored.
Bandwidth
My one site is download site so I was not sure how much bandwidth HostGator will allow in my shared hosting account. I did have a good chat with them and I assume that even more than 5-7 GB may be allowed by HostGator. Here is the chat with HostGator technician about maximum bandwidth usage.

Also when I raised this question : "So I assume that 15 GB of data size isn't a problem with HostGator. Only that CPanel backup won't run; secondly if I take backup of 15GB of data and transfer it to remote server for backup so will 15GB be added in the bandwidth of my hosting account? What will be the side affects of this for my Hatchling account?" I got the following reply from HostGator technician:

Nothing, you have unlimited bandwidth.

Monday, August 1, 2011

Sending mail with attachment using PHP & SMTP on Hostgator

I've tested it on Hostgator command line and saved it in b.php. It is sending attachment correctly.





<?php
require_once "Mail.php";
require_once('Mail/mime.php');

$from = "contactusds@downloadformsindia.com";
$to = "rag.fjraggupta1@gmail.com";
$subject = "this is the message from your domain";
$body = "give your message body here";
$host = "mail.downloadformsindia.com";
$username = "contacdtus+downloadformsindia.com";
$password = "passwd";

$headers = array ('From' => $from, 'To' => $to, 'Subject' => $subject);
$file="./a.php";
$crlf="\n";
$mime = new Mail_mime($crlf);
$mime->setTXTBody($text);
$mime->setHTMLBody($html);
$mime->addAttachment($file, 'text/plain');
//do not ever try to call these lines in reverse order
$body = $mime->get();
$headers = $mime->headers($headers);



$smtp = Mail::factory('smtp',
  array ('host' => $host,
    'auth' => true,
    'username' => $username,
    'password' => $password));
$mail = $smtp->send($to, $headers, $body);
if (PEAR::isError($mail)) {
  echo("
" . $mail->getMessage() . "
");
} else {
  echo("Message Sent successfully");
}
?>

Sending email using PHP/SMTP on Hostgator command line


If you want to send email from Hostgator command line there here is the working sample.
Just replace from email id, to email id, host,username and password.

<?php
require_once "Mail.php";

$from = "contactus@mysite.com";
$to = "to email id";
$subject = "this is the message from your domain";
$body = "give your message body here";
$host = "mail.mysite.com";
$username = "contactus+mysite.com";
$password = "pass123";
$headers = array ('From' => $from,
  'To' => $to,
  'Subject' => $subject);
$smtp = Mail::factory('smtp',
  array ('host' => $host,
    'auth' => true,
    'username' => $username,
    'password' => $password));
$mail = $smtp->send($to, $headers, $body);
if (PEAR::isError($mail)) {   echo(" " . $mail->getMessage() . " ");
} else {   echo("Message Sent successfully"); }
?>