Skip to content

Instantly share code, notes, and snippets.

@bipinu
Last active September 13, 2022 13:15
Show Gist options
  • Save bipinu/489306e6dc6a693e712c to your computer and use it in GitHub Desktop.
Save bipinu/489306e6dc6a693e712c to your computer and use it in GitHub Desktop.
Install Thread Safe PHP 5.6, along with pthreads extension on OS X
# Note: Based on http://justinhileman.info/article/reinstalling-php-on-mac-os-x/
# Refer to the page in case of any issues
# Assumed that you have Brew install; else run the following commands
# xcode-select --install
# ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
brew update && brew upgrade
# Note: Following may be updated for appropriate PHP version
# Note: Breaks every once in a while, so --build-from-source
brew install php56 --build-from-source
sudo mv /etc/php.ini /etc/php.ini.old
sudo ln -s /usr/local/etc/php/5.6/php.ini /etc/php.ini
# TODO: change upload_max_filesize and post_max_size to 20M, or whatever your app requires
# TODO: Change time
<FilesMatch \.php$>
SetHandler application/x-httpd-php
</FilesMatch>
# Note: remove, or rename php, phpize, etc. binaries at /usr/bin/php*
# You might have to run brew link --overwrite
brew link php56
#TODO: /usr/bin/php is the default php; Homebrew php is installed and symlinked at /usr/local/bin/php
#Either rename /usr/bin/php by disabling csrutil in Recovery mode, OR
#give preference to /usr/local/bin over /usr/bin in $PATH
# Apache is installed to work on port 8080; conf file is at /usr/local/etc/httpd/httpd.conf
echo "LoadModule php5_module /usr/local/opt/php@5.6/lib/httpd/modules/libphp5.so" > $(brew --prefix php56)/entropy-php.conf
echo "<FilesMatch \.php$>" >> $(brew --prefix php56)/entropy-php.conf
echo " SetHandler application/x-httpd-php" >> $(brew --prefix php56)/entropy-php.conf
echo "</FilesMatch>" >> $(brew --prefix php56)/entropy-php.conf
echo "AddType application/x-httpd-php .php" >> $(brew --prefix php56)/entropy-php.conf
sudo rm /etc/apache2/other/+php-osx.conf
sudo ln -s $(brew --prefix php56)/entropy-php.conf /etc/apache2/other/+php-osx.conf
#TODO: Add following to /usr/local/etc/httpd/httpd.conf
# Include /etc/apache2/other/+php-osx.conf
# Most php extensions are now installed by default. The remaining should be installed using pecl
pecl install xdebug
#pecl install mongo
#pecl install pthreads
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment