Synology DSM - How to install extensions in php.ini (PDFlib)

Questions about HTTP Access/Mods may go here
Forum rules
1) This is a user forum for Synology users to share experience/help out each other: if you need direct assistance from the Synology technical support team, please use the following form: ... p?lang=enu

2) To avoid putting users' DiskStation at risk, please don't paste links to any patches provided by our Support team as we will systematically remove them. Our Support team will provide the correct patch for your DiskStation model.
I'm New!
I'm New!
Posts: 5
Joined: Fri Feb 07, 2014 2:59 pm

Synology DSM - How to install extensions in php.ini (PDFlib)

Unread post by reconx86 » Thu Jul 17, 2014 12:51 am

I summarize my experience and research-methods for adding (PDFlib) extension thru Putty to my php configuration. It may save you time if you want to do something alike.

1. Locate your php.ini file
The following command is handy when you are clueless about where to find a specific file in your DSM without wasting time going thru the tons of personal files, this is how I found php.ini:

Code: Select all

find / -path "/volume*" -prune -o -iname "php.ini" -print
Result on DSM 5.0: /etc/php/php.ini

Code: Select all

vi /etc/php/php.ini
2. Open php.ini
Type vi command:

Code: Select all

Result on DSM 5.0: extension_dir = /usr/lib/php/modules
this is the module directory which is where we will place our

press n, a couple of times until you see a range of "extension =" lines. press i, to insert extenstion = after these hit ESC and :wq to save your entry

Code: Select all

cd /usr/lib/php/modules #path derived from previous result
3. Determine what processor you have
uname -m
Result on my DSM: i686 (which is a 32 bit intel proccessor), if nothing appears use uname -a

4. Download pdflib
surf to
Based on the result of uname -m, i right-clicked: "Linux/FreeBSD" > "Linux x86" > "PHP" and selected "Copy Link Location" in google chrome

Which I copied back to PuTTy, preceded with the command wget:

Code: Select all

#Download tarball

#Extract tarball
tar -zxvf PDFlib-9.0.3-Linux-php.tar.gz 

#Get PHP version (result for me PHP 5.5.13):
/usr/bin/php -v

#list all sub-folders if your version is not the same, mt suffix means "multi-threaded"
ls PDFlib-9.0.3-Linux-php/bind/php/

#copy extension to the extension directory
cp PDFlib-9.0.3-Linux-php/bind/php/php-550/

#Apache restart for DSM 5.0
/usr/syno/sbin/synoservicecfg -restart httpd-user

#check if lib is correctly installed
php -i | grep "PDFlib GmbH"
If succesfull remove tarballs and extracted directory:

Code: Select all

rm PDFlib-9.0.3-Linux-php.tar.gz
rm -r PDFlib-9.0.3-Linux-php
You may stumble upon errors, like:

Code: Select all

PHP Warning:  PHP Startup: PDFlib: Unable to initialize module
Module compiled with build ID=API20121212,[b]TS[/b]
PHP    compiled with build ID=API20121212,[b]NTS[/b]
These options need to match
 in Unknown on line 0
TS basically means the module is Thread Safe (Multi Threaded) and your PHP binary is NTS (Single threaded)

Code: Select all

PHP Warning:  PHP Startup: Unable to load dynamic library '/usr/lib/php/modules/' - /usr/lib/php/modules/ wrong ELF class: ELFCLASS64           in Unknown on line 0
wrong ELF class: ELFCLASS64: Means you are running the module on the wrong processor (ISA) (in this case a 64-bit module on a 32 bit processor)

Remove the file, if errors like these occur and replace with the proper extension.

Code: Select all

Last edited by reconx86 on Fri Jul 18, 2014 3:04 pm, edited 7 times in total.

I'm New!
I'm New!
Posts: 5
Joined: Fri Feb 07, 2014 2:59 pm

Re: Synology DSM - How to install extensions in php.ini (PDF

Unread post by reconx86 » Fri Jul 18, 2014 2:39 pm

Quick PDF test script

Code: Select all

//Creating a basic PDF (A4) document with PHP
try {

	// create new instance of the ‘PDFlib’ class
	$pdf=new PDFlib();

	// open new PDF file
	if(!$pdf->begin_document("", "")){
		throw new PDFlibException("Error creating PDF document. ".$pdf->get_errmsg());

	$pdf->set_info("Author", "John Doe");
	$pdf->set_info("Title", "My PDF title");
	$pdf->show("PHP is great for creating PDF documents!");

	// end page
	// end document
	// get buffer contents

	// get length of buffer
	// display PDF document
	header("Content-type: application/pdf");
	header("Content-Length: $len");
	header("Content-Disposition: inline; filename=example.pdf");
	echo $buffer;
catch (PDFlibException $e) {
	echo "Error Number:".$e->get_errnum()."n";
	echo "Error Message:".$e->get_errmsg();
If you want to save the PDF document to disc, comment out the $buffer=$pdf->get_buffer(); and set a filename as the first parameter of begin_document() (eg: $pdf->begin_document("/uploads/test.pdf", ""))

Also very important, make sure you set the upload folder to 777, at least for me it didnt seem to work with any less permissions

I'm New!
I'm New!
Posts: 1
Joined: Mon Aug 03, 2015 8:14 am

Re: Synology DSM - How to install extensions in php.ini (PDF

Unread post by hsc123 » Mon Aug 03, 2015 8:26 am


I followed your Installation - steps, but I have the Problem that the library can't be loaded:

php -v
PHP Warning: PHP Startup: Unable to load dynamic library '/usr/lib/php/modules/' - /usr/lib/php/modules/ cannot open shared object file: No such file or directory in Unknown on line 0
PHP 5.5.26 (cli) (built: Jun 29 2015 17:43:23)
Copyright (c) 1997-2015 The PHP Group
Zend Engine v2.5.0, Copyright (c) 1998-2015 Zend Technologies
with Zend OPcache v7.0.6-dev, Copyright (c) 1999-2015, by Zend Technologies

as you see the lib is at the correct place:

DiskStation> ls -l php*
-rwxr-xr-x 1 root root 7101294 Aug 3 08:58

can you please help me? What's the Problem?
Jürgen Bertsche

I'm New!
I'm New!
Posts: 2
Joined: Wed Oct 26, 2016 7:38 am

Re: Synology DSM - How to install extensions in php.ini (PDFlib)

Unread post by pik » Wed Oct 26, 2016 7:43 am

Hello all. I know it's an old post but I have the same problem as hsc123 and I can not fix it. Does anyone know the solution?

Post Reply

Return to “HTTP/Apache Mods”