在 XAMPP for linux 中升级 PHP?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/8740817/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-06 03:55:40  来源:igfitidea点击:

Upgrading PHP in XAMPP for linux?

phplinuxxampp

提问by Imran Omar Bukhsh

How can I upgrade my current php (only) in xampp?

如何在 xampp 中升级我当前的 php(仅)?

I need to upgrade from 5.3.1 to 5.4.0

我需要从 5.3.1 升级到 5.4.0

采纳答案by Shaharia Azam

Now XAMPPis supporting PHP 5.4and PHP 5.5. You can now download installer of your required version of PHP from http://www.apachefriends.org/en/xampp-linux.html

现在XAMPP支持PHP 5.4PHP 5.5。您现在可以从http://www.apachefriends.org/en/xampp-linux.html下载所需 PHP 版本的安装程序

Thanks.

谢谢。

回答by altern

Download PHP's source code and extract it in /usr/src:

下载 PHP 的源代码并将其解压缩到 /usr/src 中:

cd ~/downloads
wget http://snaps.php.net/php5.4-latest.tar.gz
tar -xzf php5.4-latest.tar.gz 
sudo mv php5.4 /usr/src/php-5.4

You need to find the configuration of already installed version , so you can use it and install the new version with the exact same configuration

您需要找到已安装版本的配置,以便您可以使用它并安装具有完全相同配置的新版本。

/opt/lampp/bin/php --info | grep "Configure Command"

You should see something like this as result :

你应该看到这样的结果:

./configure '--prefix=/opt/lampp' '--with-apxs2=/opt/lampp/bin/apxs' '--with-config-file-path=/opt/lampp/etc' '--with-mysql=mysqlnd' '--enable-inline-optimization' '--disable-debug' 

Actually, list should probably be much more longer. Copy and store it as you will need to use it as a whole later.

实际上,列表可能应该更长。复制并存储它,因为您以后需要将其作为一个整体使用。

Make a backup of the current installation, in case if anything goes wrong

备份当前安装,以防万一出现问题

sudo cp -r /opt/lampp /opt/lampp.bak

Now that you have configuration options, review it and then use it to compile the new version.

既然您有配置选项,请查看它,然后使用它来编译新版本。

cd /usr/src/php-5.4/
./configure  --prefix=/opt/lampp --with-apxs2=/opt/lampp/bin/apxs --with-config-file-path=/opt/lampp/etc --with-mysql=mysqlnd --enable-inline-optimization --disable-debug 
make 
make install

Run /opt/lampp/bin/php -vin order to make sure you have correct php version installed. It should be 5.4.0 Beta.

运行/opt/lampp/bin/php -v以确保您安装了正确的 php 版本。它应该是 5.4.0 Beta。

回答by WindSaber

Just want to complement @altern answer....

只是想补充@altern 的答案....

When I tried all the indications exactly in line of

当我完全按照

make install

I had an error in the output

我在输出中有错误

Installing PHP SAPI module:       apache2handler
/opt/lampp/build/instdso.sh SH_LIBTOOL='/opt/lampp/build/libtool' libphp7.la /opt/lampp/modules
/opt/lampp/build/libtool --mode=install install libphp7.la /opt/lampp/modules/
/opt/lampp/build/libtool: 3215: /opt/lampp/build/libtool: install_prog+=install: not found
/opt/lampp/build/libtool: 3235: /opt/lampp/build/libtool: files+= libphp5.la: not found
libtool: install: you must specify an install program
libtool: install: Try `libtool --help --mode=install' for more information.
apxs:Error: Command failed with rc=65536

After looking for information to solve, I found a japanese link: http://d.hatena.ne.jp/Kenji_s/touch/searchdiary?word=*%5BUbuntu%5D

找资料解决后,找到了一个日文链接:http: //d.hatena.ne.jp/Kenji_s/touch/searchdiary?word=*% 5BUbuntu%5D

What I did to solve it after trying to understand this japanese solution was simply:

在尝试理解这个日本解决方案后,我为解决它所做的很简单:

sudo nano /opt/lampp/build/libtool

And when the editor was opened I changed the first line, instead of:

当编辑器打开时,我更改了第一行,而不是:

#! /bin/sh

I wrote:

我写:

#! /bin/bash

After that I tried again

之后我又试了一次

make install

And voila it compiled!

瞧,它编译好了!

Hope It helps someone

希望它可以帮助某人