Created
June 16, 2024 12:18
-
-
Save bajpangosh/45358a9e8917dcff6ab545da9b8623dc to your computer and use it in GitHub Desktop.
Revisions
-
bajpangosh created this gist
Jun 16, 2024 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,55 @@ Sure, here's a bash script that will install the ImageMagick library and the imagick extension for PHP 7.4 by default, with an option for the user to choose PHP 8.3. This script will handle the installation through PECL and ensure the correct permissions are set for the library. ```bash #!/bin/bash # Function to install imagick for a specified PHP version install_imagick() { PHP_VERSION=$1 PHP_BIN="/usr/local/lsws/lsphp${PHP_VERSION}/bin" PHP_INI="/usr/local/lsws/lsphp${PHP_VERSION}/etc/php.ini" PHP_MODULES="/usr/local/lsws/lsphp${PHP_VERSION}/lib64/php/modules" echo "Installing ImageMagick development package..." dnf install -y ImageMagick-devel echo "Installing imagick extension for PHP ${PHP_VERSION}..." ${PHP_BIN}/pecl install imagick echo "Enabling imagick extension in php.ini..." echo "extension=imagick.so" >> ${PHP_INI} echo "Setting correct permissions for imagick.so..." chmod 755 ${PHP_MODULES}/imagick.so echo "Restarting lsws..." service lshttpd restart echo "Imagick extension installed and enabled for PHP ${PHP_VERSION}." } # Default PHP version PHP_VERSION="74" # Check for user input if [ $# -eq 1 ]; then if [ $1 == "8.3" ]; then PHP_VERSION="83" elif [ $1 != "7.4" ]; then echo "Unsupported PHP version. Only 7.4 and 8.3 are supported." exit 1 fi fi # Call the function to install imagick install_imagick $PHP_VERSION ``` ### Usage: - Save the script to a file, for example, `install_imagick.sh`. - Make the script executable: `chmod +x install_imagick.sh`. - Run the script: - For PHP 7.4: `./install_imagick.sh`. - For PHP 8.3: `./install_imagick.sh 8.3`. This script will check the provided PHP version and install the imagick extension for the corresponding version. If no version is specified, it defaults to PHP 7.4.