Notas de instalación en Debian GNU/Linux

Esta sección contiene notas y consejos específicos para instalar PHP sobre » Debian GNU/Linux.

Advertencia

No se ofrece soporte de builds no oficiales de terceros. Cualquier bug debe ser informado al equipo de Debian a no ser que puedan reproducirse usando los últimos builds de nuestra » zona de descargas.

Mientras que las instrucciones para construir PHP sobre Unix se aplican a Debian también, esta página del manual contiene información específica para otras opciones, tales como utilizar ya sea los comandos apt-get o aptitude. En esta página del manual estos dos comandos se pueden utilizar indistintamente.

Utilizando APT

Primero, nótese que otros paquetes relacionados podrían ser deseables como libapache2-mod-php5 para integración con Apache 2, y php-pear para PEAR.

Segundo, antes de instalar un paquete, es sensato asegurarse de que la lista de paquetes está al día. Típicamente, esto se realiza ejecutando el comando apt-get update.

Ejemplo #1 Ejemplo de Instalación en Debian con Apache 2

# apt-get install php5-common libapache2-mod-php5 php5-cli

APT instalará automáticamente el módulo PHP 5 para Apache 2 junto con todas sus dependencias, y luego lo activará. Apache debería reiniciarse para que los cambios tengan efecto. Por ejemplo:

Ejemplo #2 Deteniendo e iniciando Apache una vez que PHP está instalado

# /etc/init.d/apache2 stop
# /etc/init.d/apache2 start

Un mejor control de la configuración

En la sección anterior, PHP se instaló únicamente con los módulos principales. Es muy probable que se deseen módulos adicionales, tales como MySQL, cURL, GD, etc. Estos también pueden ser instalados vía el comando apt-get.

Ejemplo #3 Métodos para listar paquetes relacionados con PHP 5

# apt-cache search php5
# aptitude search php5
# aptitude search php5 |grep -i mysql

Los ejemplos mostrarán una gran cantidad de paquetes incluyendo varios específicos a PHP como php5-cgi, php5-cli y php5-dev. Determine cuales son necesarios e instálelos como cualquier otro ya sea con apt-get o aptitude. Y ya que Debian realiza revisión de dependencias, preguntará por ellos, así que por ejemplo para instalar MySQL y cURL:

Ejemplo #4 Instalar PHP con MySQL, cURL

# apt-get install php5-mysql php5-curl

APT agregará automáticamente las líneas apropiadas a los diferentes ficheros relacionados con php.ini como /etc/php5/apache2/php.ini, /etc/php5/conf.d/pdo.ini, etc. y dependiendo de la extensión, le agregará registros similares a extension=foo.so. De cualquier manera, reiniciar el servidor web (como es Apache) es requerido antes de que estos cambios tengan efecto.

Problemas Frecuentes

  • Si los scripts de PHP no se están interpretando por el servidor web, entonces es probable que PHP no haya sido agregado al fichero de configuración del servidor web, que en Debian puede ser /etc/apache2/apache2.conf o algo semejante. Véase el manual de Debian para mayores detalles.
  • Si una extensión fue aparentemente instalada y aún así las funciones no aparecen definidas, asegurar de que el fichero ini apropiado está siendo cargado y/o que el servidor web fue reiniciado después de la instalación.
  • Hay dos comandos básicos para instalar paquetes en Debian (y otras variantes de linux): apt-get y aptitude. Pero, explicar las sutiles diferencias entre estos comandos va más allá del alcance de este manual.
add a note

User Contributed Notes 6 notes

up
67
thumbs at apache dot org
10 years ago
To refresh this document, perhaps it would be worth mentioning more modern methods to serve php content under apache httpd.

Specifically, the preferred method is now fastcgi, using either of those recipes:

(mod_fastcgi, httpd 2.2)
http://wiki.apache.org/httpd/php-fastcgi

(mod_fcgid, httpd 2.2)
http://wiki.apache.org/httpd/php-fcgid

(mod_proxy_fcgi, httpd 2.4)
http://wiki.apache.org/httpd/PHP-FPM

While the legacy mod_php approach is still applicable for some older installations, the fastcgi method is much faster, and require much less RAM to operate, based on similar traffic patterns.

