Macos Catalina Apache

In this post we see how to change the PHP version of Apache in MacOS Catalina.

MacOS Catalina comes with Apache and PHP 7.3 already preinstalled.
Sometimes we may need to run a different version of PHP with Apache.
For example Magento 2 needs PHP 7.2 to run .

  1. In order to Install Apache Tomcat version 8.x.x (Supports Servlet 3.1 specifications) on your Mac OS X (macOS) running Yosemite OS 10.10.x you must have java version 7 or later installed on your Mac. How to check your java version installed: Go to Terminal. Run command: java -version. If it is less than 1.8, download and install java8.
  2. The Apache Tomcat software is developed in an open and participatory environment and released under the Apache License version 2. The Apache Tomcat project is intended to be a collaboration of the best-of-breed developers from around the world. We invite you to participate in this open development project. To learn more about getting involved.

The reason is that I am using the homebrew version of both Apache and PHP. The current version of PHP that I am using is PHP 7 as you can see in the screenshot below but when I use php -v in the terminal it shows me PHP version 5.6. See screenshot below.

Install PHP 7.2 using Homebrew

To checkout the current PHP version, run:

In my case, it was PHP 7.3.

So, first we need to install the PHP version we need. I used Homebrew to install PHP 7.2.

Next, I enabled PHP 7.2 as my default PHP version for the cli. (zsh):

Or, if you use bash, use the following:

(If you watch the terminal output during PHP 7.2 installation, you’ll see that Homebrew gives us these commands.)

Macos catalina apache document root

Now, run the following command again and you should see that PHP 7.2 is enabled.

Change Apache PHP version to PHP 7.2

If you run phpinfo() in a browser, you see that although we changed the PHP version of the cli to PHP 7.2, Apache still uses PHP 7.3.

Macos Catalina Apache

Let’s change that.
In the terminal, run the following command to edit Apache configuration file:

To disable PHP 7.3, find the following line and comment it out by entering # at the beginning:

To enable PHP 7.2, paste the following line, bellow the previous.

Restart Apache:

Refresh the browser and you should see that Apache is now using PHP 7.2

That’s it!

Apache

If you have any questions or want to say hi, please leave a comment below.

——

Macos

I would also like to reference the following:

This short guide will assume that you already have already homebrew, xcode-select and java installed on your macOS. If not, run the following commands on your terminal.

Once you are sure that everything is correctly installed on your machine, you have to follow these steps to install Apache Spark

Step 1: Install scala

Step 2: Install Spark

Step 3: Add environment variables

Add the following environment variables to your .bash_profile or .zshrc

Step 4: Review binaries permissions

For some reason, some installations are not give execution permission to binaries. Review it and give them if necessary.

Step 5: Verify installation

If everything worked fine you will be able to open a spark-shell running the following command

This should open a shell as follows

Macos Catalina Apache Download

We are done! You have successfully installed Apache Spark on macOS

Macos Catalina Apache Forbidden

You can also find me on Twitter if you’d like to read similar technical tricks!