Categories
GIDBlog Learning Journal

Compress your PHP-FPM pages

Since the recent upgrade to gidblog.com, this web site is currently being hosted by various Docker containers. One of the Docker containers used is, of course, one derived from a Docker image like php:7-fpm-alpine.

I must confess that this is my first endeavour using PHP-FPM with Apache. All these years I have only been using the Apache module: mod_php to handle all my PHP web pages.

One of the areas I got stuck for a while (making this site work with PHP-FPM) is that PHP scripts — in this case generated web pages — were not sending gz-encoded data (compressed web pages) back to web browsers.

I know how to make Apache send compressed web pages and other documents using the Apache mod_deflate module.

I also know how to make individual PHP scripts turn output compression on.

Actually, reading that last link/page gave me the solution I was looking for – use the zlib.output_compression php.ini setting when creating my PHP-FPM Docker image.

So this was how my Dockerfile for the PHP-FPM/Alpine Linux image looks like with this setting all set up. See the last line:

File: Dockerfile

FROM php:7-fpm-alpine
RUN apk update; apk upgrade;
RUN docker-php-ext-install mysqli
RUN docker-php-ext-install opcache

# Other instructions removed for brevity #

# PHP.INI
RUN mv "$PHP_INI_DIR/php.ini-production" "$PHP_INI_DIR/php.ini"

# zlib compression
RUN echo "zlib.output_compression = On" >> "$PHP_INI_DIR/php.ini"

As soon as this Docker image was built again and running, all web pages generated by PHP-FPM for this web site are being compressed before being sent out to web browsers and clients that accept the encoding.

Categories
GIDBlog Learning Journal

How to change your WordPress Permalink Structure

Today I sat down to modify the permalink structure for this web site. The URLs for this blog used to include the /YYYY/MM/ date parts in them, and until recently, I never really gave them much thought except to think that it was sometimes interesting.

Categories
Learning Journal

Redirect all subdomains to www

If you ever need to redirect all your subdomains to a main subdomain like www, here is a method for you to easily accomplish that. I kept these notes from when I wanted to implement it for my own site: www.gidforums.com.

Categories
Learning Journal

Invalid command ‘RewriteLog’

A couple of days ago, I “upgraded” Fedora on my main PC and everything seemed to be working really well until I tried to set up a local development version of one of my sites back on the machine.

Categories
Learning Journal

Compress Your Web Site

You know how to turn compression on for one or more web pages with PHP, but what if you want to enable compression for your entire web site?

Categories
Learning Journal

Parsing PHP in .HTML Files

Is parsing PHP in web pages that end in .html or .htm possible? Absolutely!

Categories
Learning Journal

Compress Your Web Page

In my never-ending quest to get my web pages to load super-fast  I chanced upon ob_gzhandler() one day while researching the uses of ob_start() in PHP.