SourceGuardian is a software protection and licensing solution used to protect PHP code from unauthorized access, copying, and modification. It is a commercial product developed by Inovica Ltd, and it is designed to help PHP developers protect their intellectual property and commercial software products.
Frequently you may come across PHP software that is protected using Source Guardian and requires the SourceGuardian PHP loader installing in order to run the application. Unfortunately custombuild, the software management script for DirectAdmin does not yet provide the option to install SourceGuardian out of the box. In this guide we will show you the simplest way to get it up and running on PHP8 inside of DirectAdmin.
First you need to access the server via SSH and login using the root user, or any user that has eqivelant priveleges.
create an install directory for SourceGuardian PHP extension, this will be where we store all of the .lin extension files:
mkdir /usr/local/sourceguardian
Now switch into that directory:
cd /usr/local/sourceguardian
You can download the SourceGuardian loader files from here:
https://www.sourceguardian.com/loaders.html
Due to the limitations (T&C Checkbox) on the Source Guardian website performing a wget based download directly into our servers working directory is not possible. This is unfortunate as it means you need to manual download and manual upload the files.
The file we used for this guide is "Linux x86_64" as we are on Rocky Linux 9 64bit.
Once downloaded we now we need to upload the file via SFTP so we can extract it. Alternatively if you are using DirectAdmin like us you can upload the file using the control panel and then copy the tar.gz file to destination directory.
To upload via the DirectAdmin control panel login to your DirectAdmin instance as an admin at:
https://sub.mydomain.com:2222
Ensure your Access Level is Admin and navigate to:
System Info & File > File Manager
Now use the DirectAdmin built in file manager to upload the previously downloaded extension files for SourceGuardian.
When the files have been uploaded move them to the extension install directory by running:
mv /home/admin/loaders.linux-x86_64.tar.gz /usr/local/sourceguardian/
Replace the /home/admin part with the relevant admin username which you uploaded the.
Change back to the install directory, change the permissions and extract the archive:
cd /usr/local/sourceguardian/
chown root:root loaders.linux-x86_64.tar.gz
tar -xf loaders.linux-x86_64.tar.gz
For good practice we like to remove any "junk" files from the directory:
rm -rf 'SourceGuardian Loader License.pdf'
rm -rf loaders.linux-x86_64.tar.gz
Now we need to add the extension to a 90-custom.ini file, PHP will automatically load this file unless you have a heavily customised install. To do this run the following command:
echo "zend_extension = /usr/local/sourceguardian/ixed.8.1.lin" >> /usr/local/php81/lib/php.conf.d/90-custom.ini
Depending on the version of PHP you are running there are two parts of the above command that you may wish to change:
Based on this if the install was for PHP 5.4 the command might look similar to the following:
echo "zend_extension = /usr/local/sourceguardian/ixed.5.4.lin" >> /usr/local/php54/lib/php.conf.d/90-custom.ini
Also note the PHP install location may vary depending on your distro or PHP install source.
The server we have been working on is running php-fpm so we need to restart this with:
systemctl restart php-fpm81
After restarting php-fpm we figured a restart would also be of use. For good measure we also restarted Apache:
systemctl restart httpd
We can check that SourceGuardian loader is running inside PHP correctly with this command:
php -i | grep "SourceGuardian Loader Support"
At this stage we should get an output similar to the following:
[root@server ~]# php -i | grep "SourceGuardian Loader Support"
SourceGuardian Loader Support => enabled
If you get the second line (SourceGuardian Loader Support => enabled) this confirms that everything is correct.