Blogs

Installing IonCube on Zend Server CE

Installing IonCube on Zend Server CE

ionCube

http://www.ioncube.com/
For better or worse, ionCube is an encryption method for those that want to protect their code. A pain the neck for system admins, but some want to protect their PHP code, whatever.

Problem... Zend Optimizer +

Zend Optimizer+ does not play well with ionCube for whatever reason, so it's really picky on what order they get loaded during startup. It's important to put the configurations in the correct order, or it will just error out during start up.

Installing ionCube

You'll want to grab the loader files from here
http://www.ioncube.com/loaders.php

I downloaded and unzipped them to

/usr/local/ioncube

Edit php.ini file

Since ionCube is a Zend Extension and not a Zend Module (what's the difference? I couldn't tell you, but there is a different) we need to open up the file

/usr/local/zend/etc/php.ini

and at the very bottom it should look something like this.

; Local Variables:
; tab-width: 4
; End:
[Zend]
zend_extension=/usr/local/ioncube/ioncube_loader_lin_5.2.so
zend.install_dir=/usr/local/zend
zend.conf_dir=/usr/local/zend/etc
zend.ini_scandir=conf.d

Of course the important line is the ioncube line, it's important that it appears before the other lines.

Big Note about versions

It wasn't immediately obvious to me, but you need to match your PHP version with the version of ionCube (You can tell I'm using PHP version 5.2).

Verify install

After it's done you can restart the web server (if the web server doesn't start check your log files for clues). Then go to the Zend admin panel to see the PHP INFO page. You should see a section that looks like this....

php-info-ioncube.png

BD... BD.. BD.. That's all folks

porky-pig.jpg

Zend Framework - Doctrine ORM strange Zend Tool behavior.

Zend Framework - Doctrine ORM strange Zend Tool behavior.

Zend Framework... awesome.
Doctrine ORB... awesome.

Both of these combined.... PURE AWESOME.

I set up a project just at it says to on this page http://github.com/fmntf/zf-doctrine. It took some doing, but I got it working and was quite happy with my initial results. Then I needed to start a new project, so I just copied all the files, tweaked the DB name was flying with a new project... with one caveat.

One of the modules I created using a YAML file was not getting created in the DB when I ran zf build-project doctrine --reload. It was frustrating, I tried changing a bunch of things.

In the end the whole problem was that the module folder didn't have a controllers folder and that was it. So I created a controllers folder and then it created the corresponding tables in the db. I think this code has much to do with it

application/Bootstrap.php

<?php
 
class Bootstrap extends Zend_Application_Bootstrap_Bootstrap
{
  /**
   *  This will register all the module directories with ZF
   */
  public function _initModuleLoaders()
  {
      $this->bootstrap('Frontcontroller');
 
      $fc = $this->getResource('Frontcontroller');
      $modules = $fc->getControllerDirectory();
 
      foreach ($modules AS $module => $dir) {
          $moduleName = strtolower($module);
          $moduleName = str_replace(array('-', '.'), ' ', $moduleName);
          $moduleName = ucwords($moduleName);
          $moduleName = str_replace(' ', '', $moduleName);
 
          $loader = new Zend_Application_Module_Autoloader(array(
              'namespace' => $moduleName,
              'basePath' => realpath($dir . "/../"),
          ));
      }
  }
 
}

Rollback CentOS updates with RPM and YUM

Rollback CentOS updates with RPM and YUM

Every server administrator likes to sleep at night and every server admin knows server updates could prove disastrous. Just found out that RPM and Yum allow you the ability to rollback an update if some how it sent your system into a choking fit.

In your /etc/yum.conf at this in there somewhere

tsflags=repackage

This will repackage all your old files from the package (including config files) and store them in /var/spool/repackage

Also add the file /etc/rpm/macros and place this in that new file

%_repackage_all_erasures 1

When things go wrong

If you want to rollback changes to a certain time, then just issue commands like

rpm -Uhv --rollback '9:00 am'
rpm -Uhv --rollback '4 hours ago'
rpm -Uhv --rollback 'december 25'

Untested Yet

This is just stuff I'm reading, I have yet to test this under fire, maybe I'll play around on a test server

Resources

http://dailypackage.fedorabook.com/index.php?/archives/17-Wednesday-Why-...

Magento and Zend Server checkout redirect to cart [solved]

Magento and Zend Server checkout redirect to cart [solved]

IMG_3623.JPG

I installed Zend Server CE on one of my machines. The next day I noticed that you could not checkout from the website. It would bring you to the to the Billing Address, then after you hit "continue" it would redirect you back to the checkout page. No errors that I could see.

Then I remember a problem I had many moons ago that was very similar and a forum comment jogged my memory. Magento is looking for a Com.php file buried deep in the bowls of Zend Framework.

Did you know that Zend Server includes the latest copy of the Zend Framework? Yes and therein lies the problem, the Zend Framework version of Zend Server was overriding the built in Zend Framework of Magento.

Easy solution

Open up your .htaccess file and add this section in there somewhere. This will reset your include path, Magento will build this for you anyway so it shouldn't cause a problem.

###########################################
## Reset Include path
 
   php_value include_path  "."

Resources:
http://www.magentocommerce.com/boards/viewthread/28231/#t200692

Magento Upload HTTP Error [SOLVED]

Magento Upload HTTP Error [SOLVED]

This was a strange error with Magento. I was in a product, trying to upload an image. The image would upload find, but then error out with "Upload HTTP Error". I changed permissions up and down the /media and /var directories and made them as loose with permissions as I could.

Still no change.

Then I happened upon this comment in the forums.

To anyone that has a HTTP upload error AND has a password protected store directory (for under construction reasons):
remove the directory password protection and you’ll be able to upload your files again! That was what happened to me.

