# PHP get errors when trying to install pear via ports



## mazaruz (May 11, 2010)

Hello, I'm newbie with FreeBSD and also I'm new here.
My English is not very well, my apologize 

My FreeBSD 8.0 is running PHP5-5.3.2 and I'd like to install centreon on my system.
Centreon requirements include pear. So, I use ports to install this package (pear).
but it's coming up with many errors (may be it's just warning, i don't know)
It said 
	
	



```
PHP Deprecated:  Function set_magic_quotes_runtime() is deprecated in /tmp/go-pear/PEAR/Registry.php
```
and so on! 
but the last line said "install ok" and when i try to grep pear package with pkg_info, it comes up.

Should I continue my installation? 

I've search for the rest of this forum but I couldn't find any clue. and I've tried google too, no lucks x(


----------



## DutchDaemon (May 11, 2010)

I don't know how you're installing Pear, but no port/package will ever touch /tmp/. For the record, devel/pear builds just fine when using `# /usr/ports/devel/pear && make install clean`.


----------



## mazaruz (May 12, 2010)

I used port to install pear and PHP just gave me that error. 
Just wonder if there is anything going to be wrong with PHP5.3 and PEAR or not. 

Thank you for your reply,
Maz


----------



## DutchDaemon (May 12, 2010)

According to the port, its only build dependencies are lang/php5 and textproc/php5-xml. I'm running PHP 5.3.2, and the pear port compiled with zero problems.


```
[/usr/ports/devel/pear] # make build
=> pear-1.9.0.tar.bz2 doesn't seem to exist in /usr/ports/distfiles/.
=> Attempting to fetch from http://freebsd.unixfreunde.de/sources/.
pear-1.9.0.tar.bz2                            100% of  303 kB  574 kBps
===>  Extracting for pear-1.9.0
=> MD5 Checksum OK for pear-1.9.0.tar.bz2.
=> SHA256 Checksum OK for pear-1.9.0.tar.bz2.
===>  Patching for pear-1.9.0
===>  Applying FreeBSD patches for pear-1.9.0
===>  Configuring for pear-1.9.0
```

The make process does not create anything in, or talk to anything under, /tmp/.


----------



## mazaruz (May 14, 2010)

DutchDaemon said:
			
		

> According to the port, its only build dependencies are lang/php5 and textproc/php5-xml. I'm running PHP 5.3.2, and the pear port compiled with zero problems.
> 
> 
> ```
> ...



If I only build it, it went no errors. But when I try to install it, errors come up.
I've tried to format and rebuild new freebsd server and have pear installed again.
the same errors came up. nothing has changed.

no lucks at all :\


----------



## AndyUKG (May 18, 2010)

I believe I had the exact same problem building a new system which I assumed to be a problem with PHP 5.3 which I have read is likely to give quite a lot of compatibility issues. I removed PHP5.3 and installed PHP5.2 (you can still install 5.2 via ports)

thanks Andy.


----------



## mazaruz (May 25, 2010)

AndyUKG said:
			
		

> I believe I had the exact same problem building a new system which I assumed to be a problem with PHP 5.3 which I have read is likely to give quite a lot of compatibility issues. I removed PHP5.3 and installed PHP5.2 (you can still install 5.2 via ports)
> 
> thanks Andy.



It means I've to deinstall PHP5.3 and install PHP5.2 instead, right?
I wonder If PHP5.2 can compile with new version of GD library. (php5-gd-5.3.2)

I'll have a shot, then.

Thanks,
Maz


----------



## AndyUKG (May 25, 2010)

mazaruz said:
			
		

> It means I've to deinstall PHP5.3 and install PHP5.2 instead, right?
> I wonder If PHP5.2 can compile with new version of GD library. (php5-gd-5.3.2)



Why do you need php5-gd-5.3? If you are going to install PHP 5.2 you should install all php5.2 extensions too. You should be looking at ports:

/usr/ports/lang/php52
/usr/ports/lang/php52-extensions

Andy.


----------



## mazaruz (May 26, 2010)

Thank you Andy.
I'll try it out. Hope gd won't  give me errors like last time.
I used to use PHP 5.2 once, but when I install gd extension
It gave me plenty if errors. Poor me


----------



## AndyUKG (May 26, 2010)

I have PHP gd installed on server systems without any probs so you should be ok. Is your ports tree up to date? I guess probably yes, but just to check. If not, update it via portsnap before doing your reinstall of PHP...
Any issues with PHP gd then post your problems and Im sure youÂ´ll find help on the forums...


----------



## cryolithic (Aug 11, 2010)

I'll toss my hat in the ring with PEAR issues right now.

```
Deprecated: Function set_magic_quotes_runtime() is deprecated in /usr/local/share/pear/PEAR/Registry.php on line 1179

Deprecated: Function set_magic_quotes_runtime() is deprecated in /usr/local/share/pear/PEAR/Registry.php on line 1183
Updating channel "pear.php.net"
Channel "pear.php.net" is up to date

Deprecated: Function set_magic_quotes_runtime() is deprecated in /usr/local/share/pear/PEAR/Registry.php on line 1179

Deprecated: Function set_magic_quotes_runtime() is deprecated in /usr/local/share/pear/PEAR/Registry.php on line 1183
Updating channel "pecl.php.net"
Channel "pecl.php.net" is up to date

Installing selected packages..................

Deprecated: Assigning the return value of new by reference is deprecated in /usr/local/share/pear/PEAR/Command/Install.php on line 331

Deprecated: Assigning the return value of new by reference is deprecated in /usr/local/share/pear/PEAR/Command/Install.php on line 343

Deprecated: Assigning the return value of new by reference is deprecated in /usr/local/share/pear/PEAR/Command/Install.php on line 1137

Deprecated: Function set_magic_quotes_runtime() is deprecated in /usr/local/share/pear/PEAR/Config.php on line 1026

Deprecated: Function set_magic_quotes_runtime() is deprecated in /usr/local/share/pear/PEAR/Config.php on line 1033
Package: PEAR-stable.............................. already installed ... ok
Package: Structures_Graph-stable.................. already installed ... ok
Package: Archive_Tar-stable....................... already installed ... ok
Package: Console_Getopt-stable.................... already installed ... ok
*** Signal 11

Stop in /usr/ports/devel/pear.
```

Another thread previously mentioned trying to downgrade libxml2, however that was unsuccessful.


----------



## EasyTarget (Jan 4, 2011)

*/tmp is used on my system..*

*NOTE*: This is not a solution for the problem listed here.. more a comment on some of the stuff at the beginning of the thread where people are saying that compiling pear does not use the /tmp folder.

.. for the record.. building pear -will- use /tmp, on my system:

```
calvin# portupgrade devel/pear
--->  Upgrading 'pear-1.9.1' to 'pear-1.9.1_1' (devel/pear)
--->  Building '/usr/ports/devel/pear'
===>  Cleaning for pear-1.9.1_1
===>  Vulnerability check disabled, database not found
===>  License check disabled, port has not defined LICENSE
===>  Extracting for pear-1.9.1_1
=> SHA256 Checksum OK for pear-1.9.1.tar.bz2.
===>  Patching for pear-1.9.1_1
===>  Applying FreeBSD patches for pear-1.9.1_1
===>  Configuring for pear-1.9.1_1
--->  Backing up the old version
--->  Uninstalling the old version
--->  Deinstalling 'pear-1.9.1'
[Updating the pkgdb <format:bdb_btree> in /var/db/pkg ... - 504 packages found (-1 +0) (...) done]
--->  Installing the new version via the port
===>  Installing for pear-1.9.1_1
===>   pear-1.9.1_1 depends on file: /usr/local/include/php/main/php.h - found
===>   pear-1.9.1_1 depends on file: /usr/local/lib/php/20090626/xml.so - found
===>   Generating temporary packing list
===>  Checking if devel/pear already installed


