Skip to content

Instantly share code, notes, and snippets.

@nullx5
Last active May 14, 2025 22:29
Show Gist options
  • Save nullx5/b02dd9d7e019351dbdf81afe0beb3047 to your computer and use it in GitHub Desktop.
Save nullx5/b02dd9d7e019351dbdf81afe0beb3047 to your computer and use it in GitHub Desktop.

Compilar php manualmente y agregarlo a una instalacion de apache por repositorio APT


sudo apt update
sudo apt install -y build-essential autoconf bison re2c libxml2-dev \
  libsqlite3-dev libssl-dev libcurl4-openssl-dev libjpeg-dev libpng-dev \
  libwebp-dev libxpm-dev libzip-dev libonig-dev libreadline-dev \
  libtidy-dev libxslt1-dev libffi-dev pkg-config git perl apache2-dev



wget https://www.php.net/distributions/php-8.3.21.tar.gz
7z x php-8.3.21.tar.gz
cd php-8.3.21


./configure --with-apxs2=/usr/bin/apxs \
  --enable-mbstring --with-curl --with-openssl --enable-soap \
  --enable-intl --with-zip --with-zlib --enable-bcmath --with-readline \
  --with-xsl --with-tidy --enable-pcntl --enable-opcache --with-mysqli \
  --with-pdo-mysql --enable-fpm --enable-zts --with-gd

make -j$(nproc)
make test
sudo make install


#Verifica que se haya creado el módulo
ls /usr/lib/apache2/modules/libphp*.so

#Carga el módulo en Apache
sudo nano /etc/apache2/mods-available/php.load
LoadModule php_module /usr/lib/apache2/modules/libphp.so


sudo cp /usr/local/bin/php /usr/bin/
php --version

sudo a2enmod php
a2query -m


echo "<?php phpinfo(); ?>" | sudo tee /var/www/html/info.php


sudo nano /etc/apache2/apache2.conf
<FilesMatch "\.php$">
    SetHandler application/x-httpd-php
</FilesMatch>

DirectoryIndex index.php



sudo systemctl restart apache2





@nullx5
Copy link
Author

nullx5 commented May 12, 2025

sudo systemctl restart apache2

Apache is running a threaded MPM, but your PHP Module is not compiled to be threadsafe. You need to recompile PHP.

❌ ¿QUÉ SIGNIFICA ESTE ERROR?
Apache está usando un MPM (Multi-Processing Module) de tipo threaded (probablemente event), pero tu PHP compilado no es threadsafe (es decir, no fue compilado con --enable-maintainer-zts).

mod_php no es compatible con MPM threaded si no está compilado con ZTS (Zend Thread Safety).

SOLUCION

Recompilar PHP con soporte ZTS (hilos seguros)

./configure --enable-zts --with-apxs2=/usr/bin/apxs 

Recomendación moderna
En lugar de usar mod_php, se suele usar PHP-FPM (FastCGI), que es más rápido y no tiene este problema, y funciona bien con mpm_event.

@nullx5
Copy link
Author

nullx5 commented May 13, 2025

sudo make install

Installing PHP CLI binary:        /usr/local/bin/
Installing PHP CLI man page:      /usr/local/php/man/man1/
Installing PHP FPM binary:        /usr/local/sbin/
Installing PHP FPM defconfig:     /usr/local/etc/
Installing PHP FPM man page:      /usr/local/php/man/man8/
Installing PHP FPM status page:   /usr/local/php/php/fpm/
Installing phpdbg binary:         /usr/local/bin/
Installing phpdbg man page:       /usr/local/php/man/man1/
Installing PHP CGI binary:        /usr/local/bin/
Installing PHP CGI man page:      /usr/local/php/man/man1/
Installing build environment:     /usr/local/lib/php/build/
Installing header files:          /usr/local/include/php/
Installing helper programs:       /usr/local/bin/
  program: phpize
  program: php-config
Installing man pages:             /usr/local/php/man/man1/
  page: phpize.1
  page: php-config.1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment