samwell
samwell

Reputation: 2797

How to install PHP extensions on nginx?

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?

Upvotes: 16

Views: 62373

Answers (6)

Xeoncross
Xeoncross

Reputation: 57184

Since you are using Nginx - that must mean you are running PHP with PHP-FPM.

After you install stuff you need to:

sudo /etc/init.d/php-fpm restart 

or

service php5-fpm restart

in newer ubuntu versions

so that PHP will pickup the new extensions.

Upvotes: 35

Lee Void
Lee Void

Reputation: 11

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.

Upvotes: 1

Alex Pogiba
Alex Pogiba

Reputation: 622

I encountered the same problem with making sudo apt-get install php5-gd to work. Console output suggested to do sudo 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.

Upvotes: 0

Dominic Woodman
Dominic Woodman

Reputation: 839

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 to conf.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.

cd /etc/php5/fpm
sudo ln -s /etc/php5/conf.d /etc/php5/fpm/conf.d

Upvotes: 4

Augusto
Augusto

Reputation: 2222

If your web server setup is in order, only install the php gd extension and restart php scripting interpreter and web server.

sudo apt-get install php5-gd
sudo /etc/init.d/php-fastcgi stop
sudo /etc/init.d/php-fastcgi start
sudo /etc/init.d/nginx stop
sudo /etc/init.d/nginx start

Here's a great LEMP tutorial http://library.linode.com/web-servers/nginx/php-fastcgi/ubuntu-10.04-lucid

Upvotes: 4

Jacob Fike
Jacob Fike

Reputation: 1001

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:

extension=gd.so

Upvotes: 3

Related Questions