Zend Guard Loader on CentOS
Created: Last updated:
How to install Zend Guard Loader on Linux CentOS, that's what this document is all about. See below for more information About other Operating Systems.
Download the correct version
First task is downloading the correct version. When you go to Zend and the Download Page for the modules you will get the Operating System tab for your current system. When I visit from my Windows desktop I will get the Windows tab, my Android shows the Linux tab and the iPod, guess what, the Mac OS X.
So, watch out and choose wisely!
Select Linux tab
Unfortunately the design and the text within the tabs isn't very helpful or distinct in telling what operating system and versions you are looking at. For CentOS make sure you clicked the Linux tab and you should see five versions. On top Zend Guard followed by Zend Optimizer and Zend Guard Loader.
Optimizer versus Guard Loader
Now you may be wondering what is the difference between Zend Optimizer and Zend Guard Loader?
If you have PHP 5.2 or earlier you will need Zend Optimizer whereas the Zend Guard Loader must be used for PHP 5.3.x; we don't know yet what the future holds for 5.4.
If you don't know what PHP version is on your system simply run php -v command. It'll tell you the version on the first line.
Note that I don't have PHP <5.3 on CentOS so Zend Optimizer for me is not an option and I cannot verify and show this process. If you have PHP 5.2 or earlier you will need the Zend Optimizer runtime and I guess the process will be pretty much the same. I simply cannot see and therefore verify the final result.
32-bit versus 64-bit
Now, for Zend Guard Loader on Linux you have two options, a 32-bit version and a 64-bit version. It is important that you install the correct version and while the download (tar.gz) packages have distinct names the filename for the actual module itself ZendGuardLoader.so is the same for both versions.
In case you don't know what processor your system has you can run the following command
- [root@centos ~]# uname -p
- x86-64 // this would be a 64-bit system
Download on the command line
If you follow this for an installation where you work remotely with ssh/PuTTY and wonder how to download on the command line in Linux here is a hint for how to download the file. If you already know you can skip ahead, of course.
There is a handy little utility called wget for retrieving files with HTTP or FTP protocols. Once you have the correct link name from above you can paste it to the wget command and download the file from Zend directly to your Linux box. Extract the tar.gz and you should be ready for the next steps. If you don't have wget yet on your Linux server you can find and install it with yum.
When you have your download and the module extracted it is time for the installation.
Install the module
Installing the Zend Guard Loader module requires three simple things: copy the module file to a special place, add this path to a php config file and restart your web server.
Now lets break down the three steps.
Copy the module
As you can see in the downloaded package the Zend Guard Loader is only a single file. Zend calls it a runtime but in terms of the installation on your Linux system this file is known as a module. You can or should copy this module to one specific location but it is up to your preference because in the next step you can add an absolute path.
The best location is with all the other PHP modules. The PHP modules directory on CentOS should be /usr/lib64/php/modules/ and it should contain some other modules.
Add path to config (php.ini)
Note the final step but the one that ties all together is adding the path to the php config which has a few options—with the php.ini as the common and default option. PHP actually allows you to have multiple configuration files, i.e. not just the default php.ini file.
Your downloaded file has a template for what you have to add. Following is the bare minimum you will need. Note that the path in zend_extension is an example and maybe be different on your system.
- ; Enable ZendGuard loader module
- ; Enables loading encoded scripts. The default value is On
- ; Disable license checks (for performance reasons)
- ; The Obfuscation level supported by Zend Guard Loader. The levels are detailed in the official Zend Guard Documentation. 0 - no obfuscation is enabled
- ; Path to where licensed Zend products should look for the product license. For more information on how to create a license file, see the Zend Guard User Guide
- ; zend_loader.license_path=
I personally use a dedicated zendguard.ini file in my /etc/php.d/ directory. the naming doesn't matter because PHP looks at and loads all ini files in this directory. In fact, you should already find a few ini files in that directory.
Note that these files are only touched once (see next step) hence the overhead for such an additional file is basically zero. Note that these files are uses under the term dynamic extensions which may be confusing
They are loaded dynamically when the web server is started, again see next step. Dynamic in this sense means they are not compiled into the PHP core and not that dynamically for every request.
Reload httpd configuration
Last but not least you reload the PHP configuration. In case you don't know when this happens: when you restart your web server.
For our CentOS Linux system this usually means you have an Apache web server. For an Apache httpd to reload the configuration you have the following options.
- [root@centos ~]# service httpd graceful
- [root@centos ~]# service httpd reload
- [root@centos ~]# service httpd restart
- For the different options please see the manual
And that's all she wrote for the installation! Except for maybe verifying if all went well. Please read on.
Verify your Zend Guard Installation
To see if this all was successful follow the next document and How to verify a Zend Guard Installation.
About other Operating Systems
This document is mainly about CentOS but the process for other Linux distributions should not be any different, though. Back to Top of page.
CentOS is based on RedHat so there shouldn't be any differences in the procedure.
Other Linux distributions
There might be some differences in paths but overall the procedure should be the same. If you know your distribution you should know what the correct path is.
Amazon AWS EC2 cloud
If you have a Linux instance in the Amazon Cloud AWS EC2 and need Zend Guard Loader for your web application this procedure is the same because most default instances are based on CentOS/RedHat.
What about Windows?
If you are looking for installing Zend Guard Loader on Windows and XAMPP in particular I will have a document up soon—unless I forget. If you have any problems with the Zend Guard Loader please check out the other documents in this section. Use the breadcrumbs above to get to the parent webpage's overview.