En este momento estás viendo compilar, instalar y configurar Apache 2.4.58 con PHP 8.3.1 en Linux

compilar, instalar y configurar Apache 2.4.58 con PHP 8.3.1 en Linux

En este articulo voy a explicarte los pasos básicos para compilar, instalar y configurar apache 2.4.58 con php 8.3.1 en GNU/Linux, concreta mente bajo Ubuntu, aunque se puede aplicar a cualquier distribución CentOS, Fedora, Debian, etc).

Lo primero que tenemos que comprobar es que tengamos actualizado nuestro sistema para comenzar a trabajar:

$ sudo apt update

$ sudo apt upgrade

También te dejare una lista de comandos que necesitaremos durante toda la instalación.

$ sudo apt install libapr1 libaprutil1 libaprutil1-dev
$ sudo apt install gcc
$ sudo apt install libpcre3-dev
$ sudo apt install make
$ sudo apt install pkg-config
$ sudo apt install libxml2-dev
$ sudo apt install libxml2
$ sudo apt install libsqlite3-dev

Vamos a crear una carpeta en nuestro caso llamada “instalaciones” para desccargar los paquetes que instalaremos en nuestro sistema, usando mkdir.

$ mkdir instalaciones
$ cd instalaciones/

Después descargaremos apache2 desde su pagina oficial.

$ wget https://dlcdn.apache.org/httpd/httpd-2.4.58.tar.gz

después usaremos los siguientes comandos para extraer los archivos:

$ gzip -d httpd-2.4.58.tar.gz

$ tar xvf httpd-2.4.58.tar

ahora vamos a compilar apache:

$ cd httpd-2.4.58/

$ ./configure

$ make

$ make install

Después de instalar apache este se instalara en la ruta /usr/local/apache2.

para levantar y parar el servicio puedes usar:

$ sudo /usr/local/apache2/bin/apachectl start

$ sudo /usr/local/apache2/bin/apachectl stop

Si te aparece el siguiente error al levantar el servicio, solo recuerda editar tu archivos /usr/local/apache2/conf/httpd.conf

NOTA: En este articulo no se abordara a fondo las configuraciones, ya que a estas alturas creemos que el problema que abordamos es compilar el php en esta versión de apache2, si tienes alguna duda déjanos tus comentarios.

Después de eso nos damos cuenta que al crear un documento info.php en /usr/local/apache2/httdocs, al consultar este info.php nos damos cuenta que apache2 no interpreta nuestro php.

<?php

phpinfo();

?>

Lo que haremos vamos a extraer y compilar PHP 8.3.1  al igual que apache2 usaremos los siguientes comandos:

$ wget https://www.php.net/distributions/php-8.3.1.tar.gz

$ gunzip php-8.3.1.tar.gz

$ tar -xf php-8.3.1.tar

$ cd php-8.3.1/

$ ./configure –with-apxs2=/usr/local/apache2/bin/apxs –with-mysql

$ make

$ make install

Después de hacerlo vamos a revisar si en el archivo /usr/local/apache2/conf/httpd.conf la siguiente linea:

LoadModule php_module modules/libphp.so

También agregaremos las siguientes lineas:

<FilesMatch ".+\.ph(?:ar|p|tml)$">
    SetHandler application/x-httpd-php
</FilesMatch>
<FilesMatch ".+\.phps$">
    SetHandler application/x-httpd-php-source
    # Deny access to raw php sources by default
    # To re-enable it's recommended to enable access to the files
    # only in specific virtual host or directory
    Require all denied
</FilesMatch>
# Deny access to files without filename (e.g. '.php')
<FilesMatch "^\.ph(?:ar|p|ps|tml)$">
    Require all denied
</FilesMatch>

Después vamos iniciar nuestro apache2 y si colocamos todo correctamente no debería haber ningún problema, quedando listo nuestro apache interpretando php.

$ sudo /usr/local/apache2/bin/apachectl start

Errores que pueden suceder durante la instalación:

checking for chosen layout… Apache checking for working mkdir -p… yes checking for grep that handles long lines and -e… /usr/bin/grep checking for egrep… /usr/bin/grep -E checking build system type… x86_64-pc-linux-gnu checking host system type… x86_64-pc-linux-gnu checking target system type… x86_64-pc-linux-gnu configure: configure: Configuring Apache Portable Runtime library… configure: checking for APR… no configure: error: APR not found. Please read the documentation.

checking for chosen layout… Apache checking for working mkdir -p… yes checking for grep that handles long lines and -e… /usr/bin/grep checking for egrep… /usr/bin/grep -E checking build system type… x86_64-pc-linux-gnu checking host system type… x86_64-pc-linux-gnu checking target system type… x86_64-pc-linux-gnu configure: configure: Configuring Apache Portable Runtime library… configure: checking for APR… yes setting CC to “x86_64-linux-gnu-gcc” setting CPP to “x86_64-linux-gnu-gcc -E” setting CFLAGS to ” ” setting CPPFLAGS to ” -DLINUX -D_REENTRANT -D_GNU_SOURCE” setting LDFLAGS to ” ” configure: configure: Configuring Apache Portable Runtime Utility library… configure: checking for APR-util… no configure: error: APR-util not found. Please read the documentation.

checking for unistd.h… yes checking minix/config.h usability… no checking minix/config.h presence… no checking for minix/config.h… no checking whether it is safe to define __EXTENSIONS__… yes checking for library containing strerror… none required checking for APR version 1.3.0 or later… yes checking for APR-util version 1.3.0 or later… no configure: error: APR-util version 1.3.0 or later is required

checking for APR… yes setting CC to “gcc” setting CPP to “gcc -E” setting CFLAGS to ” -g -O2″ setting CPPFLAGS to ” -DLINUX -D_REENTRANT -D_GNU_SOURCE” setting LDFLAGS to ” ” configure: configure: Configuring Apache Portable Runtime Utility library… configure: checking for APR-util… no configure: error: APR-util not found. Please read the documentation.

AH00558: httpd: Could not reliably determine the server’s fully qualified domain name, using x.x.x.x. Set the ‘ServerName’ directive globally to suppress this message httpd not running, trying to start (98)Address already in use: AH00072: make_sock: could not bind to address [::]:80 (98)Address already in use: AH00072: make_sock: could not bind to address 0.0.0.0:80 no listening sockets available, shutting down AH00015: Unable to open logs

sudo /usr/local/apache2/bin/apachectl start [Sun Dec 31 04:26:46.659977 2023] [php:crit] [pid 89978:tid 140255123892096] Apache is running a threaded MPM, but your PHP Module is not compiled to be threadsafe. You need to recompile PHP. AH00013: Pre-configuration failed

Deja una respuesta