When trying to install the php7.x-imagick module in Ubuntu 18.04 using the command,
# apt-get install php-imagick
Facing this error,
Package php7.x-imagick is not available, but is referred to by another package. This may mean that the package is missing, has been obsoleted, or is only available from another source E: Package ‘php7.x-imagick’ has no installation candidate
Using this script should install the module and all should be good. One chance of an error is when you have 2 PHP versions in your Ubuntu and you did that unintentionally
For example, php -v command in terminal might should you PHP version as 7.4 but the phpinfo page on the website would show that to be 7.3.
So, during these times, you would need to upgrade your PHP to use the 7.4 for your website.
Well, how do you do that ?
# sudo a2dismod php7.3 ( disable PHP 7.3 )
# sudo a2enmod php7.4 ( Enable PHP 7.4 )
# sudo service apache2 restart
# sudo update-alternatives --set php /usr/bin/php7.4
Dont forget to add imagick.so as the extension in the PHP config file and to check if you have the short_open_tag setting correct.