I am running Fedora Core 10 with php 5.2.9 without ldap. Now i want to remove current php installation and recompile the latest version of php with ldap and install it.
How to do this?
Basically, download the sources from the PHP website. Then, from a terminal, type './configure --prefix=/usr/local/my_php_version'
In the output, checks if it recognize your LDAP installation (and also the Apache one). If not, take a look at the configuration options to learn how to specify the paths. Something like '--with-openldap', '--with apxs', etc.
You should also take a look at the configuration options to active the features you need.
Once you're done, type 'make', then 'sudo make install'.
Also take a look at the official install documentation: http://www.php.net/manual/en/install.unix.php
Instead of re-compiling the PHP, you can add the LDAP support to the PHP you have installed.
You can install a variety of libraries and modules without recompiling PHP. To see the libraries that are available, you can execute
yum search php-
To install LDAP for your PHP, you can execute
yum install php-ldap
If you have PHP as an Apache module, you must restart the httpd to activate the changes
service httpd restart
Related
Documenting my struggles to help others and hopefully get some feedback on how I could have done it better.
The command pecl install pthreads fails due to the php installed on my ubuntu 13.04 box not having zts configured.
Options:
1) The ubuntu respository does not have a php package with zts enabled. As of this post, ubuntu only has php 5.4.9 in it's repository (Released: 22 Nov 2012). It is possible to compile a php version from source - which I eventually did (see below), but..
2) I .. ALSO .. wanted to use phpfarm for the ability to run different versions of PHP on my local setup. On github, there is Christian Weiske's original contribution here (phpfarm) and a fork that he has contributed to, by François Poirotte - also called phpfarm. Francois' fork has a few more options to configure ('post-install customization') but I was not able to make that work with a PECL extension. I'm curious to know if misunderstood how to do that, because it looks to me that it just simply does not take PECL commands.
3). Prior to recompiling php from source, I loaded phpfarm (tried both versions), enabled php-fpm (FastCGI) and was able to get my apache2 server to use a phpfarm version (5.5.10) which showed up in a phpinfo() output. But the php-cli always showed the original php version (5.4.9) in the cli (run: php -v). Running (run: php -i | grep php.ini) showed /etc/php5/cli but I had previously removed php5 and aptitude show php5 returned a state of 'not installed.' I even renamed the /etc/php5 directory to see if I could force the system to use the phpfarm php version. Obviously, this is incorrect thinking and I went on to simply compile php 5.6 from source. But, is there something more to do to get a phpfarm php to be used in the cli? I read that the cli loads it's configuration file on a per command basis, unlike the apache2. If I could have run the 5.5.10 version (configured with zts) then I could have then done pecl install pthreads and then re-complied the phpfarm 5.5.10 version with pthreads enabled. Although it appears I will be able to run various versions of php in the apache server, will I ever be able to switch-phpfarm to another version and see it working in the php-cli? Also, I was uncertain on where I could have loaded a pthreads file for the phpfarm compile process to find and use it; could I have done it that way?
4) This stackoverflow post, essentially posted by Joe Watkins - the developer of pThreads is a perfect how-to on getting pThreads installed on a Ubuntu system that has had php configured with zts (Zend Thread Safety). (Thanks Joe!)
A nice tutorial on using phpfarm configured with fast-cgi and the apache server to help run websites under different php configurations.
So what gives with php, php-cli and the phpfarm?
I'm not sure about phpfarm, but do know of another solution ...
Multi
A tool for maintaining multiple installations of PHP in multiple configurations
https://github.com/datingvip/multi
This is a bit more user orientated, will allow you to build many configurations and versions of php, any tagged release of php, and any patched version from any fork of php-src.
In addition, because I wrote it, it will install pthreads for you.
git clone https://github.com/datingvip/multi
cd multi
VERSION=5.5.10 DBG=no-debug ZTS=zts ./php.multi
The above commands will yield an installation of PHP (in one suitable configuration, of one version) in /opt/php.
Look at php.defaults for configuration options and adjust before building
Should configuration fail on, for example, something related to a library like libxml2, it will usually be the case that
sudo apt-get install library-dev
Where library is replaced with the name of the library holding up the build, will fix the problem for you. If it does not, a quick google should get you going again.
Once the build is complete
source /path/to/multi/php.env 5.5.10
Note: multi will always install pthreads for any zts version automatically
I hope that gets you somewhere ...
I'm using a Mac with OS X Mavericks, and running php scripts within MAMP. Some of the php scripts I'm running require the use of pthreads.
Can anyone provide step-by-step instructions on installing or enabling pthreads on a Mac?
I have Googled extensively and have found little-to-no documentation on this. All I have found is that I may or may not have to recompile php from source, or maybe just add a couple flags to php.ini, or maybe I can just use pecl, etc. In terminal, I tried pecl install pthreads and received this error:
Cannot install, php_dir for channel "pecl.php.net" is not writeable by the current user
I'm pretty much lost at this point. I want to avoid switching to my Windows machine with WAMP if possible.
I'm not a Mac user, however the build process is the same for Mac and unix, so I can help you with that.
To configure your current installation:
Cannot install, php_dir for channel "pecl.php.net" is not writeable by the current user
This is the reason pecl install failure, maybe check the configuration for php_dir.
You can ascertain the value of the setting with:
pecl config-get php_dir
I am unfamiliar with MAMP, but it is probably the case that you do not have a Thread Safe build of PHP.
You can ascertain this with:
php -i | grep Thread
You should expect:
Thread Safety => enabled
If you have Thread Safety enabled, it should be the case that fixing the permissions on php_dir will fix your problem.
If you do not, you will have to rebuild, or install from another source, a Thread Safe build of PHP.
Building Yourself
The last option is to build yourself, since this means you will miss out on updates provided by upstream, though I'm not familiar enough to know for sure if there is a well maintained thread safe build, I will assume that there is.
To build yourself you will need to overwrite your current installation with a new one, download the sources to PHP for your desired version (5.5+ recommended, latest stable, all the time is best).
Enabled Extensions
You will want to ascertain which extensions are enabled for your current build and decide which you want to enable in your new build.
To ascertain which extensions are enabled:
php -m
Make a note of these:
php -m > enabled-extensions
Configuring the Build
To configure the build to be Thread Safe use the following configure option:
--enable-maintainer-zts
You will want to set the prefix of the new installation to match the old with:
--prefix=/old/prefix
If your current php binary is at /usr/local/bin/php, then the prefix is /usr/local.
If your current php binary is at /usr/bin/php, then the prefix is /usr.
You will also want to match your current builds configuration directory and scan directory settings:
--with-config-file-path=/old/config/path
If your current php.ini is at /usr/lib/php.ini, then the path is /usr/lib
If your current php.ini is at /etc/php.ini, then the path is /etc
If you are using scan directories at startup, for example, you have the directory /etc/php.d
--with-config-file-scan-dir=/etc/php.d
If your current scan directory is /etc/php.d, then the dir is /etc/php.d
To configure extensions, referencing the list you made at the beginning, use the command:
./configure --help
To figure out the switches enable your chosen extensions. If there are extensions in the list that are in pecl, you can install those after the build is complete with the pecl command.
Generally:
--enable-extname: no dependencies on external libraries
--with-extname: dependent on external libraries
Making the Build
After configure we have to run make, if you have multiple processors or cores, you might want to use multiple jobs:
make -j8
Will allow make to run in parallel (maximum of 8 jobs), this speeds up builds considerably. Use as many jobs as you have cores.
During make, if a failure occurs it will be obvious what the failure relates to, if you can spot the name of a library (usually the name of the extension that causes failure is helpful), then you can usually resolve the error by installing the development package for the library that caused the failure.
A development package contains headers and or static libraries, it is usually the case that package maintainers omit this stuff from normal packages to save weight, so you can have the libxml2 package installed but not have headers.
Installing the Build
When make completes you will have your build ready for installation, make sure you have permissions for the prefix and execute
make install
Pecl Extensions
You should now be able to install the PECL extensions that you require with
pecl install extname
pthreads
You can now install with PECL or from github:
pecl install pthreads
The only help i can find is about XAMPP installations, but i'm running a fresh root server with Plesk and.. classical LAMP and PHP 5.3.8 - everyone is telling me that Normalizer class must be available in PHP 5.3+, but it's obviously not available in my server..
what is missing, what i have to do that the class is there and running?
Unless PHP was compiled with the --enable-intl flag, the Normalizer will not be available. Check using phpinfo(). If it's not enabled, you can either recompile PHP, adding that flag, or try the PECL installation.
See http://php.net/manual/en/intl.installation.php
If the PHP installation was provided by the OS, perhaps you can use its package manager to add the intl extension as well. With root privileges, just run something like this:
$ apt-get install php5-intl
I am trying to install pthreads for PHP, which is here.
In PHP manual of extention it says:
To enable pthreads support, configure PHP with --enable-maintainer-zts
and --enable-pthreads.
I have a CentOS server which has PHP installed but I cant figure out how to reconfigure it with these settings on, I checked my phpinfo() can see current ./configure options.
I will happy if someone can show me how to reconfigure my php. Do I need to uninstall current PHP first then install another or is there any way to run this ./configure command easily. I have SSH access to my server.
You could try install using PECL:
http://pecl.php.net/package/pthreads.
How to install PECL extensions:
http://php.net/manual/en/install.pecl.php
pecl install pthreads
I've written a tutorial about exactly this - Compile PHP with pthreads and ZTS enabled.
You must compile PHP as there are no prebuilt packages.
To reconfigure everything you'd use ./configure mainly.
if centos does not provide a thread safe version, you must compile php by own.
You have to build pthreads for your centos op system. After that you can use it as extension...
Use the following tutorials
http://blog.slowbro.org/2013/08/compiling-php-55-with-pthreads-on-centos/
http://eddmann.com/posts/compiling-php-5-5-with-zts-and-pthreads-support/
Or simply read the manual...
http://www.php.net/manual/en/pthreads.installation.php
That's much the question. I have PHP 5.2.9 on Apache and I cannot upgrade PHP. Is there a way for me to enable SOAP in PHP 5.2.9? The PHP manual did not help at all when it said, "To enable SOAP support, configure PHP with --enable-soap ." How do I configure?
Getting SOAP working usually does not require compiling PHP from source. I would recommend trying that only as a last option.
For good measure, check to see what your phpinfo says, if anything, about SOAP extensions:
$ php -i | grep -i soap
to ensure that it is the PHP extension that is missing.
Assuming you do not see anything about SOAP in the phpinfo, see what PHP SOAP packages might be available to you.
In Ubuntu/Debian you can search with:
$ apt-cache search php | grep -i soap
or in RHEL/Fedora you can search with:
$ yum search php | grep -i soap
There are usually two PHP SOAP packages available to you, usually php-soap and php-nusoap. php-soap is typically what you get with configuring PHP with --enable-soap.
In Ubuntu/Debian you can install with:
$ sudo apt-get install php-soap
Or in RHEL/Fedora you can install with:
$ sudo yum install php-soap
After the installation, you might need to place an ini file and restart Apache.
In case that you have Ubuntu in your machine, the following steps will help you:
Check first in your php testing file if you have soap (client / server)or not by using phpinfo(); and check results in the browser.
In case that you have it, it will seems like the following image ( If not go to step 2 ):
Open your terminal and paste: sudo apt-get install php-soap.
Restart your apache2 server in terminal : service apache2 restart.
To check use your php test file again to be seems like mine in step 1.
As far as your question goes: no, if activating from .ini is not enough and you can't upgrade PHP, there's not much you can do. Some modules, but not all, can be added without recompilation (zypper install php5-soap, yum install php-soap). If it is not enough, try installing some PEAR class for interpreted SOAP support (NuSOAP, etc.).
In general, the double-dash --switches are designed to be used when recompiling PHP from scratch.
You would download the PHP source package (as a compressed .tgz tarball, say), expand it somewhere and then, e.g. under Linux, run the configure script
./configure --prefix ...
The configure command used by your PHP may be shown with phpinfo(). Repeating it identical should give you an exact copy of the PHP you now have installed. Adding --enable-soap will then enable SOAP in addition to everything else.
That said, if you aren't familiar with PHP recompilation, don't do it. It also requires several ancillary libraries that you might, or might not, have available - freetype, gd, libjpeg, XML, expat, and so on and so forth (it's not enough they are installed; they must be a developer version, i.e. with headers and so on; in most distributions, having libjpeg installed might not be enough, and you might need libjpeg-dev also).
I have to keep a separate virtual machine with everything installed for my recompilation purposes.