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.

Quick Steps to Install Apache, MySQL, and PHP in Windows

There are plenty of tutorials for WAMP installations (Windows, Apache, MySQL, and PHP), but I don’t know of any that have quick, easy-to-follow directions for someone familiar with Web development, but not necessarily with getting a local installation started.

UPDATE: The following instructions are no longer up to date. To install a WAMP server, try using XAMPP.

Installing Apache

The latest version of Apache can be found at http://httpd.apache.org/download.cgi. Unfortunately, the Windows version is not always up to date with the Unix version, so you’ll have to scroll down the page until you find the most recent Win32 version. You should notice a few download options for Win32 (“source” or “binary” and “without crypto” or “including OpenSSL”). Unless you plan on using SSL, download the binary version without crypto (it’ll be an MSI file).

After the download completes, open the file and run it. Click “Next”, accept the terms and conditions, and continue through any other screens until you’re asked for some server information. Enter localhost for both the network domain and server name fields, and use whatever e-mail address you like for the administrator’s e-mail field.

If you want Apache to run, even when you’re not logged in, leave it set to run as a service. However, if you’ll only be using it with an occasional project, change it so that it has to be manually started. The “typical” installation should be fine, as well as the default destination folder. After installation completes, click “Finish.”

To start Apache (assuming it isn’t running as a service), you can navigate to the “bin” folder (found at “C:\Program Files\Apache Software Foundation\Apache2.2\bin” in most cases) and run the “httpd.exe” application. Personally, I run it from the command line. To do this, open a command prompt, and update your PATH environment variable (e.g. SETX PATH "%PATH%;C:\Program Files\Apache Software Foundation\Apache2.2\bin"). Close the command prompt, reopen it, and now you should be able to launch Apache by simply typing httpd.

To make sure everything is working, visit http://localhost/, and you should see a blank page with the words, “It works!” If not, try http://localhost:8080/ — 8080 is a common port used if the standard port 80 is unavailable. The Web page being displayed is found in the “htdocs” folder of your Apache install.

Installing PHP

Visit http://www.php.net/downloads.php and download the Windows binaries and source (Thread Safe, ZIP format) of the latest version. Extract the ZIP files to a “PHP” folder in your “Program Files” directory (e.g. “C:\Program Files\PHP” — you’ll need to create the “PHP” folder). After extracting the files, make a copy of the php.ini-development file and rename it to php.ini.

Now, we need to make some configuration changes for Apache to recognize PHP. Open the “httpd.conf” file in the “conf” folder of your Apache installation, and search for a list of lines starting with “LoadModule”. After those lines, add the following:

LoadModule php5_module "C:/Program Files/PHP/php5apache2_2.dll"

Next, look for the <IfModule mime_module> section of httpd.conf and add the following just before it’s closing </IfModule> tag:

AddType application/x-httpd-php .php

Finally, add the following to the very end of your httpd.conf file:

PHPIniDir "C:/Program Files/PHP"

To verify that PHP is working, create an index.php file in the htdocs folder, and add the following to it:

<!doctype html>
<title>PHP Info</title>
<?php echo phpinfo(); ?>

Visit http://localhost/index.php (or http://localhost:8080/index.php), and you should see some tables displaying your current PHP and server settings. Now we’re ready to install MySQL.

Installing MySQL

First, download the MySQL Community Server MSI file from http://dev.mysql.com/downloads/mysql/. The installer is fairly simple — choose “Typical” when prompted for the setup type, and it should complete shortly afterward. Check the box to run the configuration wizard after the install. The default settings should suffice for most of the screens, but you’ll need to choose a memorable root password before finishing.

As for MySQL, that’s it. No additional setup needed. Create a database and start programming — you’re local dev machine is ready to go!

Conclusion

Hopefully, you now have a working WAMP installation. I purposely left out a lot of configuration options, as the purpose of this guide was to get you up and running as fast as possible. If you notice any mistakes or have any issues, feel free to post them in the comments below.