******************************************************************************
FATAL ERROR! We cannot initialize the temp directory. Please be sure to give
full write access to this directory and the install directory.

'/go-pear' was given.sed: /usr/local/share/pear/peclcmd.php: No such file or directory
*** Error code 1

Stop in /usr/ports/devel/pear.
*** Error code 1

Stop in /usr/ports/devel/pear.
** Command failed [exit code 1]: /usr/bin/script -qa /tmp/portupgrade20110104-91365-aoizqp-0 env 
UPGRADE_TOOL=portupgrade UPGRADE_PORT=pear-1.9.1 UPGRADE_PORT_VER=1.9.1 make reinstall
--->  Restoring the old version
** Fix the installation problem and try again.
[Updating the pkgdb <format:bdb_btree> in /var/db/pkg ... - 505 packages found (-0 +1) . done]
** Listing the failed packages (-:ignored / *:skipped / !:failed)
	! devel/pear (pear-1.9.1)	(install error)
```

Note the line 
	
	



```
** Command failed [exit code 1]: /usr/bin/script -qa /tmp/portupgrade20110104-91365-aoizqp-0 .......
```

If you have 
	
	



```
open_basedir = /usr/local/www
```
 or similar in /usr/local/etc/php.ini you will see the above error..

To get pear to compile I have to temporarily comment out this setting (therefore briefly decreasing the security of my system) while the portupgrade runs. 

This is happening because the compilation of pear actually runs PHP to do some of the work (and defaults to the main temp directory for this). 
- The _open_basedir_ setting is a security setting that prevents PHP moving outside of the defined filesystem tree. 
- Yes.. my PHP apps also use a tempdir; but this is located within the tree defined by openbasedir, so I do not see errors on my sites.


----------



## DutchDaemon (Jan 4, 2011)

Try not to confuse *portupgrade* and *make*.


----------



## EasyTarget (Jan 6, 2011)

*Hummmmmm*



			
				DutchDaemon said:
			
		

> Try not to confuse *portupgrade* and *make*.



Now that got me thinking; is this really a problem with portupgrade? _I had just assumed *portupgrade* was simply the mechanism used to invoked *make*._ 
Fortunately it's easy to repeat without portupgrade being involved anywhere.

The line I highlighted is a 'red herring' the error looks deeper than this (probably not actually related to /tmp ?), but the dependence on not having open_basedir set is real:


```
calvin# grep open_basedir /usr/local/etc/php.ini
; open_basedir, if set, limits all file operations to the defined directory
open_basedir = /usr/local/www

calvin# cd /usr/ports/devel/pear

calvin# make deinstall
===>  Deinstalling for devel/pear
===>   Deinstalling pear-1.9.1_1

calvin# make install
===>  Installing for pear-1.9.1_1
===>   pear-1.9.1_1 depends on file: /usr/local/include/php/main/php.h - found
===>   pear-1.9.1_1 depends on file: /usr/local/lib/php/20090626/xml.so - found
===>   Generating temporary packing list
===>  Checking if devel/pear already installed


******************************************************************************
FATAL ERROR! We cannot initialize the temp directory. Please be sure to give
full write access to this directory and the install directory.

'/go-pear' was given.sed: /usr/local/share/pear/peclcmd.php: No such file or directory
*** Error code 1

Stop in /usr/ports/devel/pear.

calvin# vi /usr/local/etc/php.ini
calvin# grep open_basedir /usr/local/etc/php.ini
; open_basedir, if set, limits all file operations to the defined directory
;open_basedir = /usr/local/www

calvin# make install
===>  Installing for pear-1.9.1_1
===>   pear-1.9.1_1 depends on file: /usr/local/include/php/main/php.h - found
===>   pear-1.9.1_1 depends on file: /usr/local/lib/php/20090626/xml.so - found
===>   Generating temporary packing list
===>  Checking if devel/pear already installed

Bootstrapping Installer...................
Bootstrapping PEAR.php............(local) ok
Bootstrapping Archive/Tar.php............(local) ok
Bootstrapping Console/Getopt.php............(local) ok

