Posted on

Magento javascript 404 breaks Admin menu…solved!

This is just a quick post about the Magento javascript giving a 404 error because it tripped me up and really shouldn’t trip anyone up. Basically the problem is the javascript include in Magento that looks like the one below gives a 404 error and causes javascript errors on the page:

<script type="text/javascript" src="http://example.com/js/index.php?c=auto&amp;f=,prototype/prototype.js,prototype/validation.js..../>

The problem

Trying to load the javascript URL directly in a browser gives a 404 error, which in turns breaks everything javascript related in Magento. For example the checkout page will no longer work, the Magento admin menus do not display which then causes the whole admin interface to be unusable.

The fix

Set the correct permissions on the javascript files in you Magento installation.

cd /path/to/your/magento/
chmod -R 755 js/*

That should get the javascript files showing up again without the 404 error, and once they are, your Magento admin interface, add to cart, checkout and everything else that relies on javascript, will also work, yah!

Posted on

Fixing Magento Login Problem after a Fresh Installation

This is just a quick little note to suggest two ways to solve the problem that you cannot log in to your Magento admin interface after a fresh install of Magento.

The Problem

The problem will manifest itself as a redirect back to the login screen, even though you typed the right username and password. If this problem is affecting you, you will be redirected back and see no error message. This indicates you have the right credentials, but the Magento Admin is just not letting you in. You can verify it by typing the wrong username and password, you’ll see you get redirected back and it shows an error message.

The problem occurs because the Magento backend tries to set a cookie on your browser, and then for some reason when you next make a request, the cookie is gone(or was never there). This makes Magento think you have never logged in, and of course it redirects you to the login screen. So the real guts of it is the missing cookie, we need to find out why it’s missing.

There are two three solutions (Update: now with bonus 3rd solution) I have come across that will solve this, there may be others too, so please feel free to post them below. Both of these solutions have been suggested in the comments of my post on Setting up Apache Virtual Hosting.

Solution 1: Domain Name with no dots

This is the most common solution, if you have set up Magento to run locally (on MAMP for example) then you may be accessing the Apache webserver using the localhost hostname. A security setting in browsers means that the cookie will not be set, though apparently in FF3 at least, this behavior is a bug?.

So simply stop using localhost, you can use your localhost interface (e.g. 127.0.0.1 or 127.0.1.1). To determine your localhost interface you can look at the contents of your hosts file:

# Look for the number to the left of localhost
cat /etc/hosts

or your interface configuration.

# Look for interface loX with the LOOPBACK flag (probably lo0)
ifconfig

Once you know which number to use, you can replace localhost with the number. If you have already installed Magento using localhost then it will keep writing out links to localhost, even after you have changed to using the IP address, you will need to change the base_url values in the core_config_data table, you can run a query like this to find the right config values to change:

SELECT * FROM core_config_data WHERE VALUE LIKE "%localhost%";

This should identfy two config values that will need to update with a query like:

UPDATE core_config_data SET VALUE="http://127.0.0.1/" WHERE path IN ('web/unsecure/base_url','web/secure/base_url') ;

I’m going to assume you know to put the right value into that query, and not use the example one I have provided!

After changing that value you should delete your var/cache contents, and then refresh the page. Now you should have Magento running on an IP address, not a hostname with no dots in it. Of course you could always set up a fake domain name like www.testing.com by using a Virtual Hosting setup like I describe in my post on how to configure a MAMP Virtual host.

Solution 2: Timezone differences between server and client

One other, less likely problem, is that the cookie is being set, but expiring immediately. To check this you can inspect the cookies your browser is holding, and check if there is one there from Magento. If there is then check both the timezone your magento installation is using , and the one you have set locally, perhaps your local time is not set properly?

Solution 3: Cookie domain does not match server domain

This caught me out when I was replicating a remote site on my local mac development environment. I thought it’d be worth adding this solution here, seeing as this post still seems to rank well for Magento install problems. I had changed the base URLs but had forgotten to check the core_config_data table for any other Magento configuration data that might have been interfering with cookies. The config path in question is: web/cookie/cookie_domain.

You can check the table with an SQL command like this – you should be on the look out for config values that have hard coded the old URL:

SELECT * FROM core_config_data WHERE VALUE LIKE "%domain.com%";
 
-- Be on the look out for something like this:
|       513 | DEFAULT |        0 | web/cookie/cookie_domain               | DOMAIN.com                                     |

And update it to an empty string (less secure) or the new actual domain (more secure) as shown below:

UPDATE core_config_data SET VALUE = "" WHERE config_id = 513;
-- or
UPDATE core_config_data SET VALUE = "domain.com" WHERE config_id = 513;

But wait, there’s more….

Thanks to Kristof aka Fooman for this gem:

Th solution here is to clear all your cookies related to the store domains and subdomains.

And yet still more possible issues, this time from Mauro Spivak:

This is an example of the more general issue that sessions are not able to be created. That could be because local.xml is instructing Magento to store them in a non-exsistent location such as in Maruo’s example – or may also be caused by permission issues on the filesystem when storing sessions in var/session. I’d suggest checking there is a session matching the session ID for your cookie to see if this issue is affecting you.

Hopefully one of these two three four solutions will get you back on track and able to log in to your newly installed Magento. Feel free to post problems or suggest other solutions in the comments below. I’m always more than happy to update my posts with helpful tips from readers.

Posted on

Magento Error: It is not safe to rely on the system’s timezone settings

Ok, that’s not a really good post title, because it’s actually a PHP error, nothing to do with Magento as such. You’ll only see it on certain systems when PHP is set to report warnings like this (E_STRICT). I’m bundling this into the Magento category because it happened to me when installing Magento on a reasonably simple Ubuntu 8.04. I thought it might be handy to quickly document the solution for other Ubuntu users.

The problem will look like this in Magento:

It is not safe to rely on the system's timezone settings error in Magento
It is not safe to rely on the system's timezone settings error in Magento

Which spews out a whole lot of stuff, the most important of which is the message ‘It is not safe to rely on the system’s timezone settings’ and later the suggested timezone, in my case ‘Pacific/Auckland’:

There has been an error processing your request.
Strict Notice: date() [function.date]: It is not safe to rely on the system's timezone settings. Please use the date.timezone setting, the TZ environment variable or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected 'Pacific/Auckland' for 'NZST/12.0/no DST' instead  in /var/www/magento/app/code/core/Mage/Core/Model/Locale.php on line 498
Trace:
#0 [internal function]: mageCoreErrorHandler(2048, 'date() [storeTimeStamp('1')
#3 /var/www/magento/app/code/core/Mage/Catalog/Model/Resource/Eav/Mysql4/Product/Collection.php(318): Mage_Catalog_Model_Resource_Eav_Mysql4_Product_Collection->_joinPriceRules()
#4 /var/www/magento/app/code/core/Mage/Eav/Model/Entity/Collection/Abstract.php(779): Mage_Catalog_Model_Resource_Eav_Mysql4_Product_Collection->_beforeLoad()
#5 /var/www/magento/app/code/core/Mage/Catalog/Block/Product/List.php(151): Mage_Eav_Model_Entity_Collection_Abstract->load()
#6 /var/www/magento/app/code/core/Mage/Core/Block/Abstract.php(642): Mage_Catalog_Block_Product_List->_beforeToHtml()

The fix is in your php.ini file for Apache. You’ll need to have the permissions required to edit the php.ini file, on Ubuntu that means you’ll probably need sudo access, or root access on systems where you actually log in as root. You can edit the file using this command:

sudo vi /etc/php5/apache2/php.ini

Or if you prefer a slightly less convoluted text editor (but much less powerful):

sudo gedit /etc/php5/apache2/php.ini

The change you need to make is to find the line like this:

; Defines the default timezone used by the date functions
; date.timezone =

To this:

; Defines the default timezone used by the date functions
date.timezone = "Pacific/Auckland"

Of course you may want your timezone, not mine, in which case you should substitute "Pacific/Auckland" for you timezone!

Hopefully that helps others who encounter this problem. The tricky thing is it won’t manifest itself on the CMS homepage, so you might do an install and think everything is fine, only to find that when you finally add categories and actually view one of them, Magento breaks (well… PHP does). So be wary.

Posted on

Simple Helix Magento Hosting Review

Right, so after over a month of putting this off I’m finally going to start writing some Magento Hosting reviews. The first is for Simple Helix. You might remember way back in April when I said I would be reviewing a few Magento hosts, and also running a free Magento hosting competition.

The competition is now over and I will be announcing the winners shortly, thanks to everyone who entered! I’ll compile the list of hosting annoyances you sent in and post it here shortly too. Just to re-iterate my thanks to the two hosting companies that put up prizes, A2 Hosting and Nexcess Hosting.

Enough about the competition, on to the Magento hosting review of Simple Helix hosting. I look at an installation from the point of view of someone doing them all the time. There are a few things I really like about hosting providers in general, the first is SSH access, especially the kind that’s granted by default when signing up. Simple Helix thankfully provide simple clean SSH access (not the ugly cPanel style java applet), which is something that I really appreciate. The other thing I find really helpful is the welcome email – hosting providers always send a welcome email. From a technical point of view I just love it when hosts lay out all of the hosting information in plain text, so I can easily copy paste it, without trawling through screens of fluff. Simple Helix scores points on both of these factors. But I’m sure if you don’t sign up for hosting every month, these kind of things are one off and you don’t really care!

I bet what you do care about is speed, disk space and bandwidth (and possibly support?). So here’s my take on those factors. My initial reaction to the speed question was wow, good – their server pulled the Magento install down at 6MB/s – that’s close over a 10Mbps pipe, so I can tell right away that they have decent internet facing bandwidth. Another indicator of speed is the unzip of the Magento package. If it’s almost instantaneous then you know the hardware is modern, with Simple Helix this was the case. So I knew they had a decent connection and decent modern hardware. The only other question is: how many people do I have to share with! Because that really decides what kind of performance I will get.

Being in New Zealand it’s always difficult to judge exactly how quickly a page will load for users in the Northern Hemisphere. That said, I found the Simple Helix pages loaded really quickly even way down under, and I know there are reports of that not being the case for everyone. One thing to consider is that some users may forget to enable caching for Magento, which is a sure fire way of slowing it down 3-4x, so always enable caching on production installations!

Database setup was incredibly easy, they do not use the standard cPanel style interface, so the usually 3 step process was made simpler and much easier, probably really helpful for people doing their own installations that are not familiar with hosting panels.

The last thing I noted was that Apache mod_rewrite was enabled by default, which I know may seem like an absolutely obvious thing for a hosting company, but I have been surprised by the number of them who do not do this! It is important for Magento SEO to have the rewrites enabled, and to use them, it’ll mean your URL’s can be of the form yourdomain.com/my-keyword-loaded-product-name.html which will help (hopefully).

The price and specs of their plans; $20 for 50GB bandwidth and 5GB of storage and $50 for 100Gb of bandwidth and 25GB of storage are definitely at the upper end of the shared hosting spectrum. In fact for $75 per month you can actually get an Amazon EC2 server, which is what I do personally and highly recommend. I am working on an EC2 AMI for a pimped out version of Magento (with extremely high performance, data security and ease of use) – details to follow in the next couple of weeks.

So what’s my conclusion, Simple Helix Hosting seems professional, modern, speedy and well configured for Magento. Their plans are $20 or $50, which is on the higher side, but it seems to me they’re worth it. If you’re in the market for Magento Hosting, Simple Helix are well worth trying out.

Update: I just want to add that this review and my recommendation of Simple Helix is based on the short time I spent setting up and testing Magento on their platform. I have since read a fair bit of negative feedback about the stability of their hosting and I can’t really comment on this because I didn’t experience it. So please keep this in mind when you are considering my review. Also, I will add that I’d always recommend doing your own backups and not relying on your hosts backup support.

Posted on

Free Magento Hosting Competition

Yes that’s right, I am offering two 12 month shared hosting plans as prizes for a Free Magento Hosting Competition – no strings attached, totally free. Why? Well, constantly doing Magento installations for other people gives me a great deal of insight into the operations of hosting companies. I thought it was time I started sharing those insights by doing a series of reviews for web-host companies that offer Magento hosting.

I reached out to several prominent host companies asking for a trial access period to test installations for my hosting reviews. Not only have the handful of initial companies been very helpful and co-operative, two of them have actually gone one step further and offered a prize for my readers!

Just to give those two companies a quick and well deserved shout-out for their generosity, a big thank you to A2 Hosting and Nexcess Hosting. To sweeten the deal even more I have decided to also offer free Magento installations to the winners of those two 12 month packages. So you’ll not only get a free year of Magento hosting, you’ll get a professional Magento installation done for free too!

I haven’t started writing up the Magento installation hosting reviews yet, but they will be trickling in over the next week to 10 days. I just thought I’d let you all know I have the hosting prizes available and will be starting to accept entries to the competition. What’s the competition, you ask?

I’m going to compile a list of top do’s and dont’s for hosting companies, based on my readers experiences. So I want you to tell me about your positive and/or negative experiences with web hosting companies. I’ll compile them and create the lists. All entries will go in the draw to win one of the two 12 month hosting packages. If your entry makes me laugh, I’ll make it a blog post, so be funny and get a free link!

So please go to my competition page and enter the draw, I’m really looking forward to hearing about other people’s experiences with web hosting. I bet you are looking forward to a chance to win some super sweet prizes.

If you are a Magento hosting company interested in being reviewed, please contact me to make arrangements.