Working on PEAR
The project was using PEAR to handle numerous functionalities and I don’t want to rewrite codes and just install PEAR. To check, I fired up phpinfo() and found out that PEAR was disabled. Poderosa was to the rescue. I login and installed PEAR via its command line installer. The good thing with Linux is that you can do things with just a few commands (however, you must be familiar with the command).
lynx -source http://pear.php.net/go-pear | php
For RedHat, replace
That will download the file
go-pear and execute it via PHP CLI. After the installations, I put a symbolic link to the new pear executable.
ln -s /usr/local/my_pear_dir/bin/pear /usr/bin/pear
So that I can execute pear without the need to type the full path. After all those console commands, I restarted Apache and tested again.
TADA! It still don’t work. Knowing that it is because of the open_basedir restriction, I copied the whole pear installation to the directory accessible by our virtual host.
Then changed the include path for PHP to set it to new location instead of the old one since that project is the only one relying on PEAR. Saved and restarted, still don’t work. Now, I’ve finally dived into the code. I created a file that includes a file from the PEAR library, set error reporting:
init_set("display_errors", "On"); error_reporting(E_ALL ^ E_NOTICE);
TADA! It shows with no errors! Weird!
I have found out that when the owner of the script is root, it can include the PEAR package I need (since the owner of the whole PEAR tree is root).
So, I changed the ownership of the real script.
chown root the_file.php
Tested it! It triggers SAFE_MODE and says that it cannot include a file when the owner of the script is root for security reasons. Therefore I conclude that if I change the owner of the PEAR tree, it will solve all those problems.
chown -R the_ordinary_ftp_user /path/to/pear/inside/virtual/host/dir
That solves it.