Skip to content

Instantly share code, notes, and snippets.

@dangnhdev
Created June 25, 2024 07:49
Show Gist options
  • Save dangnhdev/62240aab6fe191dbb7b1cd0db7bf7af7 to your computer and use it in GitHub Desktop.
Save dangnhdev/62240aab6fe191dbb7b1cd0db7bf7af7 to your computer and use it in GitHub Desktop.
#!/bin/bash
PHP_VERSION="8.3" # Replace with your PHP version or use a variable to set it dynamically
# Define the source and destination paths
mods_available="/etc/php/$PHP_VERSION/mods-available"
cli_conf_d="/etc/php/$PHP_VERSION/cli/conf.d"
fpm_conf_d="/etc/php/$PHP_VERSION/fpm/conf.d"
link_name="10-newrelic.ini"
# Check and remove existing newrelic.ini in cli/conf.d
if [ -e "$cli_conf_d/newrelic.ini" ]; then
rm "$cli_conf_d/newrelic.ini"
echo "Removed existing 'newrelic.ini' in $cli_conf_d"
fi
# Check and remove existing newrelic.ini in fpm/conf.d
if [ -e "$fpm_conf_d/newrelic.ini" ]; then
rm "$fpm_conf_d/newrelic.ini"
echo "Removed existing 'newrelic.ini' in $fpm_conf_d"
fi
# Create symlink in cli/conf.d
ln -s "$mods_available/$link_name" "$cli_conf_d/$link_name"
# Create symlink in fpm/conf.d
ln -s "$mods_available/$link_name" "$fpm_conf_d/$link_name"
# Optionally, display success message
echo "Created symbolic link '$link_name' in:"
echo " $cli_conf_d"
echo " $fpm_conf_d"
echo "Linked to:"
echo " $mods_available"
echo "Restarting php-fpm"
sudo service "php$PHP_VERSION-fpm" reload
echo "PHP-FPM service for PHP $PHP_VERSION has been restarted."
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment