Skip to content

Instantly share code, notes, and snippets.

@roberto-butti
Last active September 16, 2019 09:27
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save roberto-butti/9fd8943851921f1e6f9c to your computer and use it in GitHub Desktop.
Save roberto-butti/9fd8943851921f1e6f9c to your computer and use it in GitHub Desktop.
upgrading php7 with MacPorts
#!/bin/bash
#update ports index
sudo port selfupdate
# install php version 7.0 :)
sudo port install php70
# install php 7 as apache module
sudo port install php70-apache2handler
cd /opt/local/apache2/modules
sudo /opt/local/apache2/bin/apxs -a -e -n php7 mod_php70.so
cd
#switch to php 7 as default php
sudo port select php php70
# check if everything is ok :)
php -v
@metd
Copy link

metd commented Apr 17, 2018

Thx

@pgee70
Copy link

pgee70 commented Aug 22, 2018

ports now puts its LAMP files in different folders.

sudo port uninstall php71*
sudo port install php72
sudo port install php72-apache2handler
cd /opt/local/lib/apache2/modules/
sudo /opt/local/bin/apxs -a -e -n php7 mod_php72.so
sudo port select php php72
cd /opt/local/etc/php72/
sudo cp php.ini-development php.ini
#update as required filemerge util is handy to see what has changed. needed to set up mysqli default sockets etc.
cd /opt/local/etc/apache2/
sudo nano httpd.conf
#make sure that all but the last php.so is enabled.
LoadModule php7_module lib/apache2/modules/mod_php72.so

sudo port select php php72

restart_apache.sh script

#!/bin/sh
#!/bin/bash
SYNTAX=apachectl -t 2>&1
if [ "$SYNTAX" = 'Syntax OK' ]; then
#sudo launchctl unload -w /System/Library/LaunchDaemons/org.apache.httpd.plist
sudo port unload apache2
sudo port load apache2
echo 'Restarted Apache'
else
sudo apachectl -t
fi

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment