Install Magento on CentOS 5.4

Here you can find our experience in installing Magento on CentOS 5.4 that we decided to share while there is some problems resolving steps.

Before we start we need to upgrade the actual version available in CentOS 5.4 Official Release of PHP, which is version 5.1, to version 5.2 or later (PHP version 5.3 in our case), to be able to install and work with Magento.

To be safe and make things easily we will use YUM as Package Management Software. We assume that you have YUM installed and running.

Update PHP 5.1 to 5.3 under CentOS 5.4 using YUM:

First we need to make use of the RPM maintained by Remi Collet, here is the code to execute under bash to get it installed but disabled by default:

wget http://download.fedora.redhat.com/pub/epel/5/i386/epel-release-5-3.noarch.rpm
wget http://rpms.famillecollet.com/enterprise/remi-release-5.rpm
rpm -Uvh remi-release-5*.rpm epel-release-5*.rpm

now we will update PHP and related libraries:

yum --enablerepo=remi update php php-* mysql-*

Using YUM to install MBSTRING for PHP 5.*:

 yum --enablerepo=remi install php-mbstring

Using YUM to install MCRYPT for PHP 5.*:

 yum --enablerepo=remi install php-mcrypt

Using YUM to install GD for PHP 5.*:

 yum --enablerepo=remi install php-gd

Using YUM to install DOM for PHP 5.*:

 yum --enablerepo=remi install php-dom

At this stage we have the system requirements asked by Magneto, we will copy Magento to our website, in my case I will put it in Magento directory under the website root.

Actually our PHP version is 5.3 which causes a small compatibility problem with Magento, when you browse to your-website-folder/your-magento-folder/ you should have an error (if you have display_errors enabled in your php, if not click here to know how to activate it) saying this:

For those who have noticed this Fatal error:

Method Varien_Object::__tostring() cannot take arguments in /magento/lib/Varien/Object.php

This is a Magento compatibility issue relatively to php 5.3. To fix it we need to change a couple lines of code in two separate files:

1- in your-website-folder/your-magento-folder/app/code/lib/Varien/Object.php (Line 484) :

Change this:

public function __toString(array $arrAttributes = array(), $valueSeparator=’,’)

to this:

public function __invoke(array $arrAttributes = array(), $valueSeparator=’,’)

2- in your-website-folder/your-magento-folder/app/code/core/Mage/Core/Controller/Request/Http.php (Line 274) :

Change this:

$host = split(':', $_SERVER['HTTP_HOST']);

to this:

$host = explode(':', $_SERVER['HTTP_HOST']);

For those who have noticed this Fatal error:

Warning: include_once(Varien/Autoload.php) [function.include-once]: failed to open stream: No such file or directory in C:\inetpub\wwwroot\app\Mage.php on line 50
Warning: include_once() [function.include]: Failed opening 'Varien/Autoload.php' for inclusion (include_path='C:\inetpub\wwwroot\app\code\local;C:\inetpub\wwwroot\app\code\community;C:\inetpub\wwwroot\app\code\core;C:\inetpub\\wwwroot\lib;.;C:\php5\pear') in C:\inetpub\wwwroot\app\Mage.php on line 50
Warning: include(Varien\Autoload.php) [function.include]: failed to open stream: No such file or directory in C:\inetpub\wwwroot\app\code\core\Mage\Core\functions.php on line 68
Warning: include() [function.include]: Failed opening 'Varien\Autoload.php' for inclusion (include_path='C:\inetpub\wwwroot\app\code\local;C:\inetpub\wwwroot\app\code\community;C:\inetpub\wwwroot\app\code\core;C:\inetpub\wwwroot\lib;.;C:\php5\pear') in C:\inetpub\wwwroot\app\code\core\Mage\Core\functions.php on line 68
Fatal error: Class 'Varien_Autoload' not found in C:\inetpub\wwwroot\app\Mage.php on line 53

If you have this, it is probably caused by a ” Bug ” on the Mage.php file of the pack magento-1.3.2.4.tar.gz.

To resolve it, open the file Mage.php that you can find in your-website-folder/your-magento-folder/app/Mage.php

In line 45, change this:

$paths[] = BP . DS . 'lib';

to this:

$paths[] = BP . DS . 'app' . DS . 'code' . DS . 'lib';

Final Step before getting all prepared for the Magento Installation

Changing Permissions for the Magento Folder

to 777 during installation and 755 after installation.

if you are running locally for the first time and you are new to this environment be careful about SELinux, you can disable it temporarily using

echo 0 >/selinux/enforce

Now you should be up and running ! You can proceed with the configuration. You will need to create a database and a user for Magento. you can follow installation guide or resources on the Internet for that, it’s easily available.

Enjoy, Vote and Comment please !

1 Star2 Stars3 Stars4 Stars5 Stars (1 votes, average: 5.00 out of 5)
Loading ... Loading ...
Share it:
  • Print
  • email
  • PDF
  • RSS
  • Add to favorites
  • Digg
  • Sphinn
  • del.icio.us
  • Facebook
  • Mixx
  • Google Bookmarks
  • Blogplay
  • blogmarks
  • Technorati
  • Yahoo! Bookmarks
  • Twitter
  • LinkedIn
  • Live

7 Responses to “Install Magento on CentOS 5.4”

  • Excellent Mr ITGRAPES. Well done !

  • I.T.GRAPES.com Admin:

    Thank you for your continuous support !

  • Hi Admin

    I have followed your instructions but I keep on getting the following error.

    PHP Extension “pdo_mysql” must be loaded
    PHP Extension “mcrypt” must be loaded

    Running Centos 5.4

  • I.T.GRAPES.com Admin:

    Hi,

    Just to be sure, did you installed remi repo on you system?

    wget http://download.fedora.redhat.com/pub/epel/5/i386/epel-release-5-3.noarch.rpm
    wget http://rpms.famillecollet.com/enterprise/remi-release-5.rpm
    rpm -Uvh remi-release-5*.rpm epel-release-5*.rpm

    to get PDO MYSQL installed you can do this:

      yum --enablerepo=remi install php-mysql php-pdo

    We will then edit php.ini file and add the extensions to it.

      nano /etc/php.ini

    Add ‘extension=pdo.so’

    Add ‘extension=pdo_mysql.so’

    save with rewrite.

    Concerning MCRYPT, What error do you get when you execute this :

    yum --enablerepo=remi install php-mcrypt
  • I am really trying to like and even switch to Magento, but just getting past the install with code level bugs that need tweaking is a bit of a worry. How stable is Magento once it is in, installed and you have a live site, do you stress every time a minor release is made? Or am I being over anxious, as I said I really want to use and like it but so far it has just been pain getting it to install.

    Thanks, great blog post by the way.

    Dave

  • I.T.GRAPES.com Admin:

    Hi Dave, Thank you for your great comment about the post.
    We tried the latest version of Magento (1.4.0.1) and seems that the errors we noticed have been corrected. Once installed, Magento seems to be very stable when it’s correctly configured. You can check on Magento website the number of persons and companies using it, this can give you an idea if it’s worth or not to rely on Magento to run your business. Our point of view is that it’s a good plateform. You can run it on a test server to check if it’s suitable for your needs and better get assisted to configure it correctly.

  • [...] 5.2/64bit</a>, <a href="http://www.itgrapes.com/content/index.php/knowledge_base/web_development/install-magento-on-centos-5…">CentOS5.4</a> and one from <a [...]

Leave a Reply