Last active
December 13, 2015 17:29
-
-
Save davidosomething/4948436 to your computer and use it in GitHub Desktop.
Script to update the PHP module version used by Apache in httpd.conf.
Written for josegonzalez/homebrew-php but you can edit the path to the module file (change /usr/local/Cellar to whatever)
This file contains 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 characters
#!/bin/bash | |
# you should already have $APACHE_CONF, change these if your files aren't in those paths | |
export APACHE_HTTPD_CONF="$APACHE_CONF/httpd.conf" | |
export APACHE_HTTPD_VHOSTS="$APACHE_CONF/extra/httpd-vhosts.conf" | |
# these require awk and sed to get the PHP version and variants of it | |
export PHPVER="`php -v | sed 1q | awk '{print \$2}'`" | |
export PHPMINORVER="`echo $PHPVER | awk -F=\".\" '{split(\$0,a,\".\"); print a[1]\"\.\"a[2]}'`" | |
export PHPMINORVERNUM="`echo $PHPVER | awk -F=\".\" '{split(\$0,a,\".\"); print a[1]a[2]}'`" | |
# use sed to do the actual replacement. Written for josegonzalez/homebrew-php but you can edit the path to the module file. | |
sed "s/\/usr\/local\/Cellar\/php\([0-9]*\)\/\([\.0-9]*\)\//\/usr\/local\/Cellar\/php$PHPMINORVERNUM\/$PHPVER\//g" $APACHE_HTTPD_CONF |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment