Welcome to Abdul Malik Ikhsan's Blog

Install php 8.0 in MacOS Sierra with Macports

Posted in php, Teknologi by samsonasik on December 6, 2020

Yes, you read it right. I live in the past, with old hardware, with legacy operating system. There is homebrew that previously still works in php 7.4 in early releases, but now no longer works. There is an alternative like a one click install app like MAMP PRO but didn’t support php 8.0 yet. XAMPP ? not really extension installable user friendly (as far as I tried)!

I don’t want to lost hope, I give a Macports a try, and it works while it not documented in the wiki yet. If you are using MacOS Sierra and want to try, you can do the following steps:

1. First, you need to have Macports installed first, that we can read in the documentation.
2. Install php 8.0

sudo port install php80

You will get the following note in the end of installation process:

 To customize php80, copy /opt/local/etc/php80/php.ini-development (if this is a development server) or /opt/local/etc/php80/php.ini-production (if this is a production server) to /opt/local/etc/php80/php.ini and then make changes.

You can follow that if you want to changes the PHP configuration.

3. Install common extensions

For example, you will need intl and mbstring extension, you can run:

sudo port install php80-intl
sudo port install php80-mbstring 

You can search already available extensions in the search page.

4. Now, you can check if it is actually installed:

php80 --version

That’s it 😉