Install PHP on macOS using brew

Follow the steps for Apache and PHP on macOS Big Sur then:

brew install php
sudo nano /etc/apache2/httpd.conf

Comment:

LoadModule php7_module libexec/apache2/libphp7.so

Add the following lines:

LoadModule php_module /opt/homebrew/opt/php/lib/httpd/modules/libphp.so

<filesmatch \.php$>
    SetHandler application/x-httpd-php
</filesmatch>

Configure DirectoryIndex section as follow:

<IfModule dir_module>
    DirectoryIndex index.html index.php
</IfModule>

Then:

brew services restart php
sudo apachectl restart

Install Symfony CLI

debian

echo 'deb [trusted=yes] https://repo.symfony.com/apt/ /' | sudo tee /etc/apt/sources.list.d/symfony-cli.list
sudo apt update
sudo apt install symfony-cli

macOS

brew install symfony-cli/tap/symfony-cli

Install Apache and PHP 8 on debian

aptitude update
aptitude install apache2 ca-certificates apt-transport-https
echo "deb https://packages.sury.org/php/ $(lsb_release -sc) main" | sudo tee /etc/apt/sources.list.d/sury-php.list
wget -qO - https://packages.sury.org/php/apt.gpg | sudo apt-key add -
aptitude update
aptitude install php8.1

Configure Apache and PHP on macOS Big Sur

sudo apachectl start
sudo cp /etc/apache2/httpd.conf /etc/apache2/httpd.conf.backup
sudo cp /etc/apache2/extra/httpd-userdir.conf /etc/apache2/extra/httpd-userdir.conf.backup
sudo nano /etc/apache2/httpd.conf

Uncomment the following lines:

LoadModule include_module libexec/apache2/mod_include.so
LoadModule rewrite_module libexec/apache2/mod_rewrite.so
LoadModule php7_module libexec/apache2/libphp7.so
Include /private/etc/apache2/extra/httpd-userdir.conf
Include /private/etc/apache2/other/*.conf
LoadModule authn_core_module libexec/apache2/mod_authn_core.so
LoadModule authz_host_module libexec/apache2/mod_authz_host.so
LoadModule userdir_module libexec/apache2/mod_userdir.so

Edit the file:

sudo nano /etc/apache2/extra/httpd-userdir.conf

Uncomment the following line:

Include /private/etc/apache2/users/*.conf

Then:

mkdir ~/Sites
sudo nano /etc/apache2/users/your_username.conf

Configure as follow:

<directory "/Users/your_username/Sites/">
    AllowOverride FileInfo AuthConfig Limit Indexes
    Options MultiViews Indexes SymLinksIfOwnerMatch IncludesNoExec
    Require method GET POST OPTIONS
</Directory>

Restart Apache:

sudo apachectl restart

Go to your user site:

http://localhost/~your_username

Add Homebrew to macOS

Change your_username by your username.

/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
echo 'eval "$(/opt/homebrew/bin/brew shellenv)"' >> /Users/your_username/.zprofile

Install Emacs on macOS

brew tap railwaycat/emacsmacport
brew install --cask emacs-mac

Add git completion to macOS

Add to .zprofile the following lines:

zstyle ':completion:*:*:git:*' script /Library/Developer/CommandLineTools/usr/share/git-core/git-completion.bash
# `compinit` scans $fpath, so do this before calling it.
fpath=(/Library/Developer/CommandLineTools/usr/share/git-core $fpath)
autoload -Uz compinit && compinit