Skip to main content

Installing php 5.3 on debian 7



It so happens that in a fresh Debian distribution you may need an old version of php, which is not part of a stable distribution branch. For example, php 5.3 for running a site on a server with Debian Jessie.

To fully resolve dependencies, in addition to php, install apache packages that are relevant to the previous stable distribution of Debian.



And the most important aspect: always make backups of all configuration files!

You may need to remove the already installed php packages from a stable branch, if you installed them earlier. This can be done with the command:


  # aptitude purge `dpkg -l |  grep php |  grep -w 5 |  awk '{print $ 2}' |  xargs` 

And we execute the same command for apache, respectively, replacing php with apache2.

Adding repositories

Packages for Debian Squeeze are currently available only in the archive repository . The list will look like this:


  deb http://archive.debian.org/debian/ squeeze main
 deb-src http://archive.debian.org/debian/ squeeze main

Add it with one command:

  # echo -e "deb http://archive.debian.org/debian/ squeeze main \ ndeb-src http://archive.debian.org/debian/ squeeze main"> /etc/apt/sources.list.d /php-squeeze.list 

And update the package cache.

  # aptitude update 

Package Prioritization

Next, create the file /etc/apt/preferences.d/php-apache-squeeze, where we write the following:

  Package: * php5 *
 Pin: release a = squeeze
 Pin: version 5.3 *
 Pin-Priority: 1000

 Package: * apache *
 Pin: release a = squeeze
 Pin: version 2.2 *
 Pin-Priority: 1000 

Two parameters deserve the most attention.

Pin: release a = squeeze - the distribution branch name is in bold.
Pin: version - version of the packages.

Save the file, install the packages in the standard way:

  # apt-get install apache2-mpm-prefork libapache2-mod-php5 php5-cli php5-mysql 

With this method, you do not need to freeze the packages, because during the system update, they will not be affected. It should also be noted that some packages may be missing from the old branches (php5-fpm for version 5.3).

PS Also this method is quite suitable for Ubuntu, but with the revision of the used repositories.



How do you rate the article?
Звёзд: 1Звёзд: 2Звёзд: 3Звёзд: 4Звёзд: 5 ( 1 rating, average: 5.00 out of 5)
Loading...

” 4 Comments “ Installing php 5.3 on Debian 7

  1. Good day!
    When installing libapache2-mod-php5, it displays the following:

    root @ funticket: ~ # apt-get install libapache2-mod-php5
    Reading package lists ... Done
    Building dependency tree
    Reading state information… Done
    Some packages could not be installed. This may mean that you have
    requested an unstable situation
    distribution
    or been moved out of incoming.
    The following information may help to resolve the situation:

    The following packages have unmet dependencies:
    init: PreDepends: systemd-sysv
    it is not going to be installed or
    upstart butt
    initscripts: Depends: sysv-rc or
    it is not going to be installed
    Recommended: e2fsprogs
    libapache2-mod-php5: Depends: libssl0.9.8 (> = 0.9.8m-1) but it isn’t going
    Depends: apache2-mpm-prefork (> 2.0.52)
    apache2-mpm-itk
    Depends: apache2.2-common but it is not going to be installed
    Depends: php5-common (= 5.3.3-7 + squeeze19)
    Depends: ucf
    Depends: it is not going to be installed
    Recommends: php5-cli
    libblkid1: Depends: libuuid1 (> = 2.16)
    libreadline6: Depends: readline-common
    logrotate: Depends: cron or
    anacron or
    cron-daemon
    Recommends: mailx
    E: Error, pkgProblemResolver :: Resolve generated by packages.
    I would be grateful for any help! It is impossible to run pehu in debian 8-ke

    1. At the moment, I can recommend using php5-cgi instead of the libapache2-mod-php5 module.

      First, put apache:

        aptitude install apache2-mpm-itk -t squeeze 

      Thus, you can not even install the old apache from the squeeze repository.

      Then put php:

        aptitude install php5-cgi php5-cli php5-mysql -t squeeze 

      Enable mod_actions:

        a2enmod actions 

      Add the following lines to the config of the virtual host in the apache config:

        ScriptAlias ​​/ local-bin / usr / bin
       AddType application / x-httpd-php .php .php3
       Action application / x-httpd-php / local-bin / php5-cgi 

Add a comment

Your email will not be published.