Drupal 6.x runs well on HostGator, but there are a few challenges due to HostGator's migration to PHP5.

HostGator's PHP5 Migration

Two weeks ago, HostGator announced, "All shared (gatorXX.hostgator.com and reseller) servers will be changed to PHP5 and MySQL5 by default, starting on March 8th." See their forum message for details.

Drupal 6 and other applications can start using PHP5 immediately.

.htaccess

Modify Drupal's .htaccess file to override the PHP4 default. Add this line early in .htaccess:
AddHandler application/x-httpd-php5 .php

For example, I added the line after the comment at the top of .htaccess:

#
# Apache/PHP/Drupal settings:
#
AddHandler application/x-httpd-php5 .php

Cron

HostGator does not allow wget or Lynx, so use PHP to replace wget as suggested by mooffie in this thread. Create a file in your public_html directory called getcron.php:

echo "2 + 2 = ". 2 + 2;
file_get_contents('http://example.com/cron.php');

Test the script by entering www.yoursite.com/getcron.php into your browser. You should see the answer 4 displayed. Now click "Status Report" on the your site's admin page. You should see something like this:
Cron maintenance tasks Last run 1 min 12 sec ago

If the script is working, you can delete the "echo" line.

Run getcron every hour with this cron entry:

0 * * * * /usr/bin/php -q /home/username/public_html/getcron.php

Cron novices can understand this line piece-by-piece:

  • 0 means "run this at the 0 minute of each hour." I recommend choosing another number to avoid the hourly computing spike. How about 13, meaning "run this at the 13th minute of each hour"?
  • * * * * means run every hour, day, month, and day of week.
  • /usr/bin/php means "run the PHP interpreter." This will run PHP4 until March 8, but that is sufficient to retrieve cron.php via HTTP. As configured in .htaccess, cron.php will run with PHP5.
  • -q means "suppress the HTTP headers that PHP generates for each page." I omitted -q to see the headers while I was debugging the PHP4/PHP5 problem.
  • /home/username/public_html/getcron.php means "run the getcron.php script in username's web directory." Replace "username" with your HostGator cPanel login name, such as "smith" or "acme." If you installed Drupal somewhere other than your public_html directory, edit the path accordingly.

If your cron command is working, you will receive no mail. Cron sends mail only when a command generates output. Be sure your email address is correct in cPanel's cron form.

While I was debugging, I didn't see any emails at first. Postini, my ISP's spam filter, considered the cron messages to be junk mail. I had to add root at gator148 to my approved sender list at Postini. Each HostGator shared host has a different root email address, so look in your cron email.

To confirm that Drupal's cron job is running, wait until after a scheduled hourly run and click "Status Report" on the your site's admin page. You should see something like this:
Cron maintenance tasks Last run 2 min 58 sec ago

Comments

artweeksgr’s picture

Actually you can have this functionality activated at Hostgator. Just email support and they will activate it for you.