Here is a quick overview:
I just finished compiling PHP 5.3.5 and made the attempt to compile "--with" a number of different extensions. Among the extensions that I need are mbstring and intl. I can manually phpize, configure, make, make install the mbstring extension and it seems to work fine. However, I am unable to do the same for intl.
My ./configure line looks like this:
./configure --with-openssl --with-pcre-regex --enable-calendar
--with-curl --enable-exif --enable-ftp --with-gd
--with-mhash --enable-mbstring --with-mysql --enable-zip
--enable-intl --with-icu-dir=...
The code compiles without problem: ./configure... make, make install
I used the php.ini-production for my php.ini configuration and I configured Apache to use php-cgi for a specific domain, and that works fine as well.
A quick:
<?php phpinfo() ?>
reveals that I am in fact running the newer version of PHP. However, the extensions specified in the "./configure..." line do not show up anywhere on the PHP info page.
After a bit of scouting I found that I could run phpize on a single extension in the PHP source folder, then compile a build of the specific module and install it in my PHP extension directory. After adding:
extension=MY_EXT
in my php.ini, the extension showed up on my phpinfo() page.
So can anyone explain why --with-mbstring doesn't seem to have an effect on my compilation?
I had no compilation problems for the intl extension, but moving the intl.so file to my PHP extensions directory and adding an extension line in my php.ini has no effect.
From php.net, have you tried
If your ICU is installed to a
non-standard directory then you might
want to specify its location in
LD_LIBRARY_PATH environment variable
so that dynamic linker can find it: $
export LD_LIBRARY_PATH=/opt/icu/lib
Otherwise, if PHP and ICU are
installed to their default locations,
then the additional options to
`configure' are not needed.
Related
I'm using CentOS 7 and building a PHP 7.4.10 rpm from source. We've previously been using PHP 7.2 with gmp located at /usr/lib64/, so ./configure in the spec file takes --with-gmp=/usr/lib64. This works with no problem, and I've also tested that it still works with PHP 7.3.22. Building PHP 7.4.10 however hits this error: configure: error: Unable to locate gmp.h.
$ locate gmp.h
/usr/include/gmp.h
$ locate gmp.so
/usr/lib64/libgmp.so
/usr/lib64/libgmp.so.10
/usr/lib64/libgmp.so.10.2.0
%build
cd %{_builddir}/php-%{version}
export CC=/usr/local/gcc/bin/gcc
export CXX=/usr/local/gcc/bin/g++
export CFLAGS="-O3 -m64 -isystem/usr/local/gcc/include -L/usr/local/gcc/lib64 -Wl,--rpath=/usr/local/gcc/lib64 "
export CXXFLAGS=$CFLAGS
./configure --with-gmp=/usr/lib64 --enable-bcmath --enable-ftp --with-curl --with-openssl --enable-mbstring
make -j8
$ rpm -qa | grep -i gmp
gmp-devel-6.0.0-15.el7.x86_64
gmp-6.0.0-15.el7.x86_64
I've tried putting a symlink between /usr/include/gmp.h and /usr/lib64/gmp.h, which didn't work.
I've also tried adding -isystem/usr/include and -isystem/usr/include/gmp.hto CFLAGS, CPFLAGS, and CXXFLAGS.
I'm especially baffled since something seems to have changed for PHP 7.4, but I can't find any upgrade notes for it.
--with-gmp=/usr/lib64 searches for the files in /usr/lib64/include and /usr/lib64/lib64. You need to use --with-gmp=/usr or --with-gmp=shared.
It's usually quite helpful to consult distribution build scripts when encountering such issues, such as the PHP 7.4 RPM SPEC file for CentOS. Further below, you will see references to %{_prefix}, which stands for /usr.
I just compiled PHP 7.3.0 alpha1 from the source, OS X, and then I installed Apache 2.2.4, but my PHP files aren't executed - instead I just see the code written in the file.
Like this:
I looked in httpd.conf, and I wasn't loading libphp7.so, but the module was nowhere to be found in the PHP source folder, I tried using libphp7.so from another PHP installation but phpinfo(); would just show an old PHP version.
How do I get the libphp7.so after compiling PHP from source?
You can get the libphp7.so file when source compiling using apxs2.
You'll need to make sure you have the devel packages for aspx, mysql-devel package for mysql_config, and httpd-devel. For CentOS/RHEL you can just run the following
yum install httpd-devel
yum install libxml2-devel
yum install mysql-devel
For the configure I ran it with mysqlnd but if you want to run it with something else, you can change the with-mysqli/with-pdo-mysql. I also enabled cli but for the .so you'll need aspx2.
./configure --with-mysqli=mysqlnd --with-pdo-mysql=mysqlnd --enable-cli --with-apxs2
You can also set a prefix when compiling and it should be installed under [PREFIX PATH]/libs/libphp7.so.
I am having a problem using xdebug w/PHP.
When I start Apache, xdebug does not load. In the log file it says:
"Cannot load Xdebug - it was built with configuration
API220131226,NTS,debug, whereas running engine is API220131226,NTS"
What does that mean? Which of the two, PHP or xdebug, is built incorrectly?
I am using:
Linux RHEL 7 on EC2
PHP 5.6 (Built from Source)
XDebug 2.3.3
PHP build options:
./configure --with-apxs2=/usr/bin/apxs --with-mysqli --with-libdir=/lib64 --enable-mbstring --with-gettext --with-libxml-dir=/usr/local/bin --enable-debug
XDebug build options:
./configure --with-libdir=/lib64
Other people on SO have mentioned that maybe the wrong phpize was being used.
I only have one copy of 'phpize' located in /user/local/bin
php-config --version returns 5.6.12
Solved!
When building PHP, make sure to use options --enable-debug --enable-phpdbg.
I had added options to the ./configure step.
The solution was to use "make distclean".
When I try to run a PHP scripts I get the following errors:
Warning: PHP Startup: Unable to load dynamic library '/home/user/php-5.4.28/installdir/include/php/ext/php_bz2.so' - /home/user/php-5.4.28/installdir/include/php/ext/php_bz2.so: cannot open shared object file: No such file or directory in Unknown on line 0
php.ini:
extension_dir = "/home/user/php-5.4.28/installdir/include/php/ext"
Content at extension_dir path:
~/php-5.4.28/installdir/include/php/ext$ ls
date ereg gd iconv libxml mysqli pcre session sqlite3 xml
dom filter hash json mbstring mysqlnd pdo spl standard
Where do I locate the extension?
I have installed PHP from source.
All the errors and phpinfo() can be seen here on JSBin
You don't have to locate the extension. You have to recompile PHP passing the option --with-bz2 to the ./configure script. Bzip2 support is not enabled by default as official documentation says.
./configure --with-bz2
Keep in mind that in order to compile PHP with this extension you need development headers and/or libraries. If they are missing ./configure will fail saying what's missing. If this will happen simply use your package manager (apt, yum or zypper - distro dependent) to install required packages and retry.
It's also likely that your PHP apps are using other extensions. The procedure is exactly the same. You just add more options. Let's say that curl is also needed, then:
./configure --with-bz2 --with-curl
will work - again more headers and packages needed.
Remember to always use all the options you need as the results of former compilations are overwritten.
I'm installing a PHP script in my server and when I try to run the test page, I get an error saying:
PHP needs to be compiled with ZLib support enabled (--with-zlib[=DIR])
How can I fix this on Apache?
I assume this is on linux?
As the error says, you need to recompile your PHP installation.
Take a look at the Makefile in the folder where you have the PHP source to see the ./configure line that was used last time, use all of the same options with the addition of --with-zlib
./configure --with-zlib ...(other config options)...
make
make install