Installing PHP 5.3.29 from Sources on Ubuntu 14 with Apache 2 Module

后端 未结 4 917
醉话见心
醉话见心 2020-12-30 05:14

I successfully installed PHP 5.3.29 on Ubuntu 14 with Apache 2 separately.

I installed PHP with the following method:

sudo -i
wget http://in1.php.net         


        
相关标签:
4条回答
  • 2020-12-30 06:00

    Wittich's answer is fabulous! I used it in order to replace php 5.1 with php 5.6 on my unix website. Unlike Wittich, I wasn't trying to get two versions running simultaneously; I was simply trying to do an upgrade from an older version of php that was integrated with apache to a newer version that would run from cgi.

    For some reason, several of Wittich's commands (such as the SetHandler command) prevented Apache from loading after I tried them. I ended up having to simplify his answer so that Apache would run correctly. I made 6 changes in Wittich's procedures:

    1. I used yum instead of apt-get because apt-get wouldn't run on my Unix system.

    2. Since I was installing php 5.6 not php 5.3, I changed all instances of "php53" to "php56" in the configure command's switches. This was not necessary for everything to work, but it will help you understand my paths below:

    3. In one of my httpd configuration folders (/etc/httpd/conf.d), I found a file that was already set up for a cgi implementation of php (php_cgi.conf). Its contents were:

    scriptAlias /phppath/ "/var/www/cgi-bin/cgi_wrapper/"
    Action php-script /phppath/cgi_wrapper

    The contents and existence of this file let me skip or change several of Wittich's steps. I neither created php53-cgi, nor did I create php53.conf.

    1. Instead of creating php53-cgi, I replaced the contents of the existing file (/var/www/cgi-bin/cgi-wrapper/cgi-wrapper) with the contents suggested for php53-cgi. Due to the other lines preventing apache from rebooting properly, I ended up with the contents of that file just being his first and last lines (without the slash before the number sign):
    \#!/bin/sh
    exec /usr/bin/php56/php-cgi
    1. Instead of creating php53.conf, I replaced a single command in the php.conf file (/etc/httpd/conf.d/php.conf). I changed the add-handler for php command so that it now reads:
    AddHandler php-script .php
    1. I didn't change the httpd.conf files at all since my goal was simply to replace the old php, not create different versions of php that would run on different virtual hosts. However, I believe that I could have set up my websites to run old version and the new one in different directories, simply by changing the httpd.conf file so that the old AddHandler would appear in some directories while the new AddHandler would appear in others.

    So, in summary, it is easy to convert Wittich's answer into a way to upgrade from an older apache based php version to a newer cgi-based version if you have an existing php_cgi.conf file that you can hijack and use as a guide.

    I found a posting by David Brogdon to be a good complement to Wittich's answer for those who are new to the configure, make, and make install commands:

    http://www.onlamp.com/pub/a/php/2000/11/17/php_admin.html

    I searched the Internet for hours and never found anything as helpful as Brogdon's post and Wittich's answer. Wittich's answer must have worked perfectly on his Unix system, but I had to modify it a bit in order to get it to work on mine.

    0 讨论(0)
  • 2020-12-30 06:07

    I do this:

    # wget wget http://in1.php.net/distributions/php-5.3.29.tar.bz2
    # tar -xvf php-5.3.29.tar.bz2
    # cd php-5.3.29
    # ./configure --with-apxs2=/usr/local/apache2/bin/apxs
    # make
    # sudo make install
    # sudo cp php.ini-development /usr/local/lib/php.ini.
    

    Then change php.ini. Change the option,

    short_open_tag = Off
    

    to

    short_open_tag = On
    

    Check and modify the httpd.conf module php5:

    LoadModule php5_module modules/libphp5.so
    

    Add in httpd.conf:

    <FilesMatch \.php$>
        SetHandler application/x-httpd-php
    </FilesMatch>
    

    Restart apache2, default install in: /usr/local/apache2

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

    Check phpinfo is now read in your Apache installation like:

    http://localhost
    
    0 讨论(0)
  • 2020-12-30 06:19

    This works for me:

    sudo -s
    

    Download source

    mkdir /usr/local/src/php5-build
    cd /usr/local/src/php5-build
    wget -O php-5.3.29.tar.gz http://de1.php.net/get/php-5.3.29.tar.gz/from/this/mirror
    tar -xzf php-5.3.29.tar.gz
    cd php-5.3.29
    

    Install all necessary dependencies

    apt-get install apache2 php5 php5-common php5-cli php5-mysql php5-gd php5-mcrypt php5-curl libapache2-mod-php5 php5-xmlrpc mysql-server mysql-client libapache2-mod-fastcgi
    
    apt-get install build-essential php5-dev libbz2-dev libmysqlclient-dev libxpm-dev libmcrypt-dev libcurl4-gnutls-dev libxml2-dev libjpeg-dev libpng12-dev
    

    Compile PHP

    ./configure --prefix=/usr/share/php53 --datadir=/usr/share/php53 --mandir=/usr/share/man --bindir=/usr/bin/php53 --includedir=/usr/include/php53 --sysconfdir=/etc/php53/apache2 --with-config-file-path=/etc/php53/apache2 --with-config-file-scan-dir=/etc/php53/conf.d --enable-bcmath --with-curl=shared,/usr --with-mcrypt=shared,/usr --enable-cli --with-gd --with-mysql --with-mysqli --enable-libxml --enable-session --enable-xml --enable-simplexml --enable-filter --enable-inline-optimization --with-jpeg-dir --with-png-dir --with-zlib --with-bz2 --with-curl --enable-exif --enable-soap --with-pic --disable-rpath --disable-static --enable-shared --with-gnu-ld --enable-mbstring
    make && make install
    

    Activate Apache module

    a2enmod cgi fastcgi actions
    service apache2 restart
    

    Create corresponding configuration file

    vi /etc/apache2/php53.conf
    

    Insert:

    #Include file for virtual hosts that need to run PHP 5.3
    
    
    SetHandler application/x-httpd-php5
    
    ScriptAlias /php53-cgi /usr/lib/cgi-bin/php53-cgi
    Action application/x-httpd-php5 /php53-cgi
    AddHandler application/x-httpd-php5 .php
    

    Create environment script to start the additional PHP version

    vi /usr/lib/cgi-bin/php53-cgi
    

    Insert:

    #!/bin/sh
    PHPRC="/etc/php53/apache2/"
    export PHPRC
    PHP_FCGI_CHILDREN=4
    export PHP_FCGI_CHILDREN
    PHP_FCGI_MAX_REQUESTS=5000
    export PHP_FCGI_MAX_REQUESTS
    exec /usr/bin/php53/php-cgi
    

    Configure Apache 2's virtual hosts

    Include php53.conf
    ServerName example.org
    DocumentRoot /var/www/sites/example.org
    
    Options Indexes FollowSymLinks MultiViews
    AllowOverride all
    Require all granted
    

    Last, restart...

    service apache2 restart
    

    Source: https://erdfisch.de/en/multiple-versions-php-apache-under-linux

    0 讨论(0)
  • 2020-12-30 06:21

    This works for me on a scratch Ubuntu 14.04:

    Manual installation

    Update the systems packages

    1. apt-get update

    2. apt-get upgrade -y

    Install the dependencies and prepare environment

    1. apt-get install -y build-essential libxml2-dev apache2 apache2-dev

    2. echo "export PATH=/usr/local/bin:/usr/local/sbin:$PATH" >> ~/.bashrc

    3. apt-get install -y libapache2-mod-php5 --no-install-recommends

    Download PHP 5.3.29

    1. apt-get install -y wget && cd /tmp && wget http://php.net/distributions/php-5.3.29.tar.bz2

    Unzip and configure apache's module apxs2

    1. tar -xvf php-5.3.29.tar.bz2 && cd php-5.3.29 && ./configure --with-apxs2=/usr/bin/apxs2

    Install it

    1. make && make install

    Check if works

    1. service apache2 restart && php -v
    0 讨论(0)
提交回复
热议问题