SourceGuardian PHP Extension – Install and Enable It On Ubuntu Linux 15.04

Phpinfo

SourceGuardian is a widely used software that lets you encrypt and secure your PHP scripts. In this way, your source code is secure and no one can view or compile it, you can lock and unlock your code on the basis of strict parameters like server IP, server MAC address or Domain name, in this way, your code is unlocked on authentic place only. Source Guardian PHP extension is not enabled by default, if you have LAMP setup running on your system, you need to install and configure it separately. That’s what we will be focusing in this article, how to install and configure Source Guardian PHP extension on Ubuntu 15.04.

Installing SourceGuardian on Ubuntu

We are running PHP 5.6 and Apache 2 on our test system. Lets see how we can install and configure this extension there.

First of all, go to /usr/src directory by running the following command:

cd /usr/src/

Here create a new directory named “loader” by running the following command.

sudo mkdir loader

Now go into this newly created directory.

cd loader

And download Source Guardian tar file here.

For 32bit system:

sudo wget http://www.sourceguardian.com/loaders/download/loaders.linux-i386.tar.gz

For 64bit system:

sudo wget http://www.sourceguardian.com/loaders/download/loaders.linux-x86_64.tar.gz

As soon as the file has been download, extract it by running the following command:

tar vxf loader*.tar.gz

extract loader

That’s all, Now we need to copy the loader configuration file to PHP extenstion directory. Please note that if your PHP version is different, then you might have different folder/file name, run command accordingly.

sudo cp ixed.5.6.lin /usr/lib/php5/20131226/

Create a file for sourceguardian inside PHP5 mod’s directory i.e. /etc/php5/mods-available/, run following command to create file.

sudo gedit /etc/php5/mods-available/sourceguardian.conf

It will create an empty file in GEdit text editor, paste following content in this empty file. [Change your path or file names in case you are using different version of PHP]

[sourceguardian]

zend_extension=/usr/lib/php5/20131226/ixed.5.6.lin

Gedit add extension

Save the file and return back to the terminal windows. Run following command to enable this extension.

php5enmod sourceguardian

We are almost there, restart apache web server by running the following command:

sudo /etc/init.d/apache2 restart

Congratulations, SourceGuardian has been installed and enabled for your PHP now 🙂

In order to verify it, we need to see the output of phpinfo() function. Go to /var/www/html directory by running the following command.

cd /var/www/html

Create an empty file here, named phpinfo.php by running the following command.

sudo gedit phpinfo.php

And paste following code in this file.

<?php
phpinfo();

?

phpinfo file

Save the file, launch your web browser and load http://localhost/phpinfo.php . It should load a page as shown in following screenshot, From here you should be able to confirm that Source Guardian is configured successfully (shown encircled in screenshot).

Phpinfo

Enjoy securing and encrypting your PHP code.

Conclusion

Source Guardian is one of those few PHP extensions which focus on security and encryption. Not all hosting providers have this installed at the moment, but its certainly an option to consider when choosing your hosting provider or hosting setup.  We hope you enjoyed the article, do let us know in comments  🙂