When building PHP 5.3.x for Apache 2.4.x you may get an error in the apxs query for the MPM_NAME.
This is because the apxs included in Apache 2.4.x doesn't recognize that query anymore.
To resolve this issue one should modify the PHP configure file to use the right MPM module used by Apache.
To know the used MPM you can execute this command: apachectl -t -D DUMP_MODULES | grep mpm
Then, edit the PHP configure file, search for the APXS_MPM variable and force its value to prefork, event or worker according to the value returned by the previous command.
Hope it helps.
-
Fabio
Problemas de Compilación
Esta sección reune la mayoría de errores que ocurren al momento de compilar.
- Tengo la última versión de PHP usando el servicio anónimo Git, pero no hay un script de configuración.
- Tengo problemas configurando PHP para que trabaje con Apache. Dice que no puede encontrar el httpd.h, pero esta justo donde digo que esta!
- Mientras se configura PHP (./configure), se devuelve un error similar al siguiente: checking lex output file root... ./configure: lex: command not found configure: error: cannot find output from lex; giving up
- Cuando intento iniciar Apache, obtengo el siguiente mensaje: fatal: relocation error: file /path/to/libphp4.so: symbol ap_block_alarms: referenced symbol not found
- Cuando ejecuto la configuración, dice que no puede encontrar los archivos o librerías para GD, gdbm, o algún otro paquete!
- Cuando se esta compilando el archivo language-parser.tab.c, da errores así yytname undeclared.
- Cuando ejecuto make, parece que se ejecuta bien, pero luego falla cuando intenta enlazar la aplicación final quejandose de que faltan algunos archivos.
- Cuando se enlaza PHP, se queja del número de referencias indefenidas.
- No puedo encontrar la manera de compilar PHP con Apache 1.3.
- He seguido todos los pasos para instalar la versión del módulo de Apache en Unix, y cuando mis scripts de PHP aparecen se me pregunta por guardar el archivo.
- Dice que use: --activate-module=src/modules/php4/libphp4.a, pero ese archivo no existe, asi que lo cambie a --activate-module=src/modules/php4/libmodphp4.a y no funciona!? que esta pasando?
- Cuando intento compilar Apache con PHP como un módulo estatico usando --activate-module=src/modules/php4/libphp4.a me dice que mi compilador no es compatible con ANSI.
- Cuando intento compilar PHP usando --with-apxs obtengo mensajes de error extraños.
- Durante el make, obtengo errores sobre microtime, y muchas cosas de RUSAGE_.
- Cuando compilo PHP con MySQL, la configuración se ejecuta bien, pero durante el make obtengo un error similar al siguiente: ext/mysql/libmysql/my_tempnam.o(.text+0x46): In function my_tempnam': /php4/ext/mysql/libmysql/my_tempnam.c:103: the use of tempnam' is dangerous, better use mkstemp', ¿Qué esta mal?
- Si deseo actualizar mi PHP. ¿Donde puedo encontrar la línea ./configure que fue usada para compilar mi instalación actual de PHP?
- Cuando compilo PHP con la librería GD, también da errores raros de compilación o segfaults en la ejecución.
- Cuando compilo PHP parece que recibo errores al azar, como si se colgara. Estoy usando Solaris si eso importa.
- Tengo la última versión de PHP usando el servicio anónimo Git, pero no hay un script de configuración.
-
Se tiene que tener el paquete autoconf de GNU instalado y así se podrá generar el script de configuración desde configure.in. Solo se ejecuta ./buildconf en el directorio de nivel superior después de obtener los fuentes desde el servidor Git. (También, a menos que se ejecute configure con la opción --enable-maintainer-mode, el script de configuración no se recompilará automaticamente cuando el archivo configure.in es actualizado, así que debe de asegurarse que se hace manualmente cuando se note que configure.in haya cambiado. Un sintoma de esto es encontrar cosas como @VARIABLE@ en el archivo Makefile después de configurar o ejecutar config.status).
- Tengo problemas configurando PHP para que trabaje con Apache. Dice que no puede encontrar el httpd.h, pero esta justo donde digo que esta!
-
Se necesita decirle al script configure/setup de apache la ubicación del nivel superior del árbol origen. Esto significa que se debe especificar --with-apache=/path/to/apache y no --with-apache=/path/to/apache/src .
-
Mientras se configura PHP (./configure), se devuelve
un error similar al siguiente:
checking lex output file root... ./configure: lex: command not found
configure: error: cannot find output from lex; giving up
-
Se debe asegurar de leer cuidadosamente las instrucciones installation y notar que se necesita flex y bison instalados para compilar PHP. Dependiendo de la configuración, se necesitará instalar bison y flex desde el paquete de origen, como un RPM
- Cuando ejecuto la configuración, dice que no puede encontrar los archivos o librerías para GD, gdbm, o algún otro paquete!
-
Se puede configurar el script para que busque los archivos de encabezados y librerías en ubicaciones no estándar para especificar flags adicionales para ser pasados al preprocesador y compilador C, como:
Si se esta usando una variante de csh como login shell (por qué?), debería de ser:CPPFLAGS=-I/path/to/include LDFLAGS=-L/path/to/library ./configureenv CPPFLAGS=-I/path/to/include LDFLAGS=-L/path/to/library ./configure
- Cuando se esta compilando el archivo language-parser.tab.c, da errores así yytname undeclared.
-
Se debe actualizar la versión de Bison. Se puede encontrar la ultima versión en » http://www.gnu.org/software/bison/bison.html.
- Cuando ejecuto make, parece que se ejecuta bien, pero luego falla cuando intenta enlazar la aplicación final quejandose de que faltan algunos archivos.
-
Algunas versiones antiguas de make no colocan correctamente las versiones compiladas de archivos y funciones de directorio en el mismo directorio. Se debe intentar ejecutar las funciones cp *.o y entonces re-ejecutar make para ver si eso ayuda. Si no lo hace, realmente se debería actualizar a la versión más reciente de GNU Make.
- Cuando se enlaza PHP, se queja del número de referencias indefenidas.
-
Hay que mirar la linea del enlace y asegurarse de que todas las librerías apropiadas han sido incluidas al final. Las mas comunes que podrían estar perdidas son las '-ldl' y librerías requeridas como soporte por cualquier base de datos que se haya incluido.
Algunas personas han reportado que han tenido que adicionar '-ldl' inmediatamente seguido por libphp4.a cuando enlazan con Apache.
- No puedo encontrar la manera de compilar PHP con Apache 1.3.
-
Esto es muy fácil actualmente. Siga cuidadosamente estos pasos:
- Obtener la ultima distribución de Apache 1.3 desde » http://httpd.apache.org/download.cgi.
- Descomprimir el archivo en alguna parte, por ejemplo /usr/local/src/apache-1.3.
- Compilar PHP para la primera ejecución ./configure --with-apache=/<path>/apache-1.3 (sustituir <path> por la ruta actual del directorio de apache-1.3).
- Escribir make seguido por make install para compilar PHP y copiar los archivos necesarios al árbol de la distribución de Apache.
- Cambiar los directorios en el directorio /<path>/apache-1.3/src y editar el archivo de Configuration. Adicionar al archivo: AddModule modules/php4/libphp4.a.
- Escribir: ./configure seguido por make.
- Se debería tener ahora un httpd binario con PHP habilitado!
Nota:Se puede usar también el nuevo script ./configure. Ver las instrucciones en el archivo README.configure el cual es parte de la distribución de Apache. También se puede hechar una mirada al archivo INSTALL en la distribución de PHP.
- He seguido todos los pasos para instalar la versión del módulo de Apache en Unix, y cuando mis scripts de PHP aparecen se me pregunta por guardar el archivo.
-
Esto significa que el módulo de PHP no esta siendo invocado por alguna razón. Hay tres cosas que chequear antes de pedir ayuda:
- Asegurarse que el binario del httpd que se esta ejecutando es el nuevo binario httpd que se acaba de hacer. Para ver esto, se debe intentar ejecutar: /path/to/binary/httpd -l Si no se ve mod_php4.c listado, entonces no se esta ejecutando el binario correcto. Hay que encontrarlo e instalar el binario correcto.
- Asegurarse de que es agregado el Mime Type correcto en uno de los archivos de Apache .conf. Debería de ser: AddType application/x-httpd-php .php También asegurarse que esta línea AddType no esta oculta dentro de un bloque de <Virtualhost> o uno de <Directory> el cual podría evitar que se aplique en el lugar donde se prueba el script.
- Por último, el lugar por defecto de los archivos de configuración de Apache cambio entre Apache 1.2 y Apache 1.3. Se debería chequear que el archivo de configuración al cual se le agrega la línea AddType esta siendo leído actualmente. Se puede poner un error de sintaxis obvio dentro del archivo httpd.conf o algún otro cambio que pueda decir si el archivo esta siendo leído de forma correcta.
- Dice que use: --activate-module=src/modules/php4/libphp4.a, pero ese archivo no existe, asi que lo cambie a --activate-module=src/modules/php4/libmodphp4.a y no funciona!? que esta pasando?
-
Hay que tener en cuenta que el archivo libphp4.a no se supone que exista. El proceso de apache sera creado!.
- Cuando intento compilar Apache con PHP como un módulo estatico usando --activate-module=src/modules/php4/libphp4.a me dice que mi compilador no es compatible con ANSI.
-
Este es un mensaje de error equivocado de Apache que ha sido corregido en las versiones mas recientes.
- Cuando intento compilar PHP usando --with-apxs obtengo mensajes de error extraños.
-
Hay 3 cosas que chequear aqui. Primero, por alguna razón cuando Apache compila el script de Perl apxs, algunas veces termina compilandose sin el compilador apropiado y sin los flags correspondientes. Hay que encontrar el script apxs (intentar con el comando which apxs), algunas veces se encuentra en /usr/local/apache/bin/apxs o /usr/sbin/apxs. Abrirlo y revisar las líneas similares a estas:
Si esto es lo que se ve, se ha encontrado el problema. Podrían contener espacios u otros valores incorrectos, como 'q()'. Hay que cambiar esas linas para que digan:my $CFG_CFLAGS_SHLIB = ' '; # substituted via Makefile.tmpl my $CFG_LD_SHLIB = ' '; # substituted via Makefile.tmpl my $CFG_LDFLAGS_SHLIB = ' '; # substituted via Makefile.tmpl
El segundo problema posible podría ser un caso único en Red Hat 6.1 y 6.2. El script apxs de Red Hat esta malo. Hay que ver esta línea:my $CFG_CFLAGS_SHLIB = '-fpic -DSHARED_MODULE'; # substituted via Makefile.tmpl my $CFG_LD_SHLIB = 'gcc'; # substituted via Makefile.tmpl my $CFG_LDFLAGS_SHLIB = q(-shared); # substituted via Makefile.tmpl
Si se ve como la línea anterior, hay que cambiarla por:my $CFG_LIBEXECDIR = 'modules'; # substituted via APACI install
Por último, si se reconfigura/reinstala Apache, hay que agregar un make clean al proceso después de ./configure y antes de make.my $CFG_LIBEXECDIR = '/usr/lib/apache'; # substituted via APACI install
- Durante el make, obtengo errores sobre microtime, y muchas cosas de RUSAGE_.
-
Durante la parte de la instalación de make, si se encuentran problemas que se vean similares a esto:
microtime.c: In function `php_if_getrusage': microtime.c:94: storage size of `usg' isn't known microtime.c:97: `RUSAGE_SELF' undeclared (first use in this function) microtime.c:97: (Each undeclared identifier is reported only once microtime.c:97: for each function it appears in.) microtime.c:103: `RUSAGE_CHILDREN' undeclared (first use in this function) make[3]: *** [microtime.lo] Error 1 make[3]: Leaving directory `/home/master/php-4.0.1/ext/standard' make[2]: *** [all-recursive] Error 1 make[2]: Leaving directory `/home/master/php-4.0.1/ext/standard' make[1]: *** [all-recursive] Error 1 make[1]: Leaving directory `/home/master/php-4.0.1/ext' make: *** [all-recursive] Error 1
Significa que el sistema esta mal. Se necesita corregir los archivos /usr/include instalando el paquete glibc-devel que coincida con tu glibc. Esto no tiene nada que ver con PHP. Para comprobar esto, hay que hacer esta simple prueba:
Si esto produce errores, se sabrá que los archivos incluidos están mal.$ cat >test.c <<X #include <sys/resource.h> X $ gcc -E test.c >/dev/null
- Cuando compilo PHP con MySQL, la configuración se ejecuta bien, pero durante el make obtengo un error similar al siguiente: ext/mysql/libmysql/my_tempnam.o(.text+0x46): In function my_tempnam': /php4/ext/mysql/libmysql/my_tempnam.c:103: the use of tempnam' is dangerous, better use mkstemp', ¿Qué esta mal?
-
Primero, es importante darse cuenta que esto es un Warning y no un error fatal. Debido a que esto es la última salida vista durante el make, podría verse como un error fatal pero no lo es. Por supuesto, si se ha puesto el compilador a que pare en los Warnings, lo hará. También hay que tener en mente que el soporte por MySQL es habilitado por defecto.
Nota:
Como en PHP 4.3.2, se verá el siguiente texto después de que se complete la compilación (make):
Build complete.
(Es seguro hacer caso omiso de las advertencias sobre tempnam y tmpnam).
- Si deseo actualizar mi PHP. ¿Donde puedo encontrar la línea ./configure que fue usada para compilar mi instalación actual de PHP?
-
Si se mira el archivo config.nice, en el árbol origen de la instalación actual de PHP o, si esto no esta disponible, simplemente se debe ejecutar un script con
Al inicio de la salida se mostrará la línea ./configure que fue usada para compilar la instalación de PHP.<?php phpinfo(); ?>
- Cuando compilo PHP con la librería GD, también da errores raros de compilación o segfaults en la ejecución.
-
Hay que asegurar que la librería GD y PHP estan enlazados contra las mismas librerías dependientes (ej: libpng).
- Cuando compilo PHP parece que recibo errores al azar, como si se colgara. Estoy usando Solaris si eso importa.
-
Usando utilidades no-GNU mientras se compila PHP podría causar problemas. Hay que asegurarse de usar herramientas GNU para estar seguros que la compilación de PHP funcionará. Por ejemplo, en Solaris, usando el SunOS BSD-compatible o versiones de Solaris de sed no funcionará, pero usando las versiones GNU o Sun POSIX (xpg4) de sed hará que funcione. Enlaces: » GNU sed, » GNU flex, y » GNU bison.
The configure script of PHP 5.3.0 has some test lines that use expr with the option --, my expr (version 2.0) does not except --. This causes a run of error messages from the shell like:
./configure: line 2xxx: test: =: unary operator expected
expr: syntax error
I used buildconf --force to see if it would fix this.
While it resulted in a quit different file, it still had the lines of code with expr -- in it.
Re Solaris
I was able to compile PHP 5.0.4 under Solaris 2.6 but I had to use gcc to do it. The source is not compatible with the Solaris C preprocessor. I did not have to install any of the gnu utilities (like sed etc) to get it to compile. It clean compiled & linked immediately using gcc 3.3.2.
For the configure newbies among us:
If you update or reinstall any of the libraries used to compile in a different directory than they started out, you will need to make sure that you update the config.cache file (or re-generate it) so that configure will not look in the wrong place for the information.
On Mac OS X, for example, I updated my libxml using Fink. Fink placed the files in the /sw directory. However, php was still looking for important libxml files (such as xml2-config) in the old directory (/usr/bin/xml2-config). After updating config.cache with the new value of the xml2-config path, I was able to compile correctly.
If the option --with-apsx2=/path/to/apxs seems to have absolutely no effect and if the configure script ignores the Apache 2.x support, try to shutdown your Apache server (/path/to/bin/apachectl stop) and retry.
It worked here.
I post here because I was unable to find the information on the web.
I hope it will help someone.
Let say you have 2 apache ruuning, on one you want to have disable_functions set and on the other one you don't.
In fact I have (one) solution compiling two differents php modules with differents path to php.ini
using :
--with-config-file-path=/etc/php5 (for the first one)
--with-config-file-path=/etc/php5.nonchroote (for the second one)
for the second one I do not use "make install" but just
"cp .libs/libphp5.so /usr/lib/apache/1.3/libphp5.nonchroote.so"
Then you have to change the
LoadModule php5_module /usr/lib/apache/1.3/libphp5.nonchroote.so in the second httpd.conf
My problem was actually with mod_dav (which referred me here). Since they took the time to point people here, I thought I'd go ahead and add my two cents worth and expand on the above since it obviously affects PHP as well. I am running Fedora Core 3, Apache 2.0.53, & PHP 5.03. Apache and PHP were built from source.
The first suggestion in section 13 above was close, but not exactly what I needed. jimsteele's suggestion would have worked, but you would have to do it every time you use APXS. What I did was copy these lines:
my $CFG_CFLAGS_SHLIB = '-fpic -DSHARED_MODULE';
my $CFG_LD_SHLIB = 'gcc';
my $CFG_LDFLAGS_SHLIB = q(-shared);
and pasted them in the configuration section of my apxs file. Worked like a champ.
When you have installed PHP5 as a package from your distribution source list, such as yast or apt and want to upgrade the probably out of date PHP5 version make sure:
1. Apache-develope tools are installed so that you have APXS(2)
2. make a clean install which means:
make distclean
./configure --with-apxs2=/usr/sbin/apxs2 and other options
make && make test && make clean install
This will take a while, the make test basically tests your php installation if it passes all the bug reports, as of now about 8600.
Those thre lines will take a while longer! So dont panic, but read the output!
This should ensure, that you have .so files again (because of the APXS and that you have established a relation between the apache and php. Obviously you needed to deinstall the mod_php5 first. I would highly recommend to train this and verify that you have all the required kernel source files and compiler stuff on a virtual machine before doing that on your productive server!
@ anca-phpdoc at anca dot tv:
You can use ./configure --with-libxml-dir=/path_to_xml2-config
Note on PHP5 setup under RedHat 7
Sometimes php5 fails to build with the following message:
[root@www bin]# ./php5
./php5: error while loading shared libraries: unexpected reloc type 0x80
Below is the configure script used:
# PHP5 CLI build, CGI/SAPI disabled
# Created by configure
'./configure' \
'--enable-libxml' \
'--with-mysql=/path_to_mysql' \
'--with-libxml=/path_to_my_libxml' \
'--program-suffix=5' \
'--disable-cgi' \
"$@"
I used the following trick to get round this:
0. If it is not a clean installation, run 'make clean' to get rid of improperly compiled files
1. run ./configure with required options
2. edit makefile:
2.1 find any LDFLAGS or PROGRAM_LDFLAGS definition
2.2 append -lstdc++ to the end of it
3. Run 'make'
4. Run 'make install'
5. Enjoy!!!
Compiling mod_php4 port on a clean freeBSD 4.8 install for Apache2 needed FOR_APACHE2= yes manually inserted into Makefile prior to version check.
If you have customized your Apache to lie about its version number, you may need to edit configure to skip the version number check. Just /APACHE_VERSION in configure to find the instance(s) where configure checks to make sure you have the right combination of --with-apxs or --with_apxs2 and Apache 1.3 or 2.0. Assuming you're smart enough to remember which version of Apache you have, you can just delete or comment out the version check and continue to march.
Defining the right environment variables for my Apache "make" invocation allowed the correct "apxs" file to be generated for me. Your mileage may vary.
cd ../apache_1.3.22
CFLAGS_SHLIB="-fpic -DSHARED_MODULE" \
LD_SHLIB=gcc \
LDFLAGS_MOD_SHLIB="-shared" \
make
