Linux 如何在 CentOS 6.2 上安装 PHP mbstring
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/10278561/
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
How to install PHP mbstring on CentOS 6.2
提问by alioygur
How do I install mbstring with PHP on CentOS 6.2
如何在 CentOS 6.2 上使用 PHP 安装 mbstring
I've tried:
我试过了:
$ sudo yum install php-mbstring
Loaded plugins: fastestmirror, security
Loading mirror speeds from cached hostfile
* base: mirror.net.cen.ct.gov
* extras: centos.aol.com
* updates: mirrors.seas.harvard.edu
Setting up Install Process
No package php-mbstring available.
Error: Nothing to do
But no packages were found?
但是没有找到包?
采纳答案by Tor P
do the following:
请执行下列操作:
sudo nano /etc/yum.repos.d/CentOS-Base.repo
under the section updates
, comment out the mirrorlist line (put a #
in front of the line), then on a new line write:
在 section 下updates
,注释掉 mirrorlist 行(#
在该行前面放一个),然后在新行上写:
baseurl=http://centos.intergenia.de/$releasever/updates/$basearch/
now try:
现在尝试:
yum install php-mbstring
(afterwards you'll probably want to uncomment the mirrorlist and comment out the baseurl)
(之后您可能想要取消对镜像列表的注释并注释掉 baseurl)
回答by Tor P
yum install php-mbstring (as per http://php.net/manual/en/mbstring.installation.php)
yum 安装 php-mbstring(根据http://php.net/manual/en/mbstring.installation.php)
I think you have to install the EPEL repository http://fedoraproject.org/wiki/EPEL
我认为您必须安装 EPEL 存储库http://fedoraproject.org/wiki/EPEL
回答by user1934863
If you have cPanel hosting you can use Easy Apache to do this through shell. These are the steps.
如果您有 cPanel 托管,您可以使用 Easy Apache 通过 shell 执行此操作。这些是步骤。
- Type the Easy Apache PathType the path for Easy Apache
root@vps#### [~]# /scripts/easyapache
- Do not say yes to the "cPanel update available".
- Continue through the screens with defaults till you get to the "Exhaustive options list".
- Page down till you see the Mbstring extension listed and select it.
- Continue through the Steps and Save the Apache PHP build.
- 输入 Easy Apache PathType the path for Easy Apache
root@vps#### [~]# /scripts/easyapache
- 不要对“cPanel 更新可用”说是。
- 继续浏览具有默认设置的屏幕,直到您进入“详尽的选项列表”。
- 向下翻页,直到您看到列出的 Mbstring 扩展名并选择它。
- 继续执行步骤并保存 Apache PHP 构建。
Apache and PHP will now rebuild to include the mbstring extension. Wait for the process to finish ~10 to 30 minutes. Once the process is finished you should see the Mbstring extension in the phpinfo now.
Apache 和 PHP 现在将重建以包含 mbstring 扩展。等待该过程完成约 10 到 30 分钟。该过程完成后,您现在应该在 phpinfo 中看到 Mbstring 扩展名。
For more detailed steps see the article Installing the mbstring extension with Easy Apache
有关更多详细步骤,请参阅 使用 Easy Apache 安装 mbstring 扩展一文
回答by Cees Timmerman
As yum install php-mbstring
then httpd -k restart
didn't do it for me, I think these optionsshould be compiled, as documented here:
由于yum install php-mbstring
当时httpd -k restart
没有为我做,我认为应该编译这些选项,如此处所述:
Now, configure and build PHP. This is where you customize PHP with various options, like which extensions will be enabled. Run ./configure --help for a list of available options. In our example we'll do a simple configure with Apache 2 and MySQL support.
If you built Apache from source, as described above, the below example will match your path for apxs, but if you installed Apache some other way, you'll need to adjust the path to apxs accordingly. Note that some distros may rename apxs to apxs2.
cd ../php-NN ./configure --with-apxs2=/usr/local/apache2/bin/apxs --with-mysql --enable-mbstring make make install
If you decide to change your configure options after installation, you'll need to re-run the configure, make, and make install steps. You only need to restart apache for the new module to take effect. A recompile of Apache is not needed.
Note that unless told otherwise, 'make install' will also install PEAR, various PHP tools such as phpize, install the PHP CLI, and more.
现在,配置和构建 PHP。这是您使用各种选项自定义 PHP 的地方,例如将启用哪些扩展。运行 ./configure --help 以获取可用选项列表。在我们的示例中,我们将使用 Apache 2 和 MySQL 支持进行简单的配置。
如果您从源代码构建 Apache,如上所述,下面的示例将匹配您的 apxs 路径,但如果您以其他方式安装 Apache,则需要相应地调整 apxs 的路径。请注意,某些发行版可能会将 apxs 重命名为 apxs2。
cd ../php-NN ./configure --with-apxs2=/usr/local/apache2/bin/apxs --with-mysql --enable-mbstring make make install
如果您决定在安装后更改配置选项,则需要重新运行 configure、make 和 make install 步骤。新模块只需要重启apache即可生效。不需要重新编译 Apache。
请注意,除非另有说明,否则“make install”还将安装 PEAR、各种 PHP 工具(例如 phpize)、安装 PHP CLI 等。
Though this pagesays it's optional:
虽然这个页面说它是可选的:
--enable-mbstringAllows multibyte character string support. This is optional, as slower custom code will be used if not available.
--enable-mbstring允许多字节字符串支持。这是可选的,因为如果不可用,将使用较慢的自定义代码。
回答by Andres SK
*Make sure you update your linux box first
*确保你先更新你的linux box
yum update
In case someone still has this problem, this is a valid solution:
如果有人仍然有这个问题,这是一个有效的解决方案:
centos-release : rpm -q centos-release
centos-release : rpm -q centos-release
Centos 6.*
Centos 6.*
wget http://download.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm
rpm -ivh epel-release-6-8.noarch.rpm
wget http://rpms.famillecollet.com/enterprise/remi-release-6.rpm
rpm -Uvh remi-release-6*.rpm
Centos 5.*
Centos 5.*
wget http://ftp.jaist.ac.jp/pub/Linux/Fedora/epel/5/x86_64/epel-release-5-4.noarch.rpm
rpm -ivh epel-release-5-4.noarch.rpm
wget http://rpms.famillecollet.com/enterprise/remi-release-5.rpm
rpm -Uvh remi-release-5*.rpm
Then just do this to update:
然后只需执行此操作即可更新:
yum --enablerepo=remi upgrade php-mbstring
Or this to install:
或者这样安装:
yum --enablerepo=remi install php-mbstring
回答by Bren1818
If none of the above help you out, and you have the option, try obtaining one of the rpm files eg:
如果以上方法都没有帮助您,并且您可以选择,请尝试获取其中一个 rpm 文件,例如:
wget http://rpms.famillecollet.com/enterprise/6/remi/x86_64/php-mbstring-5.4.45-2.el6.remi.x86_64.rpm
wget http://rpms.famillecollet.com/enterprise/6/remi/x86_64/php-mbstring-5.4.45-2.el6.remi.x86_64.rpm
then using rpm, install it ignoring the depenecies like so:
然后使用 rpm,安装它忽略像这样的依赖:
rpm -i --nodeps php-mbstring-5.4.45-2.el6.remi.x86_64.rpm
rpm -i --nodeps php-mbstring-5.4.45-2.el6.remi.x86_64.rpm
Hope that helps out.
希望有所帮助。
回答by Saud Alfadhli
Please check your /etc/yum.conf
file, maybe it is exclude php
packages.
请检查您的/etc/yum.conf
文件,可能是排除php
包。
You should remove php*
from this line so you can download php-*
packages:
您应该php*
从此行中删除,以便您可以下载php-*
软件包:
exclude= courier* dovecot* exim* filesystem httpd* mod_ssl* mydns* php*
It's seems your server having some scripts like cPanel
您的服务器似乎有一些像 cPanel 这样的脚本
回答by Sarvesh Acharya
- Find out php version -
php -v
- Search for php extensions available -
yum search php-
- Install using -
yum install ea-php56-php-mbstring.x86_64
- Then
httpd -k restart
- 找出php版本 -
php -v
- 搜索可用的 php 扩展 -
yum search php-
- 安装使用 -
yum install ea-php56-php-mbstring.x86_64
- 然后
httpd -k restart
Package name - ea-php-php-mbstring.x86_64
包名 - ea-php-php-mbstring.x86_64
回答by Kenny
I have experienced the same issue before. In my case, I needed to install php-mbstring extension on GoDaddy VPS server. None of above solutions did work for me.
我以前也遇到过同样的问题。就我而言,我需要在 GoDaddy VPS 服务器上安装 php-mbstring 扩展。以上解决方案都不适合我。
What I've found is to install PHP extensions using WHM (Web Hosting Manager) of GoDaddy. Anyone who use GoDaddy VPS server can access this page with the following address.
我发现使用 GoDaddy 的 WHM(虚拟主机管理器)安装 PHP 扩展。任何使用 GoDaddy VPS 服务器的人都可以通过以下地址访问此页面。
http://{Your_Server_IP_Address}:2087
http://{Your_Server_IP_Address}:2087
On this page, you can easily find Easy Apache software that can help you to install/upgrade php components and extensions. You can select currently installed profile and customize and then provision the profile. Everything with Easy Apache is explanatory.
在此页面上,您可以轻松找到可以帮助您安装/升级 php 组件和扩展的 Easy Apache 软件。您可以选择当前安装的配置文件并自定义,然后配置该配置文件。Easy Apache 的一切都是解释性的。
I remember that I did very similar things for HostGator server, but I don't remember how actually I did for profile update.
我记得我为 HostGator 服务器做了非常相似的事情,但我不记得我实际上是如何更新配置文件的。
Edit:When you have got the server which supports Web Hosting Manager, then you can add/update/remove php extensions on WHM. On godaddy servers, it's even recommended to update PHP ini settings on WHM.
编辑:当您获得支持 Web Hosting Manager 的服务器后,您可以在 WHM 上添加/更新/删除 php 扩展。在godaddy 服务器上,甚至建议更新WHM 上的PHP ini 设置。
回答by hoogw
None of above works for godaddy server centOS 6, apache 2.4, php 5.6
以上均不适用于 Godaddy 服务器 centOS 6、apache 2.4、php 5.6
Instead, you should
相反,你应该
Install the mbstring PHP Extension with EasyApache
使用 EasyApache 安装 mbstring PHP 扩展
check if you already have it by, putty or ssh
检查你是否已经拥有它,腻子或 ssh
php -m | grep mbstring
php -m | grep 字符串
[if nothing, means missing mbstring]
[如果没有,意味着缺少 mbstring]
Now you need to goto godaddy your account page,
现在你需要转到godaddy你的账户页面,
click manager server,
单击管理器服务器,
open whm ----- search for apache,
打开 whm ----- 搜索 apache,
open "easy apache 4"(my case)
打开“easy apache 4”(我的情况)
Now you need customize currently installed packages,
现在您需要自定义当前安装的软件包,
by
经过
click "customize" button on top line next to "currently installed package..."
单击“当前安装的软件包...”旁边顶行的“自定义”按钮
search mbstring,
搜索 mbstring,
click on/off toggle next to it.
单击它旁边的开/关切换。
click next, next, .... privision..done.
单击下一步,下一步,.... 优先权.. 完成。
Now you should have mbstring
现在你应该有 mbstring
by check again at putty(ssh)
通过在腻子(ssh)再次检查
php -m | grep mbstring [should see mbstring]
php -m | grep mbstring [应该看到mbstring]
or you can find mbstring at phpinfo() page
或者你可以在 phpinfo() 页面找到 mbstring