Thank you!
up
41
kearney dot taaffe at gmail dot com
6 years ago
Compiling PHP on Ubuntu boxes.

If you would like to compile PHP from source as opposed to relying on package maintainers, here's a list of packages, and commands you can run

STEP 1:
sudo apt-get install autoconf build-essential curl libtool \
libssl-dev libcurl4-openssl-dev libxml2-dev libreadline7 \
libreadline-dev libzip-dev libzip4 nginx openssl \
pkg-config zlib1g-dev

So you don't overwrite any existing PHP installs on your system, install PHP in your home directory. Create a directory for the PHP binaries to live

mkdir -p ~/bin/php7-latest/

STEP 2:
# download the latest PHP tarball, decompress it, then cd to the new directory.

STEP 3:
Configure PHP. Remove any options you don't need (like MySQL or Postgres (--with-pdo-pgsql))

./configure --prefix=$HOME/bin/php-latest \
--enable-mysqlnd \
--with-pdo-mysql \
--with-pdo-mysql=mysqlnd \
--with-pdo-pgsql=/usr/bin/pg_config \
--enable-bcmath \
--enable-fpm \
--with-fpm-user=www-data \
--with-fpm-group=www-data \
--enable-mbstring \
--enable-phpdbg \
--enable-shmop \
--enable-sockets \
--enable-sysvmsg \
--enable-sysvsem \
--enable-sysvshm \
--enable-zip \
--with-libzip=/usr/lib/x86_64-linux-gnu \
--with-zlib \
--with-curl \
--with-pear \
--with-openssl \
--enable-pcntl \
--with-readline

STEP 4:
compile the binaries by typing: make

If no errors, install by typing: make install

STEP 5:
Copy the PHP.ini file to the install directory

cp php.ini-development ~/bin/php-latest/lib/

STEP 6:

cd ~/bin/php-latest/etc;
mv php-fpm.conf.default php-fpm.conf
mv php-fpm.d/www.conf.default php-fpm.d/www.conf

STEP 7:
create symbolic links for your for your binary files

cd ~/bin
ln -s php-latest/bin/php php
ln -s php-latest/bin/php-cgi php-cgi
ln -s php-latest/bin/php-config php-config
ln -s php-latest/bin/phpize phpize
ln -s php-latest/bin/phar.phar phar
ln -s php-latest/bin/pear pear
ln -s php-latest/bin/phpdbg phpdbg
ln -s php-latest/sbin/php-fpm php-fpm

STEP 8: link your local PHP to the php command. You will need to logout then log back in for php to switch to the local version instead of the installed version

# add this to .bashrc
if [ -d "$HOME/bin" ] ; then
PATH="$HOME/bin:$PATH"
fi

STEP 9: Start PHP-FPM

sudo ~/bin/php7/sbin/php-fpm
up
-17
marin at sagovac dot com
10 years ago
To install LAMP stack on Ubuntu (+Server) from 10.04 you need first install taskel and then lamp-server for example:

Install taskel, follow terminal guides:
sudo apt-get install tasksel

Install LAMP stack package from Ubuntu repository:
sudo tasksel install lamp-server
up
-22
John Fisher
17 years ago
With Apache2 and Php4 under Debian Sarge there is an extra configuration file : /etc/apache2/sites-available/default
This file is not clearly documented, at least not for noobs, in Apache docs.

It overrides the conf file in the way you expect the /etc/apache2/conf.d/apache2-doc to do according to the README.

Add ExecCGI to it to get rid of "Options ExecCGI is off in this directory" errors.
up
-25
juraj at jurajsplayground dot com
14 years ago
On Ubuntu (since 7.04), rather do:
sudo tasksel install lamp-server

Details:
https://help.ubuntu.com/community/ApacheMySQLPHP
up
-40
tranzbit at yahoo dot com
14 years ago
On Ubuntu:

sudo apt-get install apache2 php5 mysql-client-5.0 mysql-server-5.0 phpmyadmin libapache2-mod-php5 libapache2-mod-auth-mysql php5-mysql

then restart the computer/start mysql manually
From:
http://ubuntuforums.org/showthread.php?t=186492
To Top