Archive for June, 2009



Install PDFlib PHP on cPanel Dedicated server

Saturday, June 27th, 2009

One web developer contacted us and requested us to install PDFlib on their cPanel dedicated server which has PHP 5. As you must be knowing that PDFlib is not supported in the current cPanel easyapache, and especially with PHP 5 so we installed PDFlib Lite manually for him. Here is how we had installed it for them:

Download the pacakge, their official site is www.pdflib.com

root@server# wget http://www.pdflib.com/binaries/PDFlib/703/PDFlib-Lite-7.0.3.tar.gz
root@server#  tar xvzf PDFlib-Lite-7.0.3.tar.gz
root@server#  cd PDFlib-Lite-7.0.3
root@server#  ./configure --prefix=$HOME/usr --without-java
root@server#  make
root@server#  make install

Once this is done, we built PDFlib DSO by the below commands:

root@server#  cd ~/tmp
root@server#  pecl download pdflib
root@server#  tar xvzf pdflib-*.tgz
root@server#  cd pdflib-*
root@server#  phpize
root@server#  ./configure --with-pdflib=$HOME/usr
root@server#  make
root@server#  make test

Then, copied the PDFlib extensions to a seperate directory:

root@server#  cd ~
root@server#  mkdir extensions
root@server#  cp ~/tmp/pdflib-*/modules/pdf.so ~/extensions

Added the extensions in the php.ini using the below steps:

root@server#   php -i | grep php.ini
Configuration File (php.ini) Path => /usr/local/lib
Loaded Configuration File => /usr/local/lib/php.ini

Add the below line in php.ini

root@server#  nano /usr/local/lib/php.ini

extension_dir = "/root/extensions"
extension = "pdf.so"

Save php.ini file
Create a test PHP file under your domain to check if it works, below is the test code:


<?php

try {
$p = new PDFlib();

/*  open new PDF file; insert a file name to create the PDF on disk */
if ($p->begin_document(”", “”) == 0) {
die(”Error: ” . $p->get_errmsg());
}

$p->set_info(”Creator”, “hello.php”);
$p->set_info(”Author”, “Rainer Schaaf”);
$p->set_info(”Title”, “Hello world (PHP)!”);

$p->begin_page_ext(595, 842, “”);

$font = $p->load_font(”Helvetica-Bold”, “winansi”, “”);

$p->setfont($font, 24.0);
$p->set_text_pos(50, 700);
$p->show(”Hello world!”);
$p->continue_text(”(says PHP)”);
$p->end_page_ext(”");

$p->end_document(”");

$buf = $p->get_buffer();
$len = strlen($buf);

header(”Content-type: application/pdf”);
header(”Content-Length: $len”);
header(”Content-Disposition: inline; filename=hello.pdf”);
print $buf;
}
catch (PDFlibException $e) {
die(”PDFlib exception occurred in hello sample:\n” .
“[" . $e->get_errnum() . "] ” . $e->get_apiname() . “: ” .
$e->get_errmsg() . “\n”);
}
catch (Exception $e) {
die($e);
}
$p = 0;
?>

You need to get the below output in PDF format within your browser.

Hello world!
(Says PHP)

Let us know if this was helpful for you?

This article is released by SupportFacility.Com — the leaders in providing outsourced technical support, live chat support & help desk support for web hosts. Interested ? Opt for a trial now.


Zen cart smtpauth gmail configuration port 465 issue on cPanel VPS

Tuesday, June 16th, 2009

On a ecommerce website which had zen cart, in the “email options” the email address set was a free gmail account. When configured email address as per zen cart documentation we were facing error – where it said :

SMTP Error: Could not connect to SMTP server.

Settings in Zen cart:

E-Mail Transport Method : smtpauth
E-Mail Linefeeds : LF
Use MIME HTML When Sending Emails : true
Verify E-Mail Addresses Through DNS : false
Send E-Mails : true
SMTP Server Host Address tls://smtp.gmail.com or smtp. gmail.com: smtp gmail.com
SMTP Server Port Number : 465
SMTP Authentication Required : true
SMTP Authentication Username your@domain.com or you@ gmail.com : someaccount@gmail.com
SMTP Authentication Password your password : my password

From the server the connection to gmail SMTP was perfect:

root@server [~]# telnet smtp.gmail.com 465

Trying 74.125.79.109...

Connected to smtp.gmail.com (74.125.79.109).

Escape character is '^]'.

So, the connection from server was perfect. But, from zen cart it was not connecting.

Solution:

OpenSSL was not available in PHP. So, we recompiled PHP with OpenSSL support and everything worked just great.

This article is released by SupportFacility.Com — the leaders in providing outsourced technical support, live chat support & help desk support for web hosts. Interested ? Opt for a trial now.