TÍTULO: Apache2+PHP4+Htdig
VERSIÓN LFS: 3.1 en adelante
AUTOR: Marcos Zapata <zeta11@yahoo.com>
TRADUCTOR: Proyecto LFS-ES
SINOPSIS:
Cómo configurar PHP4 con Apache2 y ht://Dig.
RECETA:
La primera vez que intenté compilar PHP4 para Apache 2, no pude debido al
nuevo soporte de E/S implementado. Leí el README en sapi/apache2filter, pero
esto no ayudó y no quería retroceder al apache-1.3.x; así es como lo tuve
que hacer:
Puedes descargar apache desde http://httpd.apache.org y PHP desde
http://www.php.net. Voy a usar httpd-2.0.39.tar.gz y php-4.2.1.tar.bz2.
httpd-2.0.39:
#Recuerda cambiar la opción '--prefix' para reflejar el esquema de tu sistema,
#yo prefiero usar una ubicación no usual para estos paquetes. Si construiste
#un sistema LFS, deberías tener instalado openssl y perl, sino quita esas
#opciones de configuración.
tar -zxvf httpd-2.0.39.tar.gz
cd httpd-2.0.39
./configure --prefix=/opt/httpd-2.0.39 --enable-ssl --enable-cgi --enable-so \
--enable-modules=all --with-perl --enable-shared=max
make
make install
Verifica si ya tienes definido el usuario nobody, si no es así, agrégalo con
useradd, algo como: 'useradd nobody' debería bastar. Ahora veamos si todo
marchó bien:
/opt/httpd-2.0.39/bin/apachectl start
Utiliza lynx, nmap, netstat o cualquier otr herramienta que uses para ver
si el servidor está corriendo. Si tienes lynx: 'lynx http://localhost/'
te dará la página que muestra una instalación exitosa de apache. Si no lo
tienes puedes usar 'netstat -l | grep www', te mostraráuna línea similar a
esta:
'tcp 0 0 *:www *.* LISTEN'
Ahora, que estamos seguros:
/opt/httpd-2.0.39/bin/apachectl stop
, sólo un momento para instalar PHP.
php-4.2.1:
tar -jxvf php-4.2.1.tar.bz2
cd php-4.2.1
#PHP te da toneladas de opciones, usa las que necesites. Verifícalas con
#'./configure --help'. Si No tienes instalado mysql, php construirá el
#módulo incorporado. Yo uso las siguientes opciones:
./configure --prefix=/opt/httpd-2.0.39 \
--with-config-file-path=/opt/httpd-2.0.39/conf --without-pear --with-openssl \
--with-zlib --with-bz2 --enable-calendar --with-gdbm --with-db3 --with-gmp \
--with-mysql --with-ncurses --with-pgsql
make
make install
Muy bien, tenemos que agregar algunas opciones en /opt/httpd-2.0.39/conf/httpd.conf:
echo "ScriptAlias /php/ \"/opt/httpd-2.0.39/bin/\"" >> \
/opt/httpd-2.0.39/conf/httpd.conf
echo "Action application/x-httpd-php \"/php/php\"" >> \
/opt/httpd-2.0.39/conf/httpd.conf
echo "AddType application/x-httpd-php .php" >>
/opt/httpd-2.0.39/conf/httpd.conf
Esto es vital. Asegúrate que has cambiado /php/ para apuntar donde has instalado
los paquetes.
Crea un archivo de prueba:
echo "<? phpinfo(); ?>" > /opt/httpd-2.0.39/htdocs/test.php
Es momento de ver si todo ha marchado bien, reinicia el servidor con:
/opt/httpd-2.0.39/bin/apachectl start
Ahora necesitarás lynx u otro navegador web, con lynx haz:
lynx http://localhost/test.php
Esta página te mostrará información sobre PHP y tu sistema. Si puedes verla,
la instalación fué todo un éxito. Ahora puedes borrar el test.php.
Siguiendo el estilo LFS nosotros...:
Following the LFS style we...:
ln -s /opt/httpd-2.0.39 /opt/apache2
Bien, ahora necesitamos un guión de inicio, créalo con:
cat > /etc/rc.d/init.d/apache << "EOF"
#!/bin/sh
source /etc/rc.d/init.d/functions
case "$1" in
start)
echo "Iniciando el servidor web..."
loadproc /opt/apache2/bin/httpd
;;
stop)
echo "Deteniendo el servidor web..."
killproc /opt/apache2/bin/httpd
;;
restart)
$0 stop
sleep 1
$0 start
;;
status)
statusproc /opt/apache2/bin/httpd
;;
*)
echo "Modo de uso: $0 {start|stop|restart|status}"
exit 1
;;
esac
EOF
chmod a+x /etc/rc.d/init.d/apache
Recuerda hacer los enlaces simbólicos en /etc/rc.d/rc*.d.
htdig-3.1.6:
Un paquete interesante para ser usado en un servidor web es htdig, pero fué
difícil instalarlo en mi LFS. Puedes descargarlo de http://www.htdig.org.
tar -zxvf htdig-3.1.6.tar.gz
cd htdig-3.1.6
cp configure configure.bak
sed -e "s/ofstream=1/ofstream=0/" configure.bak > configure
Tuve que hacer esto porque no reconocía mi instalación de gcc.
Edita htlib/htString.h para forzarla a usar iostream.h coméntala
de esta manera:
...
// #ifdef HAVE_OSTREAM_H
// #include <ostream.h>
// #endif
// #ifdef HAVE_IOSTREAM_H
#include <iostream.h>
// #endif
...
Solamente deja sin comentar el '#include <iostream.h>'. Ahora no tendremos
ningún problema para hacer.
./configure --prefix=/opt/httpd-2.0.39 \
--with-config-dir=/opt/httpd-2.0.39/conf \
--with-common=/opt/httpd-2.0.39/common \
--with-database-dir=/opt/httpd-2.0.39/db \
--with-cgi-bin-dir=/opt/httpd-2.0.39/cgi-bin \
--with-image-dir=/opt/httpd-2.0.39/htdocs/htdig \
--with-search-dir=/opt/httpd-2.0.39/htdocs/htdig
make
make install
Para comenzar a usarlo, debes editar opt/apache2/conf/htdig.conf. Como
ejemplo cambia 'start_url' por 'http://localhost/' y ejecuta:
'/opt/apache2/bin/rundig'.
Tomará un rato construir la base de datos de búsqueda, puedes ignorar
tranquilamente cualquier mensaje de advertencia. Para probarlo:
'lynx http://localhost/htdig/search.html'.
¡Voila! Estamos listos. Recuerda cambiar todos los ficheros de configuración
para reflejar el esquema de tu sistema y vuelve a correr 'rundig', también
leer toda la documentación. Buena suerte.
Zeta
|