Jorge Batres
asked on
compile PHP gd.so module with WebP support
Hello, I'm in need of some assistance to compile PHP gd.so module with WebP support on my server.
I started following the instruction provided here:
https://talk.plesk.com/resources/how-to-compile-php-gd-so-module-with-webp-support.4/
The original instructions refer to PHP version 7.1.11 however, I changed mine to 7.2.13 which is the current version on my Plesk Server.
This is the result of the first 2 commands so far, and I had to stop because I saw the packages required were not available. I didn't want to continue because I don't want to break my current PHP version, but I need PHP gd.so module with WebP support on my server.
Could somebody please take a look and give me so guidance? Should I continue?
yum install make gcc plesk-php72-devel libjpeg-turbo-devel libpng-devel libXpm-devel freetype-devel libwebp-devel
wget http://be2.php.net/get/php-7.2.13.tar.gz/from/this/mirror
[root@web ~]# yum install make gcc plesk-php72-devel libjpeg-turbo-devel libpng-devel libXpm-devel freetype-devel libwebp-devel
Loaded plugins: product-id, search-disabled-repos, subscription-manager
This system is not registered with an entitlement server. You can use subscription-manager to register.
PLESK_17_8_11-extras | 2.9 kB 00:00:00
PLESK_17_PHP52 | 2.9 kB 00:00:00
PLESK_17_PHP53 | 2.9 kB 00:00:00
PLESK_17_PHP54 | 2.9 kB 00:00:00
PLESK_17_PHP55 | 2.9 kB 00:00:00
PLESK_17_PHP56 | 2.9 kB 00:00:00
PLESK_17_PHP70 | 2.9 kB 00:00:00
PLESK_17_PHP71 | 2.9 kB 00:00:00
PLESK_17_PHP72 | 2.9 kB 00:00:00
epel/x86_64/metalink | 18 kB 00:00:00
epel | 3.2 kB 00:00:00
kernelcare | 2.6 kB 00:00:00
mariadb | 2.9 kB 00:00:00
plesk-migrator | 2.9 kB 00:00:00
plesk-migrator-tp | 2.9 kB 00:00:00
(1/16): PLESK_17_PHP55/primary_db | 13 kB 00:00:00
(2/16): PLESK_17_PHP52/primary_db | 13 kB 00:00:00
(3/16): PLESK_17_PHP53/primary_db | 13 kB 00:00:00
(4/16): PLESK_17_8_11-extras/prima ry_db | 30 kB 00:00:00
(5/16): PLESK_17_PHP56/primary_db | 14 kB 00:00:00
(6/16): PLESK_17_PHP70/primary_db | 14 kB 00:00:00
(7/16): PLESK_17_PHP71/primary_db | 14 kB 00:00:00
(8/16): PLESK_17_PHP54/primary_db | 13 kB 00:00:00
(9/16): PLESK_17_PHP72/primary_db | 14 kB 00:00:00
(10/16): epel/x86_64/group_gz | 88 kB 00:00:00
(11/16): kernelcare/7Server/x86_64/ primary_db | 16 kB 00:00:00
(12/16): plesk-migrator/primary_db | 6.3 kB 00:00:00
(13/16): mariadb/primary_db | 50 kB 00:00:00
(14/16): plesk-migrator-tp/primary_ db | 1.1 kB 00:00:00
(15/16): epel/x86_64/updateinfo | 943 kB 00:00:00
(16/16): epel/x86_64/primary | 3.6 MB 00:00:00
epel 12780/12780
No package libjpeg-turbo-devel available.
No package libpng-devel available.
No package libXpm-devel available.
No package freetype-devel available.
No package libwebp-devel available.
Resolving Dependencies
--> Running transaction check
---> Package plesk-php72-devel.x86_64 1:7.2.13-centos7.18120711 will be installed
--> Finished Dependency Resolution
Dependencies Resolved
========================== ========== ========== ========== ========== ========== ========== ========== ========== ========== ========== ========== ========== ========== ========== ========== ==
Package Arch Version Repository Size
========================== ========== ========== ========== ========== ========== ========== ========== ========== ========== ========== ========== ========== ========== ========== ========== ==
Installing:
plesk-php72-devel x86_64 1:7.2.13-centos7.18120711 PLESK_17_PHP72 827 k
Transaction Summary
========================== ========== ========== ========== ========== ========== ========== ========== ========== ========== ========== ========== ========== ========== ========== ========== ==
Install 1 Package
Total download size: 827 k
Installed size: 6.0 M
Is this ok [y/d/N]: y
Downloading packages:
plesk-php72-devel-7.2.13-c entos7.181 20711.x86_ 64.rpm | 827 kB 00:00:00
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
Installing : 1:plesk-php72-devel-7.2.13 -centos7.1 8120711.x8 6_64 1/1
Verifying : 1:plesk-php72-devel-7.2.13 -centos7.1 8120711.x8 6_64 1/1
Installed:
plesk-php72-devel.x86_64 1:7.2.13-centos7.18120711
Complete!
[root@web ~]# wget http://be2.php.net/get/php-7.2.13.tar.gz/from/this/mirror
--2019-01-01 15:17:31-- http://be2.php.net/get/php-7.2.13.tar.gz/from/this/mirror
Resolving be2.php.net (be2.php.net)... 194.50.97.16, 2001:67c:314::feed:efff
Connecting to be2.php.net (be2.php.net)|194.50.97.16 |:80... connected.
HTTP request sent, awaiting response... 302 Found
Location: http://be2.php.net/distributions/php-7.2.13.tar.gz [following]
--2019-01-01 15:17:32-- http://be2.php.net/distributions/php-7.2.13.tar.gz
Reusing existing connection to be2.php.net:80.
HTTP request sent, awaiting response... 200 OK
Length: 19623902 (19M) [application/octet-stream]
Saving to: ‘mirror’
100%[===================== ========== ========== ========== ========== ========== ========== ========== ========== ========== ========== ========== =====>] 19,623,902 7.83MB/s in 2.4s
2019-01-01 15:17:35 (7.83 MB/s) - ‘mirror’ saved [19623902/19623902]
[root@web ~]#
Thanks,
Jorge Batres
I started following the instruction provided here:
https://talk.plesk.com/resources/how-to-compile-php-gd-so-module-with-webp-support.4/
The original instructions refer to PHP version 7.1.11 however, I changed mine to 7.2.13 which is the current version on my Plesk Server.
This is the result of the first 2 commands so far, and I had to stop because I saw the packages required were not available. I didn't want to continue because I don't want to break my current PHP version, but I need PHP gd.so module with WebP support on my server.
Could somebody please take a look and give me so guidance? Should I continue?
yum install make gcc plesk-php72-devel libjpeg-turbo-devel libpng-devel libXpm-devel freetype-devel libwebp-devel
wget http://be2.php.net/get/php-7.2.13.tar.gz/from/this/mirror
[root@web ~]# yum install make gcc plesk-php72-devel libjpeg-turbo-devel libpng-devel libXpm-devel freetype-devel libwebp-devel
Loaded plugins: product-id, search-disabled-repos, subscription-manager
This system is not registered with an entitlement server. You can use subscription-manager to register.
PLESK_17_8_11-extras | 2.9 kB 00:00:00
PLESK_17_PHP52 | 2.9 kB 00:00:00
PLESK_17_PHP53 | 2.9 kB 00:00:00
PLESK_17_PHP54 | 2.9 kB 00:00:00
PLESK_17_PHP55 | 2.9 kB 00:00:00
PLESK_17_PHP56 | 2.9 kB 00:00:00
PLESK_17_PHP70 | 2.9 kB 00:00:00
PLESK_17_PHP71 | 2.9 kB 00:00:00
PLESK_17_PHP72 | 2.9 kB 00:00:00
epel/x86_64/metalink | 18 kB 00:00:00
epel | 3.2 kB 00:00:00
kernelcare | 2.6 kB 00:00:00
mariadb | 2.9 kB 00:00:00
plesk-migrator | 2.9 kB 00:00:00
plesk-migrator-tp | 2.9 kB 00:00:00
(1/16): PLESK_17_PHP55/primary_db | 13 kB 00:00:00
(2/16): PLESK_17_PHP52/primary_db | 13 kB 00:00:00
(3/16): PLESK_17_PHP53/primary_db | 13 kB 00:00:00
(4/16): PLESK_17_8_11-extras/prima
(5/16): PLESK_17_PHP56/primary_db | 14 kB 00:00:00
(6/16): PLESK_17_PHP70/primary_db | 14 kB 00:00:00
(7/16): PLESK_17_PHP71/primary_db | 14 kB 00:00:00
(8/16): PLESK_17_PHP54/primary_db | 13 kB 00:00:00
(9/16): PLESK_17_PHP72/primary_db | 14 kB 00:00:00
(10/16): epel/x86_64/group_gz | 88 kB 00:00:00
(11/16): kernelcare/7Server/x86_64/
(12/16): plesk-migrator/primary_db | 6.3 kB 00:00:00
(13/16): mariadb/primary_db | 50 kB 00:00:00
(14/16): plesk-migrator-tp/primary_
(15/16): epel/x86_64/updateinfo | 943 kB 00:00:00
(16/16): epel/x86_64/primary | 3.6 MB 00:00:00
epel 12780/12780
No package libjpeg-turbo-devel available.
No package libpng-devel available.
No package libXpm-devel available.
No package freetype-devel available.
No package libwebp-devel available.
Resolving Dependencies
--> Running transaction check
---> Package plesk-php72-devel.x86_64 1:7.2.13-centos7.18120711 will be installed
--> Finished Dependency Resolution
Dependencies Resolved
==========================
Package Arch Version Repository Size
==========================
Installing:
plesk-php72-devel x86_64 1:7.2.13-centos7.18120711 PLESK_17_PHP72 827 k
Transaction Summary
==========================
Install 1 Package
Total download size: 827 k
Installed size: 6.0 M
Is this ok [y/d/N]: y
Downloading packages:
plesk-php72-devel-7.2.13-c
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
Installing : 1:plesk-php72-devel-7.2.13
Verifying : 1:plesk-php72-devel-7.2.13
Installed:
plesk-php72-devel.x86_64 1:7.2.13-centos7.18120711
Complete!
[root@web ~]# wget http://be2.php.net/get/php-7.2.13.tar.gz/from/this/mirror
--2019-01-01 15:17:31-- http://be2.php.net/get/php-7.2.13.tar.gz/from/this/mirror
Resolving be2.php.net (be2.php.net)... 194.50.97.16, 2001:67c:314::feed:efff
Connecting to be2.php.net (be2.php.net)|194.50.97.16
HTTP request sent, awaiting response... 302 Found
Location: http://be2.php.net/distributions/php-7.2.13.tar.gz [following]
--2019-01-01 15:17:32-- http://be2.php.net/distributions/php-7.2.13.tar.gz
Reusing existing connection to be2.php.net:80.
HTTP request sent, awaiting response... 200 OK
Length: 19623902 (19M) [application/octet-stream]
Saving to: ‘mirror’
100%[=====================
2019-01-01 15:17:35 (7.83 MB/s) - ‘mirror’ saved [19623902/19623902]
[root@web ~]#
Thanks,
Jorge Batres
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
This item, "4. Replace original Plesk PHP gd.so module with compiled:" can be super tricky.
I built entire LAMP Stacks from source + maintained them for years.
You'll save yourself a massive amount of grief going one of these ways.
1) Use Ubuntu Bionic + just install the default PHP GD module.
2) Follow my suggestion above, deinstall all shreds of PHP + FPM, then build your PHP + FPM from source + use only the PHP modules you built.
http://www.linuxfromscratc h.org/blfs /view/svn/ general/ph p.html provides a very good overview of building PHP from source.
I built entire LAMP Stacks from source + maintained them for years.
You'll save yourself a massive amount of grief going one of these ways.
1) Use Ubuntu Bionic + just install the default PHP GD module.
2) Follow my suggestion above, deinstall all shreds of PHP + FPM, then build your PHP + FPM from source + use only the PHP modules you built.
http://www.linuxfromscratc
ASKER
Hi David, I really don't have experience enough to do this and I'm afraid to break something on my server and render all my sites useless.
So far, everything works great with my server and it runs about 5 or 6 websites, and they all work just fine, but now that I'm starting to use newer site templates for Joomla on my sites, I see results on Google PageSpeed and the template itself suggesting I use webP for images.
I was wondering if you would have the time and if you were interested in maybe install PHP on my server so that I can implement this and it still make it work with Plesk.
I would definitely would be interested in updating OpenSSL, Apache, OpenSSH and so on, my concern is that it all works with my configuration:
Red Hat Enterprise Linux Server 7.5 (Maipo)
Plesk Onyx Version 17.8.11 Update #35, last updated on Dec 28, 2018 03:41 AM
5.5.5-10.2.15-MariaDB
Please let me know.
Thanks,
Jorge Batres
So far, everything works great with my server and it runs about 5 or 6 websites, and they all work just fine, but now that I'm starting to use newer site templates for Joomla on my sites, I see results on Google PageSpeed and the template itself suggesting I use webP for images.
I was wondering if you would have the time and if you were interested in maybe install PHP on my server so that I can implement this and it still make it work with Plesk.
I would definitely would be interested in updating OpenSSL, Apache, OpenSSH and so on, my concern is that it all works with my configuration:
Red Hat Enterprise Linux Server 7.5 (Maipo)
Plesk Onyx Version 17.8.11 Update #35, last updated on Dec 28, 2018 03:41 AM
5.5.5-10.2.15-MariaDB
Please let me know.
Thanks,
Jorge Batres
1) "Hi David, I really don't have experience enough to do this and I'm afraid to break something on my server and render all my sites useless."
This is why I suggested you search for a repo which already builds PHP + GD + Webp support or use a Distro (like Ubuntu) which packages this type of PHP by default.
Building from source is complex + you must go through a rebuild anytime any part of your Stack changes (Apache, PHP, GD, Webp, etc...) which becomes time consuming.
2) "I see results on Google PageSpeed and the template itself suggesting I use webP for images."
Likely not a good enough reason to go through the all the time which will be required to build from source.
Again, likely best you find a better repo or use Ubuntu for this.
3) "I was wondering if you would have the time and if you were interested in maybe install PHP on my server so that I can implement this and it still make it work with Plesk."
No.
Here's why.
This might take 10-20 hours (sometimes more) to get working first time + then 1-2 additional hours each time any Stack change occurs.
I charge by the hour, so you could lease a dedicated server for a year + install Ubuntu, for what I'd charge to do the work for Plesk.
4) So long as you stick with RedHat, you'll be faced with this same problem. Also you'll have the additional problem of running older Kernels, so you may end up fighting with bugs in RedHat that have been long fixed in Debian/Ubuntu.
5) The other problem worth mentioning is Plesk or CPanel or any Panel System.
Since your Panel system will have no knowledge about source builds, an incorrect Panel command can destroy your source build + take all your sites down.
If your working on a serious, long term project, where your time is better invested in marketing or some other work, best to stick with Ubuntu to optimize your time.
With RedHat/CentOS/Fedora you'll always spend far more time mucking around with packaging nonsense which is handled sensibly in Ubuntu.
At least, that's my conclusion after working on LAMP Stacks since 1994... when I received my first copy of Linux... in the mail... on a large stack of 3.5 inch hard floppies.
I prefer the Ubuntu... Install + forget approach to dealing with tech.
This is why I suggested you search for a repo which already builds PHP + GD + Webp support or use a Distro (like Ubuntu) which packages this type of PHP by default.
Building from source is complex + you must go through a rebuild anytime any part of your Stack changes (Apache, PHP, GD, Webp, etc...) which becomes time consuming.
2) "I see results on Google PageSpeed and the template itself suggesting I use webP for images."
Likely not a good enough reason to go through the all the time which will be required to build from source.
Again, likely best you find a better repo or use Ubuntu for this.
3) "I was wondering if you would have the time and if you were interested in maybe install PHP on my server so that I can implement this and it still make it work with Plesk."
No.
Here's why.
This might take 10-20 hours (sometimes more) to get working first time + then 1-2 additional hours each time any Stack change occurs.
I charge by the hour, so you could lease a dedicated server for a year + install Ubuntu, for what I'd charge to do the work for Plesk.
4) So long as you stick with RedHat, you'll be faced with this same problem. Also you'll have the additional problem of running older Kernels, so you may end up fighting with bugs in RedHat that have been long fixed in Debian/Ubuntu.
5) The other problem worth mentioning is Plesk or CPanel or any Panel System.
Since your Panel system will have no knowledge about source builds, an incorrect Panel command can destroy your source build + take all your sites down.
If your working on a serious, long term project, where your time is better invested in marketing or some other work, best to stick with Ubuntu to optimize your time.
With RedHat/CentOS/Fedora you'll always spend far more time mucking around with packaging nonsense which is handled sensibly in Ubuntu.
At least, that's my conclusion after working on LAMP Stacks since 1994... when I received my first copy of Linux... in the mail... on a large stack of 3.5 inch hard floppies.
I prefer the Ubuntu... Install + forget approach to dealing with tech.
ASKER
By default Plesk package plesk-php71-gd does not ship PHP GD module with WebP support. Initial discussion is here Issue - PHP 7.x: webp support in GD
Here is my instruction how to compile own gd.so module with WebP support.
1. Install all needed packages:
Code:
# yum install make gcc plesk-php71-devel libjpeg-turbo-devel libpng-devel libXpm-devel freetype-devel libwebp-devel
2. Download PHP source. Note! Version of PHP source should be the same as your Plesk PHP version! For example, for PHP 7.1.11:
Code:
# wget http://be2.php.net/get/php-7.1.11.tar.gz/from/this/mirror
# tar -xzf mirror
# cd php-7.1.11/ext/gd
3. Compile gd.so module:
Code:
# /opt/plesk/php/7.1/bin/php
# ./configure --with-php-config=/opt/ple
# make
4. Replace original Plesk PHP gd.so module with compiled:
Code:
# mv /opt/plesk/php/7.1/lib64/p
# cp modules/gd.so /opt/plesk/php/7.1/lib64/p
# plesk bin php_handler --reread
5. Check that all is OK:
Code:
# /opt/plesk/php/7.1/bin/php
gd
Create file gdinfo.php with following content:
Code:
<?php
var_dump(gd_info());
?>
And check that WebP support is enabled:
# /opt/plesk/php/7.1/bin/php
array(12) {
["GD Version"]=>
string(26) "bundled (2.1.0 compatible)"
["FreeType Support"]=>
bool(true)
["FreeType Linkage"]=>
string(13) "with freetype"
["GIF Read Support"]=>
bool(true)
["GIF Create Support"]=>
bool(true)
["JPEG Support"]=>
bool(true)
["PNG Support"]=>
bool(true)
["WBMP Support"]=>
bool(true)
["XPM Support"]=>
bool(true)
["XBM Support"]=>
bool(true)
["WebP Support"]=>
bool(true)
["JIS-mapped Japanese Font Support"]=>
bool(false)
}
Do not forget to to make fake removal of original plesk-php71-gd package! Otherwise, your custom gd.so will be overwritten with next update.
David, please let me know if you think I should proceed with these instructions.
Thanks,
Jorge Batres