如何在nginx上安装PHP扩展?
我最近发现了 NginX,并决定在我的服务器上尝试一下。我正在运行 NginX 并且能够提供 PHP 和 HTML 文件。但现在我想尝试安装drupal。当尝试安装它并检查要求时,我被一项要求阻止了。
PHP 扩展已禁用
Drupal 要求您启用以下列表中的 PHP 扩展(有关详细信息,请参阅系统要求页面):
gd
我尝试通过执行 apt-get install php5-gd
来安装 gd,它说它已经安装了。所以我创建了一个 phpinfo() 文件,并检查 gd 是否已启用,但我找不到它。这与 NginX 或 PHP 有关系吗?我该怎么做才能解决这个问题?
I recently discovered NginX, and decided to try it out on my server. I have NginX running and able to serve PHP and HTML files. But now I want to try to install drupal. When trying to install it and check the requirements, I am stopped by one requirement.
PHP extensions Disabled
Drupal requires you to enable the PHP extensions in the following list (see the system requirements page for more information):
gd
I have tried to install gd by doing apt-get install php5-gd
, and it says it is already installed. So I created a phpinfo()
file, and checked to see if gd was enabled and I wasn't able to find it. Does this have to do with NginX or PHP? What do I do to fix this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(6)
由于您使用的是 Nginx - 这必定意味着您正在使用 PHP-FPM 运行 PHP。
安装完之后,您需要:
或者
在较新的 ubuntu 版本中
,以便 PHP 能够获取新的扩展。
Since you are using Nginx - that must mean you are running PHP with PHP-FPM.
After you install stuff you need to:
or
in newer ubuntu versions
so that PHP will pickup the new extensions.
如果您的 Web 服务器设置正常,只需安装 php gd 扩展并重新启动 php 脚本解释器和 Web 服务器。
这是一个很棒的 LEMP 教程 http://library.linode。 com/web-servers/nginx/php-fastcgi/ubuntu-10.04-lucid
If your web server setup is in order, only install the php gd extension and restart php scripting interpreter and web server.
Here's a great LEMP tutorial http://library.linode.com/web-servers/nginx/php-fastcgi/ubuntu-10.04-lucid
对于未来的我,如果我忘记了这一点。
如果您一直在摆弄
/etc/php/fpm
那么您可能不小心丢失了conf.d
的符号链接,这意味着 gd 和 PDO 加载文件将无法加载不能用 FPM 启动。如果您只使用 PHP5-FPM 附带的基本配置,这将是一个问题。如果您有自定义配置,您可以将文件包含在不同的位置。
解决方案:重新创建符号链接。
For future me if I forget this.
If you've been messing around with
/etc/php/fpm
then you may have accidentally lost the symlink toconf.d
which means the gd and PDO load files won't be booted with FPM.This will be an issue if you're just using the basic config that comes with PHP5-FPM. If you have a custom config you may included the files in a different place.
Solution: Recreate the sym-link.
PHP 扩展仅与 PHP 有关。您选择的网络服务器(apache、nginx 等)不会影响它们。很可能您只需要启用 gd 扩展即可。如果您使用的是 Ubuntu,请检查 /etc/php5/conf.d 文件夹并添加包含以下行的 gd.ini:
PHP extensions have only to do with PHP. Your choice of webserver (apache, nginx, etc) do not affect them. Most likely you just need to enable the gd extension. If you are on Ubuntu, check /etc/php5/conf.d folder and add a gd.ini with the following line:
如果您使用的是centos 7并且找不到/etc/init.d/php-fpm,您可以尝试
systemctl restart php-fpm
,这对我有用。if you are using centos 7 and you can't find /etc/init.d/php-fpm, you may try
systemctl restart php-fpm
, that worked for me.我在使用 sudo apt-get install php5-gd 时遇到了同样的问题。控制台输出建议执行
sudo apt-get update
。只是对所有软件包进行基本更新。更新后,我运行 sudo apt-get install php5-gd ,它为我完成了所有繁重的工作,包括重新启动 php5-fpm 并正确安装其间的所有内容。
I encountered the same problem with making
sudo apt-get install php5-gd
to work. Console output suggested to dosudo apt-get update
. Just basic updating on all your packages.After updating, I run
sudo apt-get instal php5-gd
and it did all heavy lifting for me, including restarting php5-fpm and correctly installing everything in between.