Install Apache Macos Catalina

The current Apache OpenOffice supports Apple OS X version 10.7 (Lion), 10.8 (Mountain Lion), 10.9 (Mavericks), 10.10 (Yosemite), 10.11 (El Capitan) and macOS 10.12 (Sierra), 10.13 (High Sierra), 10.14 (Mojave), 10.15 (Catalina). The last OpenOffice version supporting Mac OS X 10.4 (Tiger), 10.5 (Leopard), 10.6 (Snow Leopard) is OpenOffice 4.0.1.

  • Now the macOS installer will load. Select Disk Utility and format the largest disk in the list. Exit Disk Utility and and select Reinstall macOS. On restart, select macOS to continue the installation. When the installation is finished, upon reboot select macOS to boot into macOS Catalina.
  • My current version of Apache httpd is: Apache/2.4.41 My security team told me that I need to update to Apache/2.4.42 or later.How do I do that? Can I run a simple command line that update the Apache httpd version to 2.4.42 or later. Apache configuration file is overwritten when you upgrade, macOS Big Sur: Server version: Apache/2.4.46 (Unix).

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 .

Install PHP 7.2 using Homebrew

Install Apache Macos Catalina

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.)

Install apache on macos catalina

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.

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:

Apache

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!

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

——

I would also like to reference the following:

The title of this page is quite 'misleading' as both Apache and PHP comes pre-bundled in macOS Catalina 10.15. We merely need to configure them.

Press + SPACE (Spotlight Search) and bring up the terminal. Start as root

1) The Apache HTTP Server

As Apache 2.4 comes pre-packaged in macOS Catalina 10.15, check the version to verify

If the version number is proper, start the server by running the command

Next, type http://localhost in the URL bar of the web browser. It should display the It works! page.

2) The It works! Page Location

The default It works! page is located inside /Library/WebServer/Documents as the index.html.en file.

3) Changing the Work Directory

Get back to the login directory typing

Navigate to your home directory (it is named with your user name). In my case, it is dennisgabil

There, create a directory for your web projects, say Sites

For easy access later, you can place this newly created Sites directory in the Favorites section of your Mac's Finder. Do Spotlight Search ( + SPACE) on your username and drag and drop Sites to the Finder sidebar.

4) Modifying httpd.conf

Install Apache Macos Catalina Update

Next, navigate to /etc/apache2

Create a backup of the httpd.conf file

We need to make some changes to the httpd.conf file. Open it with vi editor

Find the line

Install apache on macos catalina

#LoadModule php7_module libexec/apache2/libphp7.so

and uncomment it, i.e., remove # (focus the cursor on # and press x).

Then find the two lines below

DocumentRoot '/Library/WebServer/Documents'
<Directory '/Library/WebServer/Documents'>

and change them to

DocumentRoot '/Users/dennisgabil/Sites'
<Directory '/Users/dennisgabil/Sites'>

(You change /dennisgabil/ in the two paths to your /username/ ). For inserting text in vi, press i. Save the changes (press ESC, then : (SHIFT + :), then wq!)

5) Restart Apache

Restart the server by running the command

Now all your web projects can go inside /Users/dennisgabil/Sites. If you have a web project called, say, myproj, inside that directory, you can access it by typing localhost/myproj in the URL bar of your browser and it will display your default index.html (or index.php, keeping in mind that we are learning PHP) file. If you have a Git repository for your project, you can clone it there and work.

Install Apache On Macos Catalina

Just for the purpose of testing, create an index.php page that displays Hello, World! inside the /Sites directory (do not forget to change /dennisgabil to your /username in the path)

Install Apache Macos Catalina Operating System

Access http://localhost. The page should display Hello, World!