For years now, WordPress and PHP have been best buddies. Despite WordPress technically being a sub-framework built on top of PHP (with its own unique coding style, hooks, filters, and so forth), its reliance on underlying PHP functions has always been critical to steering WordPress development.
WordPress core makes use of PHP extensions. If the preferred extension is missing WordPress will either have to do more work to do the task the module helps with or, in the worst case, will remove functionality.
— WordPress Handbook
Most quality web hosting companies should already know what PHP extensions to install in order for WordPress to function optimally. But in some cases, a web host is using severely outdated documentation. In other cases, you might be setting up your own web server, such as a LEMP stack, and you need to know what PHP extensions to install. Because LittleBizzy is built on top of SlickStack, all of these “required” and “recommended” PHP extensions are already installed for our hosting clients. You can also check out the free SlickStack script if you want a quick and easy way to setup your own WordPress server that works out-of-the-box.
Keep in mind that on Ubuntu servers when you
install php7.2 it includes the following by default (and if you’re on Ubuntu 18.04 then you can just use
install php instead):
libapache2-mod-php7.2 php7.2 php7.2-cli php7.2-common php7.2-json php7.2-opcache php7.2-readline
If you are installing a LEMP (Nginx) server and have no need for Apache junk, use
install php-fpm instead:
php7.2-cli php7.2-common php7.2-fpm php7.2-json php7.2-opcache php7.2-readline
Aah… that looks much, much better :)
So now let’s compare the recommended list of PHP extensions with a few things. First, is it installed already for us? Second, is it really necessary? Here’s the official list of recommended PHP extensions:
curl – Performs remote request operations. dom – Used to validate Text Widget content and to automatically configuring IIS7+. exif – Works with metadata stored in images. fileinfo – Used to detect mimetype of file uploads. hash – Used for hashing, including passwords and update packages. json – Used for communications with other servers. mbstring – Used to properly handle UTF8 text. mysqli – Connects to MySQL for database interactions. libsodium – Validates Signatures and provides securely random bytes. openssl – Permits SSL-based connections to other hosts. pcre – Increases performance of pattern matching in code searches. imagick – Provides better image quality for media uploads. See WP_Image_Editor is incoming! for details. Smarter image resizing (for smaller images) and PDF thumbnail support, when Ghost Script is also available. xml – Used for XML parsing, such as from a third-party site. zip – Used for decompressing Plugins, Themes, and WordPress update packages.
WordPress.org also lists the following as fallback/optional extensions:
filter – Used for securely filtering user input. gd – If Imagick isn’t installed, the GD Graphics Library is used as a functionally limited fallback for image manipulation. iconv – Used to convert between character sets. mcrypt – Generates random bytes when libsodium and /dev/urandom aren’t available. simplexml – Used for XML parsing. xmlreader – Used for XML parsing. zlib – Gzip compression and decompression.
Therefore rather than simply copying the recommended list from WordPress.org, which is aimed more at PHP 5.6 and a general array of operating systems, we’ve researched extensively to produce the below list of PHP extensions you should install on PHP 7+ servers with a focus on Ubuntu servers.
As you can see, knowing which PHP extensions to install for your WordPress stack depends on your operating system, PHP version, and whether you are using Nginx (alone) and/or Apache as your server. So the solution will be different in each case — however, if you are using LEMP (Nginx) with PHP 7.2, such as using our free SlickStack script, then here’s our final recommendations and comments on PHP 7.2 extensions:
bcmath cli -- installed alongside PHP-FPM but not really used (included as part of php-fpm installation) common -- several general sub-modules (included in php-fpm installation) curl -- for remote server requests dev -- dom -- for validating some WP textual content (included in the xml extension now) exif -- not recommended for security and privacy reasons fileinfo -- filter -- hash -- fpm -- performant PHP engine used by LEMP/Nginx servers (included in php-fpm installation) gd -- backup WordPress image extension iconv -- imagick -- preferred WordPress image extension for media resizing, thumbnails, etc. json -- for remote server communication (included in php-fpm installation) mbstring -- for handling UTF8 text mcrypt -- mysql -- "improved" (mysqli) MySQL interface merged into this Ubuntu package libsodium -- openssl -- pcre -- pear -- opcache -- Zend OPcode caching for PHP scripts (included in php-fpm installation) readline -- used for CLI related functions (included as part of php-fpm installation) simplexml -- not needed if you have xml module installed soap xml -- for various XML parsing xmlreader -- not needed if you have xml module installed zip
zlib -- not recommended (gzip should be done by the server)
Thus you’ll find the following install command in SlickStack for Ubuntu 18.04 servers:
sudo apt install php7.2-fpm php7.2-bcmath php7.2-curl php7.2-gd php7.2-imagick php7.2-json php7.2-mbstring php7.2-mysql php7.2-soap php7.2-xml php7.2-zip
Or another way to say this in Ubuntu 18.04:
sudo apt install php-fpm php-bcmath php-curl php-gd php-imagick php-json php-mbstring php-mysql php-soap php-xml php-zip
https://devanswers.co/installing-php-nginx-ubuntu-18-04/Last modified: 8 Jul, 2019
"After being hosted on GoDaddy for years, I didn't realize how negatively it was impacting my search traffic. Soon after moving to LittleBizzy, my homepage went from page 3 on Google to #1 world-wide for my target market, and I also reached the top 3 on Google Maps, with no additional SEO work."Juliette S.
"Before moving to LittleBizzy, whenever our news website was featured on the Drudge Report, it often slowed to a crawl or even froze up during big traffic spikes. Now, that never happens anymore, and we've been able to focus on publishing more articles instead of worrying about our web hosting."Steve G.
"The research by Amazon is definitely true, because our slow WooCommerce store was bleeding sales. After LittleBizzy stabilized our performance and moved us closer to our target customers, we saw a measurable improvement in shopping cart checkouts, esp. during holidays... much better!"Mohammed H.
No contracts, free migration, and free SSL forever. What are you waiting for? Order Hosting Now.
WordPress Gossip, Technical SEO News, And Other Goodies.
Free. Unsubscribe anytime.