Extracting installer..................
Using local package: PEAR.............ok
Using local package: Structures_Graph....ok

Preparing installer..................
Updating channel "doc.php.net"
Update of Channel "doc.php.net" succeeded
Updating channel "pear.php.net"
Channel "pear.php.net" is up to date
Updating channel "pecl.php.net"
Update of Channel "pecl.php.net" succeeded

Installing selected packages..................
Installing bootstrap package: PEAR...................warning: pear/PEAR requires 
package "pear/Archive_Tar" (recommended version 1.3.7)
warning: pear/PEAR requires package "pear/Structures_Graph" (recommended version 1.0.3)
warning: pear/PEAR requires package "pear/Console_Getopt" (recommended version 1.2.3)
warning: pear/PEAR requires package "pear/XML_Util" (recommended version 1.2.1)
install ok: channel://pear.php.net/PEAR-1.9.1
PEAR: Optional feature webinstaller available (PEAR's web-based installer)
PEAR: Optional feature gtkinstaller available (PEAR's PHP-GTK-based installer)
PEAR: Optional feature gtk2installer available (PEAR's PHP-GTK2-based installer)
PEAR: To install optional features use "pear install pear/PEAR#featurename"
Installing bootstrap package: Structures_Graph.......install ok: channel://pear.php.net/Structures_Graph-1.0.3
Installing local package: Archive_Tar-stable.........install ok: channel://pear.php.net/Archive_Tar-1.3.7
Installing local package: Console_Getopt-stable.......install ok: channel://pear.php.net/Console_Getopt-1.2.3
===>   Registering installation for pear-1.9.1_1

calvin# vi /usr/local/etc/php.ini
< restore my open_basedir setting.. >
```

However.. this is the wrong place to be discussing this.. I'll put in a PR against the port itself.


----------



## kudu (Jan 6, 2011)

EasyTarget, u're correct, it's a bug with port, didnt check if there's a PR already tho :<

this is for already patched /usr/ports/devel/pear/work/pear-1.9.1/

```
--- go-pear     2011-01-06 15:44:37.232409846 +0200
+++ go-pear.new 2011-01-06 15:45:35.009223707 +0200
@@ -1429,7 +1429,7 @@
         $doc_dir   = '$prefix/share/doc/pear';
         $data_dir  = '$php_dir/data';
         $test_dir  = '$php_dir/tests';
-       $temp_dir   = '/go-pear';
+       $temp_dir   = '/tmp/go-pear';
 /*
         // check if the user has installed PHP with PHP or GNU layout
         if (@is_dir("$prefix/lib/php/.registry")) {
```

solved my problems :>


----------



## EasyTarget (Jan 6, 2011)

*PR submitted.*

PR-153723 

I dont think your patch would work for me.. I do not want to allow PHP to access /tmp at all (security.. just in case), I have a separate /usr/local/www/php_tmp for file uploads etc..

My suggestion was to simply override the open_basedir setting in the Makefile when invoking php:


```
*** Makefile    Thu Jan  6 13:16:02 2011
--- Makefile.orig       Thu Dec 30 05:15:49 2010
***************
*** 30,36 ****
                ${WRKSRC}/go-pear
  
  do-install:
!       @cd ${WRKSRC} && ${LOCALBASE}/bin/php -d open_basedir="" -q ./go-pear
        @${SED} -i "" "s|<?php|<?php dl('pcre.so'); dl('xml.so');|" \
                ${PEARDIR}/peclcmd.php
  
--- 30,36 ----
                ${WRKSRC}/go-pear
  
  do-install:
!       @cd ${WRKSRC} && ${LOCALBASE}/bin/php -q ./go-pear
        @${SED} -i "" "s|<?php|<?php dl('pcre.so'); dl('xml.so');|" \
                ${PEARDIR}/peclcmd.php
```

I have tested this, it worked, and is what is what I put in the PR..


----------

