Compile o PHP5.4 para o Apache (já PHP5.3 apt-get instalado)

2

Eu tive o PHP Versão 5.3.10-1ubuntu3.1 instalado através do apt-get do Ubuntu por algum tempo.

Agora quero instalar o PHP5.4, que eu estava planejando compilar a partir do código-fonte. Eu extraí para /usr/src/php-5.4.3/ e executo:

./configure --with-mysqli --with-pcre-regex --with-pdo-mysql --with-pear --with-curl --with-gd --with-openssl; make; make install

assim como apt-get install ing outras bibliotecas necessárias para fazer esse trabalho.

Agora php -v é 5,4, como esperado, mas quando eu uso PHP através do Apache, ele ainda aponta para 5.3 de alguma forma. Eu até fiz apt-get remove --purge php5-dev mas estou perdendo alguma coisa. Alguma idéia do que?

Obrigado pela sua ajuda.

    
por Adam 08.05.2012 / 23:52

3 respostas

2

Aqui está um exemplo onde você verá os passos para esse processo (parece que você está perdendo a diretiva apxs2 e o LoadModule do apache em nossa pergunta):

#!/bin/sh 
 # #################################################### 
 # PHP INSTALLATION SHELL for compiled version
 # By Hornetbzz - 17/09/2010 
 # localhost stands for the machine to be installed 
 # remote host stands for the machine to be duplicated 
 # chmod 700 and run as root 
 # #################################################### 

# ########################
# USER CONTROL
# ########################
[[ $(whoami) != "root" ]] && echo "pls run as root" && exit

# ########################
# SOURCE DIR
# ########################
SRC=/usr/local/src

# ########################
# latest php tarball
# check the most recent mtime tarball in the source directory (already downloaded)
# ########################
LOCAL_SRC_INSTALLED=$(ls -t *tar.gz $SRC | head -1)
echo "latest php tarball: $LOCAL_SRC_INSTALLED"
[[ ! -z $LOCAL_SRC_INSTALLED ]] && LOCAL_SRC_INSTALLED=$SRC/$LOCAL_SRC_INSTALLED
echo "latest php tarball (full path): $LOCAL_SRC_INSTALLED"


# get source files from mirror if no tarball already existing in the src directory
if [ -z $LOCAL_SRC_INSTALLED ];then
    echo "No php tarball found => it will be downloaded from mirror" && exit
    MIRROR="fr.php.net"
    VERSION="5.3.3"
    cd $SRC
    wget http://$MIRROR/get/php-$VERSION.tar.gz/from/this/mirror
    # tarball checksum : not done
    mv mirror "php-$VERSION.tar.gz"
    # get the last accessed tarball file
    LOCAL_SRC_INSTALLED=$SRC/"php-$VERSION.tar.gz"
fi

# name with full path
echo "checkpoint: $LOCAL_SRC_INSTALLED"

# ########################
# PROCEED to installation
# ########################
 if [ -f $LOCAL_SRC_INSTALLED ];then

     echo "Local PHP sources : $LOCAL_SRC_INSTALLED"

     # change directory - keep this even if already done -
     cd $SRC

     # untar
     tar xzf $LOCAL_SRC_INSTALLED

    # get the new dir name created on the localhost after untar
    echo "basename: " && echo $(basename $LOCAL_SRC_INSTALLED)
    NEW_DIR_NAME=$(basename $LOCAL_SRC_INSTALLED | sed -e "s/\.tar\.gz$//")

     echo "Info: New src directory created: $NEW_DIR_NAME" 

     # change directory 
     cd /usr/local/src/$NEW_DIR_NAME 

     [[ -f "config.nice ]] && cp config.nice config.nice.original

        # NOTA: copying this shell, you may have to escape each included quote by a backslash, like this \"
         echo -e " 
     # build: import remote host config.nice into the localhost installation shell
    # Created by configure
    './configure' \
    '--prefix=/usr/local/php' \
    '--with-apxs2=/usr/bin/apxs2' \
    '--enable-embed' \
    '--with-config-file-path=/usr/local/php/php.ini' \
    '--with-config-file-scan-dir=/usr/local' \
    '--with-gd=shared' \         # NOTA: remove "=shared" if you install a bundled lib as explained in my wiki page
     all other options there
    '--enable-mbstring' \
    "$@"
" > config.nice

        make clean
       ./config.nice
    make 
    make install
        echo -e "LoadModule php5_module /usr/local/php/lib/libphp5.so \n
                 AddType application/x-httpd-php .php \n
                 PHPIniDir "/usr/local/php \n" >> /etc/apache2/httpd.conf

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

else 
    echo "PHP source : local tarball not found in $SRC" 
fi 
    
por 09.05.2012 / 01:33
2

Você instalou apenas a versão da linha de comando. Você não instalou o módulo do apache. Você precisa adicionar o seguinte

--with-apxs2

Verifique se você tem apache2-dev instalado

    
por 09.05.2012 / 00:13
0

Dê uma olhada no seu httpd.conf file / dir e dê uma olhada nas suas declarações LoadModule . Não é obrigado a ser um ainda apontando para o php 5.3.

    
por 09.05.2012 / 00:13