在带有 Apache 2 模块的 Ubuntu 14 上从源安装 PHP 5.3.29 [英] Installing PHP 5.3.29 from Sources on Ubuntu 14 with Apache 2 Module
问题描述
我在 Ubuntu 14 和 Apache 2 上分别成功安装了 PHP 5.3.29.
I successfully installed PHP 5.3.29 on Ubuntu 14 with Apache 2 separately.
我使用以下方法安装了 PHP:
I installed PHP with the following method:
sudo -i
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
make
make install
然而,PHP 和 Apache 似乎没有任何联系.这意味着我已经安装了 Apache 和 PHP,但 Apache 不运行 PHP.
However, PHP and Apache do not seem to have any linkage. That means I have installed both Apache and PHP, but Apache does not run PHP.
我尝试过的:
来自此站点:https://docs.moodle.org/28/en/Compiling_PHP_from_source
配置Apache和PHP",它要求我在Apache配置文件中添加:
From this site: https://docs.moodle.org/28/en/Compiling_PHP_from_source
"Configuring Apache and PHP", it asked me to add this in the Apache configuration file:
LoadModule php5_module modules/libphp5.so
LoadModule php5_module modules/libphp5.so
但是,我没有libphp5.so"模块.
However, I do not have "libphp5.so" module.
有些人让我运行这个:
sudo apt-get install libapache2-mod-php5
但是运行该命令后,它为我安装了 PHP 5.5.9,但我需要 PHP 5.3.29.
But after running the command, it installed PHP 5.5.9 for me, but I need PHP 5.3.29.
如何让 Apache 运行我安装的 PHP 5.3.29?
How can I make Apache run PHP 5.3.29 which I have installed?
推荐答案
这对我有用:
sudo -s
下载源
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
安装所有必要的依赖
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
编译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
激活 Apache 模块
a2enmod cgi fastcgi actions
service apache2 restart
创建相应的配置文件
vi /etc/apache2/php53.conf
插入:
#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
创建环境脚本以启动附加的 PHP 版本
vi /usr/lib/cgi-bin/php53-cgi
插入:
#!/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
配置 Apache 2 的虚拟主机
Include php53.conf
ServerName example.org
DocumentRoot /var/www/sites/example.org
Options Indexes FollowSymLinks MultiViews
AllowOverride all
Require all granted
最后,重启...
service apache2 restart
来源:https://erdfisch.de/en/multiple-版本-php-apache-under-linux
这篇关于在带有 Apache 2 模块的 Ubuntu 14 上从源安装 PHP 5.3.29的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!