Using Magento CE on Go Daddy Shared Hosting

I recently installed Magento Community Edition on a Go Daddy shared Linux server, and I ran into a few problems that I thought I would share in case anyone else has the same issues.

Making the Installation Work

After uploading all the files, the first problem you may run into is that the installation wizard doesn’t work. Instead you get a blank page with the words “No input file specified.” You will need to make a couple changes to your .htaccess and php.ini files to get past this.

First, uncomment line 12 of .htaccess (remove the #). It should look as follows:

############################################
## GoDaddy specific options

Options -MultiViews

## you might also need to add this line to php.ini
##     cgi.fix_pathinfo = 1
## if it still doesn't work, rename php.ini to php5.ini

Next, rename the php.ini.sample file to php5.ini, open it, and add the following to a new line at the very end (as suggested in the .htaccess file ):

cgi.fix_pathinfo = 1

Upload these two files, but hold on — there is still one more step before you can install. Log into your Go Daddy hosting control panel, and click the “File Extensions Management” icon in the “Settings” section. You will need to change the .php and .php5 extensions to run under PHP 5.2.x (not the FastCGI option).

Go Daddy file extensions menu

After these changes, you shouldn’t have any problems getting through the installer. However, if you’ll be using Go Daddy’s preview DNS feature to view your website before changing DNS records, there are a few more things you need to do.

Using Go Daddy’s Preview DNS Feature with Magento

During the installation, you will be asked for your site’s “Base URL.” Enter http://yoursite.com.previewdns.com/ (or whatever your preview DNS URL happens to look like). Installation should finish without problem, but when you try to log into the admin panel, you’ll see that it’s a no-go. No error, no warning, nothing — it will simply show the login dialog again. This has to do with how Magento sets cookies for the admin panel, and to fix it, we need to temporarily comment out some code. Open the file at /app/code/core/Mage/Core/Model/Session/Abstract/Varien.php. Around line 94, you should see the following:

if (!$cookieParams['httponly']) {
    unset($cookieParams['httponly']);
    if (!$cookieParams['secure']) {
        unset($cookieParams['secure']);
        if (!$cookieParams['domain']) {
            unset($cookieParams['domain']);
        }
    }
}

if (isset($cookieParams['domain'])) {
    $cookieParams['domain'] = $cookie->getDomain();
}

Comment out this section, save the file, and upload it.

/*
if (!$cookieParams['httponly']) {
    unset($cookieParams['httponly']);
    if (!$cookieParams['secure']) {
        unset($cookieParams['secure']);
        if (!$cookieParams['domain']) {
            unset($cookieParams['domain']);
        }
    }
}

if (isset($cookieParams['domain'])) {
    $cookieParams['domain'] = $cookie->getDomain();
}
*/

Now, you should be able to access the admin panel. You’ll see a warning at the top, complaining about a {{base_url}} setting. This is what prevented you from logging in earlier. Go to System > Configuration from the main menu, and click the “Web” tab in the left sidebar. Expand the “Unsecure” section and change the “Base URL” value to the same preview DNS URL you entered during the installation. You can leave the other “Base…” settings alone. Next, expand the “Secure” section and make the same change to the “Base URL” value. Save your changes.

Magento Base URL configuration menu

Everything should be working now, but remember to uncomment the code in Varien.php. If you have any problems with or comments on your experience with Go Daddy and Magento, please leave them below.

Updates

Here are a couple more problems I came across and how to fix them.

Unable to Insert Uploaded Image into Content

If you get a “target element not found for content update” error when trying to insert an image, it has to do with Magento setting the wrong domain cookie for Go Daddy’s previewdns.com URL. Magento checks the HTTP_HOST server variable when it should be checking for HTTP_X_FORWARDED_HOST first. As a quick fix, open /app/code/core/Mage/Core/Controller/Request/Http.php and change this:

public function getHttpHost($trimPort = true)
{
    if (!isset($_SERVER['HTTP_HOST'])) {
        return false;
    }
    if ($trimPort) {
        $host = explode(':', $_SERVER['HTTP_HOST']);
        return $host[0];
    }
    return $_SERVER['HTTP_HOST'];
}

to this:

public function getHttpHost($trimPort = true)
{
    if (!isset($_SERVER['HTTP_HOST'])) {
        return false;
    }
    if ($trimPort) {
        if (isset($_SERVER['HTTP_X_FORWARDED_HOST'])) {
            $host = explode(':', $_SERVER['HTTP_X_FORWARDED_HOST']);
        } else {
            $host = explode(':', $_SERVER['HTTP_HOST']);
        }
        
        return $host[0];
    }
    return $_SERVER['HTTP_HOST'];
}

Note: any upgrades will probably break this code, but as the preview DNS URL is a temporary measure anyway, it shouldn’t be an issue.

Uploaded Images are Broken on Front-end

If uploaded images aren’t showing up on the website, try deleting the .htaccess file in your /media/wysiwyg folder. Simple as that.

3 thoughts on “Using Magento CE on Go Daddy Shared Hosting”

  1. For setting up Magento on preview Domain, do not do any of the above additional changes required for Magento working on preview Domain, just set your secure and unsecure url as your actual domain name.

    Like this article said, suppose your preview domain is http://www.example.com.previewdns.com and your actual domain is http://www.example.com then I am saying that do not do any additional changes provided in this article for setting up Magento on preview domain. Just set your secure web url and unsecure web url in Admin Panel > System > Configuration > Web > Unsecure URL > Base URL and Secure URL > Base URL to http://www.example.com and you are done.

    Thank you!

    1. Thanks for the input, Ali. Unfortunately, in my testing, it wasn’t as easy as that. Using the final domain name made the admin UI inaccessible from the preview domain.

Leave a Reply

Your email address will not be published. Required fields are marked *