Howto: Install PDFlib-Lite and PDFlib on Centos server

To install PDFlib on Centos server, you may follow the guide below,

1. Download the PDFlib-Lite package,

cd /usr/local/src 
wget http://www.pdflib.com/binaries/PDFlib/705/PDFlib-Lite-7.0.5.tar

2. Extract and go to PDFlib-Lite folder,

tar -zxvf PDFlib-Lite-7-* 
cd PDFlib-Lite-7.0*

3. Configure PDFlib-Lite,

./configure --prefix=/usr/local

4. Create installation file and install it,

make
make install

5. Once PDFlib-Lite installed, download PDFlib with PECL,

pecl download pdflib

6. Extract and enter the folder,

tar xvzf pdflib-*.tgz 
cd pdflib-*

7. Create configuration file,

phpize

8. Configure, create configuration file and install PDFlib,

./configure
make
make install

9. A pdf.so will be created in your PHP extension folder, check it from PHP info,

php -i | grep extension_dir

10. If it is not exists, add the following line to the php.ini,

extension="pdf.so"

Show Detailed Error when Moodle show blank page

One of the customer is facing blank page when they are using Moodle application but they can’t find a way to show the error from Apache error_log.

After search around from the Internet, it is found out Moodle used their custom PHP ini_set function to define the PHP value.

In order to show the detailed error which got from Moodle, simply add the following code to the config.php file.

ini_set ('display_errors', 'on');
ini_set ('log_errors', 'on');
ini_set ('display_startup_errors', 'on');
ini_set ('error_reporting', E_ALL);

Now, browse to your page again and you should see the detailed error by now.

Howto: Install Apache 2.2.x and PHP 5.3.x on CentOS 5

Assume that you do not want to spend money on your server to have a control panel and having minimal requirement for your website,

1. Install the required packages,

yum install bison flex gcc db4 db4-devel libxml2-devel libpng-devel mysql-devel make

2. Download Apache source (refer the latest one from http://httpd.apache.org/)

wget http://apache.petsads.us//httpd/httpd-2.2.21.tar.gz

3. Download PHP source (refer the latest one from http://www.php.net/)

wget http://my.php.net/get/php-5.3.8.tar.gz/from/us.php.net/mirror

4. Build the Apache,

tar zxvf httpd-2.2.21.tar.gz
cd httpd-2.2.21
./configure --enable-so --enable-rewrite=shared
make
make install
cd ..

5. Build the PHP,

tar zxvf php-5.3.8.tar.gz
cd ../php-5.3.8
./configure --with-apxs2=/usr/local/apache2/bin/apxs --with-mysql --enable-bcmath \
--enable-ftp --enable-magic-quotes --with-pear --enable-sockets --with-zlib --with-gd
make
make install
cp php.ini-production /usr/local/lib/php.ini
cd ..

6. Now, start the Apache services,

/usr/local/apache2/bin/apachectl start

Howto: Enable FastCGI from Linux

To enable FastCGI from your Apache server, you may follow this article.

1. Copy the php.ini file to your cgi-bin folder.
2. Create a file named php.fcgi in the cgi-bin folder.
3. Insert the following script,

#!/bin/sh
export PHP_FCGI_CHILDREN=1
export PHP_FCGI_MAX_REQUESTS=10
exec /usr/local/cpanel/cgi-sys/php5

4. Change the php.fcgi permission to 755.
5. Create/Edit the .htaccess file and insert the following script.

AddHandler php5-fastcgi .php
Action php5-fastcgi /cgi-bin/php.fcgi

cPanel: Configuring PHP and suEXEC from the Command Line

With cPanel, you do not need to recompile the whole easyapache to get your PHP or suEXEC to be run, you may easily get the PHP work with the rebuild_phpconf script to update the php.conf file.

To see a list of all options and arguments for the script, you may type the following from the command line,
/usr/local/cpanel/bin/rebuild_phpconf –help

If you wish to use PHP 5, CGI handler and enable suEXEC, you might type as,
/usr/local/cpanel/bin/rebuild_phpconf 5 cgi cgi 1

If you wish to use PHP 5, suPHP and enable suEXEC, you might type as
/usr/local/cpanel/bin/rebuild_phpconf 5 suphp suphp 1

The available PHP handler is as cgi, dso, none, fcgi and suphp.

PHP Startup: Unable to Load Dynamic library ‘C:\PHP\ext\php_pdo_mysql.dll – The specified module could not be found

I was getting this error from one of the Windows Server with IIS, after looking for several source from the Internet, I found this solution.

The error is like detail below,

PHP Startup: Unable to Load Dynamic library ‘C:\PHP\ext\php_pdo_mysql.dll – The specified module could not be found.

Solution,
Copy the ext\libmysql.dll file from PHP installation folder to /Windows/System32 folder.

Configure FastCGI to Host PHP from IIS 5.x and 6.x

I want to tell everybody that I am back again after last post from Jan 2011. MGe is lost after the Celebrating the Chinese New Year(I am Chinese, 🙂 ), and it is very sad that 2 relative passed away during the past week. 🙁

Somehow, I will continue sharing my post from here, :-).

Today, I want to guide my reader on how to configure PHP FastCGI for IIS 5.x and 6.x.

Prerequisite,
i) IIS5.x or 6.x installed.
ii) PHP installed.

Step:
Install FastCGI extension,
1. Download the extension from http://www.iis.net/extensions/fastcgi.
2. Install it and you will see it is installed to C:\Windows\System32\inetsrv folder.

Apply FastCGI extension,
i) Configure through command,
Run the follow command,

cscript fcgiconfig.js -add -section:"PHP" -extension:php -path:"C:\PHP\php-cgi.exe"

ii) Manually Configure it.
1) Run inetmgr.
2) Right click Web Site and select properties.
3) Click on Home Directory tab.
4) Click on the Configure button.
5) Click on the Add button.
6) In the “Add/Edit Application Extension Mapping”, add the following information,
Executable: C:\Windows\System32\inetsrv\fcgiext.dll
Extension: .php
Verbs: Limit to GET, HEAD, POST
7) Click OK.

Modify the fcgiext.ini file,
1) Add the following information to the fcgiext.ini file,
[Types]
php=PHP
[PHP]
ExePath=C:\PHP\php-cgi.exe

Set the optimal setting for FastCGI,
Set the following value to php.ini,
fastcgi.impersonate = 1
cgi.fix_pathinfo = 1
cgi.force_redirect = 0

Set the following value to fcgiext.ini, run the following script.

cscript fcgiconfig.js -set -section:"PHP" -EnvironmentVars:PHP_FCGI_MAX_REQUESTS:10000

PHP Compilation Error

It is not my first time to install PHP to the Linux server, but I am always not remember the error and which packages should install to get away the error.

So I am sharing some error code with the packages needed as below.

Error: Configure: error: xml2-config not found. Please check your libxml2 installation.
Solution:

yum install libxml2-devel

Error: Checking for pkg-config… /usr/bin/pkg-config configure: error: Cannot find OpenSSL’s
Solution:

yum install openssl-devel

Error: Configure: error: Cannot find MySQL header files under /usr.
Note that the MySQL client library is not bundled anymore!
Solution:

yum install mysql-devel

Error: Checking for unixODBC support… configure: error: ODBC header file ‘/usr/include/sqlext.h’ not found!
Solution:

yum install unixODBC-devel

Error: Configure: error: Cannot find pspell
Solution:

yum install pspell-devel

cPanel Fantastico not able to install any apps

Today I found out that the cPanel do not working well with the Fantastico DeLuxe and I have no idea what it is going on at first as there do not have any error from the server.

Symptoms:
1. Fantastico showing installation configuration file and database with ERROR.
2. No web file in the public_html folder.
3. Database is not configured properly(no table and data).

After long time tested and checked. Finally I am able to get some hint from the cPanel error_log.
=================
PHP Warning:  shell_exec() has been disabled for security reasons in /tmp/cpanel_phpengine.1289814352.9866F8Ane8kVMm on line 979
=================

I have immediate go to php.ini file and check for the disable_function and found out shell_exec and system is being listed.

To overcome it, I have putting a semi-colon “;” to the line of disable_function and restart the Apache HTTPD services and it is working fine.