BINGO!

I removed the password protection for the admin (not the Magento password, but Apache basic password protection).

Reference:
http://www.magentocommerce.com/boards/viewreply/154831/

jQuery - Marking Current Link Active

jQuery - Marking Current Link Active

Have you ever wanted to have a link show as "Active" when a users is on that link? If you have a navigation at the top of your site and you want to visually indicate that the visitor is on that link, then you would usually add and "active" class to that link and style it appropriately.

This little snippet of code will do that.

$(document).ready(function(){
    var path = location.pathname.substring(1);
    if ( path ) {
        $('.header a[href$="' + path + '"]').addClass('active');
    }
});

location.pathname.substring(1); will return the url that you are on, subtract the hostname name.
a[href$="' + path + '"] looks for all anchor tags inside of the header block whose end match the path.

This is pure genius.

References:
http://docs.jquery.com/Tutorials:Auto-Selecting_Navigation

Web Server Setup of Permissions and Folders for multiple developers

Web Server Setup of Permissions and Folders for multiple developers

This summarizes how I currently set up my servers so that I can have multiple developers accessing certain client files, but retain control on which clients. The key to this whole process is groups.

Users

Create user accounts for your developers.

# useradd developer1
# passwd developer1
# useradd developer2
# passwd developer2

Groups

Create groups that section off your clients. For example.

# groupadd client1
# groupadd client2

Add apache to your groups

The web server is going to need access to the files so we will add apache to any groups we create for this purpose.

# usermod -a -G client1 apache
# usermod -a -G client2 apache

This will add apache to the groups client1 and client2.

Add developers to your groups

Your developers need to access your client files as well so we assign them to the groups. This will assign developer1 -> client1 and developer2 -> client2. Fun stuff.

# usermod -a -G client1 developer1
# usermod -a -G client2 developer2

Note: the "-a" appends, if you don't have this option, then it overwrites the users groups list, not good.

You could also section off your groups in other ways, such as by website.

DocumentRoot Folders

The web server folders will be located at /var/www/. So you will have :

/var/www/client1
/var/www/client2

Setting the setgid bit

# chmod 2770 /var/www/client1
# chmod 2770 /var/www/client1

Assigning User and Group ownership to the directories

This will have to be done by root, because you cannot assign ownership to another person unless you are root. Also, I created a dummy user of "www" to be the user owning the files, it doesn't matter who owns the files because we are not relying on that part of the permissions.

# chown www:client1 /var/www/client1
# chown www:client2 /var/www/client2

The permissions on these folders will now look like

#ls -l /var/www/
drwxrws---  6 www client1 4.0K Apr 14 15:28 client1
drwxrws---  6 www client2 4.0K Apr 14 15:28 client2

This will ensure that all files and folders created below this directory

Result

Developer1 can access Client1's files, change them, create new folders/files, but cannot get to Client2's files. Developer2 has the visa-vers result.

NOTE: any new file created by the developers will be owned by the developer and the group (e.g. the ownership will be developer1:client1). This is not a problem since we are not really checking user level permissions.

Helpful commands

Set the setgid on all folders.

# find ./* -type d -print0 | xargs -0 chmod 2775

Set all files to appropriate permissions

# find ./* -type f -print0 | xargs -0 chmod g+rw

Fixing the IE z-index bug.

Fixing the IE z-index bug.

We all know that IE is full of bugs and just plain sucks as a browser... if you didn't know that you can drop your geek badge off on the way out. So today I ran across the Z-Index bug in IE7.

Sometimes you've seen this behavior before:
Screen shot 2010-05-13 at 12.15.21 PM.png

The fix is to give the parent of the element with a z-index a slightly higher z-index

<div style="z-index: 1000">
  <div style="z-index:999">
    Content Here
  </div>
</div>

Resources:
http://brenelz.com/blog/squish-the-internet-explorer-z-index-bug/

Zend Server Mysql Socket problem with PDO [Solved]

Zend Server Mysql Socket problem with PDO [Solved]

The Problem

This answer has eluded me for months. I have Zend Server CE installed on my Mac (and linux web servers). I would use a DSN similar to the following (please note that my real password is not 'root').

mysql://root:root@localhost/thedatabase

This would result in an error in a PHP Fatal error of

'Can't connect to local MySQL server through socket '/tmp/mysql.sock''

This drove me mad looking for an answer. I had not configured it to connect through a socket, why was it doing that? To add more injury to this insult, if I tried to connect to Zend Server's mysql socket (/usr/local/zend/mysql/tmp/mysql.sock) I would still get the same error message.

The Best Solution

It's as simple as specifying 127.0.0.1 in replace of localhost. I guess if you do this, you force PDO to use a TCP connection.

Solution Alternative

I haven't tried this, but you could also symlink from

/tmp/mysql.sock

to

/usr/local/zend/mysql/tmp/mysql.sock

.

I'm not a big fan of symlinks that reach outside of the application.

Cause

It seems there is a bug in PDO PHP 5.2.x that is not fixed until 5.3.x.

Resources:
http://forums.zend.com/viewtopic.php?f=44&t=568

Spamassassin upgrade caused error of "exited or timed out without..."

Spamassassin upgrade caused error of "exited or timed out without..."

I just upgraded Spamassassin, and low, after I restarted it I received an error message while trying to start Spamassassin.

[root]# /etc/init.d/spamassassin start
Starting spamd: child process [21162] exited or timed out without signaling production of a PID file: exit 255 at /usr/bin/spamd line 2588.
[FAILED]

Per the article below, a simple sa-update at the command line updated the Spamassassin rules. Then it would start like normal.

Resources:
http://www.elehost.com/faq/web-tool-tips-and-fixes/54-spamassassin/172-f...

Syndicate content