Using Macports is easy to setup a MAMP environment with all the custom PHP extensions you may need.

This is what I did to have a dev environment, running on MacOS Catalina:

Install apache and php

  1. sudo port install php74 php74-xdebug php74-apache2handler php74-mysql php74-sqlite php74-mcrypt php74-mbstring php74-openssl

Activate mod_php

  1. cd /opt/local/lib/apache2/modules
  2. sudo /opt/local/bin/apxs -a -e -n php7 mod_php74.so

Activate mod_rewrite

  1. LoadModule rewrite_module lib/apache2/modules/mod_rewrite.so

Set a default php.ini

  1. sudo cp /opt/local/etc/php74/php-development.ini /opt/local/etc/php74/php.ini

Change DirectoryIndex in /opt/local/etc/apache2/httpd.conf from:

  1. DirectoryIndex index.html

To:

  1. DirectoryIndex index.php index.html

Uncomment the vhosts file

  1. Include etc/apache2/extra/httpd-vhosts.conf
  2. Include etc/apache2/extra/mod_php74.conf

Create a new vhost in /opt/local/etc/apache2/extra/httpd-vhosts.conf

  1. <VirtualHost *:80>
  2. ServerName agilistico.test
  3. ServerAdmin webmaster@xilonen.lan
  4. DocumentRoot "/Users/ivan/PhpstormProjects/agilistico.com/public"
  5. <Directory "/Users/ivan/PhpstormProjects/agilistico.com/public">
  6. Options Indexes FollowSymLinks
  7. AllowOverride All
  8. Require all granted
  9. </Directory>
  10. ErrorLog "var/log/apache2/agilistico.test-error_log"
  11. CustomLog "var/log/apache2/agilistico.test-access_log" common
  12. </VirtualHost>

Restart Apache to reflect the config changes

  1. sudo apachectl restart

And finally add the host to /etc/hosts

  1. sudo echo '127.0.0.1 agilistico.test' > /etc/hosts

Now install MySQL (in my case I need 5.7 at the time, but by default network is off so I can install multiple versions)

  1. sudo port install mysql57-server mysql57
  2. sudo /opt/local/lib/mysql57/bin/mysqld --initialize --user=_mysql
  3. sudo chown -R _mysql:_mysql /opt/local/var/db/mysql57/
  4. sudo chown -R _mysql:_mysql /opt/local/var/run/mysql57/
  5. sudo chown -R _mysql:_mysql /opt/local/var/log/mysql57/

Add mysql_client path to the shell, in my case I’ve added the following to ~/.zshrc

  1. export PATH=$PATH:/opt/local/lib/mysql57/bin

Create another mysql user, default root has no password:

  1. mysql -uroot
  2. Welcome to the MySQL monitor. Commands end with ; or \g.
  3. Your MySQL connection id is 24
  4. Server version: 5.7.29 Source distribution
  5. Copyright (c) 2000, 2020, Oracle and/or its affiliates. All rights reserved.
  6. Oracle is a registered trademark of Oracle Corporation and/or its
  7. affiliates. Other names may be trademarks of their respective
  8. owners.
  9. Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
  10. mysql >

Then in mysql console

  1. CREATE USER 'ivan'@'%' IDENTIFIED BY '123456';
  2. GRANT ALL PRIVILEGES ON *.* TO 'ivan'@'%'WITH GRANT OPTION;
  3. CREATE USER 'ivan'@'localhost' IDENTIFIED BY '123456';
  4. GRANT ALL PRIVILEGES ON *.* TO 'ivan'@'localhost'WITH GRANT OPTION;
  5. flush privileges; 

Make apache and mysql start at boot:

  1. sudo port load mysql57-server
  2. sudo port load apache2