Archive

Archive for the ‘PHP Configuration’ Category

How to Prepend a PHP File For a Single Domain

November 26th, 2010 No comments

Sometimes you need to prepend a PHP file, before execution of any file. This can be: website header, or variable declaration, or anything else. In order to do it, we need access to out Virtualhost (which is usually located ad your httpd.conf). If you are using Directadmin, you may find it at /usr/local/directadmin/data/users/. Of course, you need to have root access to modify these values.

Here is our source virtualhost secrion:

ServerName www.lampdocs.com
ServerAlias www.lampdocs.com lampdocs.com
ServerAdmin webmaster@lampdocs.com
DocumentRoot /home/lampdocs/domains/lampdocs.com/public_html
ScriptAlias /cgi-bin/ /home/lampdocs/domains/lampdocs.com/public_html/cgi-bin/
UseCanonicalName OFF
SuexecUserGroup lampdocs lampdocs
CustomLog /var/log/httpd/domains/lampdocs.com.bytes bytes
CustomLog /var/log/httpd/domains/lampdocs.com.log combined
ErrorLog /var/log/httpd/domains/lampdocs.com.error.log


Options +Includes -Indexes
php_admin_flag engine ON

php_admin_flag safe_mode OFF

php_admin_value sendmail_path ‘/usr/sbin/sendmail -t -i -f lampdocs@lampdocs.com’

We will add a string:

php_admin_value auto_prepend_file /var/www/html/docroot.php.

Here is the result:


ServerName www.lampdocs.com
ServerAlias www.lampdocs.com lampdocs.com
ServerAdmin webmaster@lampdocs.com
DocumentRoot /home/lampdocs/domains/lampdocs.com/public_html
ScriptAlias /cgi-bin/ /home/lampdocs/domains/lampdocs.com/public_html/cgi-bin/
php_admin_value auto_prepend_file /var/www/html/docroot.php
UseCanonicalName OFF
SuexecUserGroup lampdocs lampdocs
CustomLog /var/log/httpd/domains/lampdocs.com.bytes bytes
CustomLog /var/log/httpd/domains/lampdocs.com.log combined
ErrorLog /var/log/httpd/domains/lampdocs.com.error.log


Options +Includes -Indexes
php_admin_flag engine ON

php_admin_flag safe_mode OFF

php_admin_value sendmail_path ‘/usr/sbin/sendmail -t -i -f lampdocs@lampdocs.com’

Now reboot Apache and have fun. You can place anything you need in this file. This method does not involve php.ini and allows to prepend a PHP file for a single domain.

Categories: PHP Configuration, PHP Solutions Tags:

/usr/bin/ld: cannot find -lltdl on PHP Make: How to Fix

April 21st, 2010 No comments

You can meet this error while trying to make PHP on a fresh server. For example, you have this configure line:

./configure '--with-apxs2=/usr/local/apache2/bin/apxs' '--enable-calendar' '--enable-mbstring' '--disable-cgi' '--disable-magic-quotes' '--with-curl' '--with-curlwrappers' '--with-zlib' '--with-bz2' '--enable-ftp' '--with-gd' '--with-mcrypt' '--with-mhash' '--with-mysql=/usr/lib/mysql' '--enable-soap' '--with-xmlrpc' '--enable-zip' '--with-pear'

and the error you receive is:

/usr/bin/ld: cannot find -lltdl
collect2: ld returned 1 exit status
make: *** [libphp5.la] Error 1

Most probably you don’t have libtool-ltdl-devel installed. All you need is to install it using yum (or any other applicable package manager). yum install libtool-ltdl-devel. Then run ./configure, make and make install. This should do the job.

Categories: PHP Configuration Tags:

How to Add Imagemagick Support to PHP

February 2nd, 2010 No comments

In order to process images with php using image processing functions, you need to have Imagemagick support installed. Since I haven’t found any clear reference, how to do it fast, let me post my solution, it should help you to to your PHP installation.

First of all, we need to ensure we’ve got Imagemagick on our server. Please, read my previous post, where the procedure of Imagemagick setup is explained, if you don’t have it installed. You need to install Imagemagick first in order to add its functions in PHP, I hope it’s clear.

After the main library is installed, we will need another source archive, that will allow us to add Imagemagick functions to PHP. This package is called Imagick, and you’re welcome to select one package you like. I’ve taken 3.0.0b2 beta, the most recent for today.

Let’s download it to our server:

wget http://pecl.php.net/get/imagick-3.0.0b2.tgz

Extract to a folder:

tar -xzvf imagick-3.0.0b2.tgz

cd into this folder

cd imagick-3.0.0b2;

Then we need to run phpize

phpize

Then our usual list of commands:
./configure –with-imagick=/usr/local
make
make install

After you’ve built imagick, you should see something like this:

how to install imagick

Now you need to copy the created library named imagick.so to your extensions directory. However you can skip this step, if you like to deal with ling paths in your php.ini.

And the final stage is to add imagick module to php.ini. If you have copied the library to your extensions directory, you should add the following line to php.ini:

extension=imagick.so

If you have decided to keep the library at the place where it was installed, the string will look like

extension=/usr/local/lib/php/extensions/no-debug-non-zts-20060613/imagick.so

Now restart Apache and check your phpinfo(). If everything is OK, you should see:

imagick ready

You should now be able to use Imagemagick functions. Feel free to ask me any questions you have.

How to Enable Ioncube Support For The Entire Server

January 29th, 2010 No comments

PHP code protection is widely used today. As most servers come with Zend installed, I will tell you how to install another code protection library named Ioncube. If you’re a server administrator, I would suggest you to install this library on server level, as it might be used by many users of your server.

First of all, we need to download the Ioncube package. Just choose your operating system and download an archive to your place. Then you need to extract it.

tar -xzvf ioncube_loaders_lin_x86.tar.gz

I would suggest you to copy extracted files to a safe location so you could point to it when adding support lines to php.ini.

It will be much easier if ioncube loader helper page is accessible from the web, just like here: http://www.lampdocs.com/blog/ioncube/ioncube-loader-helper.php?page=install-assistant . Helper will detect the place where your php.ini is located and will suggest the correct path. If you don’t have web access to helper page, you’re welcome to follow my post finding php.ini file location.

To install the Loader in your php.ini file, edit or create php.ini file by the path specified by loader and add the following line before any other zend_extension lines:

zend_extension = /
/ioncube_loader_lin_5.2.so

where /
/ is where you’ve installed the loader, e.g. /usr/local/ioncube/. Make sure this line is added before any other zend_extension lines, as you might have troubles starting Apache. Here is how it looks on my server:

[Zend]
zend_extension=/usr/local/ioncube/ioncube_loader_lin_5.2.so
zend_extension_manager.optimizer=/usr/local/Zend/lib/Optimizer-3.3.3
zend_extension_manager.optimizer_ts=/usr/local/Zend/lib/Optimizer_TS-3.3.3
zend_optimizer.version=3.3.3

zend_extension=/usr/local/Zend/lib/ZendExtensionManager.so
zend_extension_ts=/usr/local/Zend/lib/ZendExtensionManager_TS.so

After that you must restart apache to activate your changes. You should not experience problems starting it, and your ioncube installation should be ready to use. If not, you’re welcome to ask me here. :)