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

后端 未结 4 951
醉话见心
醉话见心 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.

提交回复
热议问题