PHPIniDir "/usr/local/etc/php/8.1/php.ini" For example, for an Apple silicon Mac, change /usr/local to /opt/homebrew. You may need to update the paths below to match your Mac. In this file, add the following settings. We will edit the file in the terminal, but you can use your favorite code editor.įor an Apple silicon Mac, change /usr/local to /opt/homebrew. AddType allows us to map the PHP file extension to our PHP module.In this case, it is the PHP Apache module. LoadModule is where we specify the module we wish to load and its location.PHPIniDir is where you can specify the directory where the php.ini file is located.I will briefly touch on each of them below. There are several directives that we will need to add to this file. We will need first to load the nf file that is located in the /usr/local/etc/httpd/ folder. The process is relatively straightforward, as you will use something like Homebrew to install the software.Ħ. You must have the Apache web server installed on macOS for this section. extension=curlĮxtension=mysqli Configuring PHP for Apache on macOS If you plan on doing web work, you will want to remove the semicolon from in the front of the following extensions. If a line starts with the semicolon ( ) the setting is commented out and disabled. You can enable and disable settings by removing the semicolon ( ) from in front of the line. There are quite a few different settings, so we will not cover them in this guide. Inside the ini file, you can change the settings of PHP so it is configured to your liking. I like to use the nano editor, but you can use the vim editor instead. To edit the php.ini file, enter the following line into the terminal. You can edit the file within the terminal or use a code editor such as Xcode or Visual Studio Code.įor this tutorial, we will use the terminal. This location may change if the PHP version differs from the version we use in this tutorial.įor an Apple silicon Mac, change /usr/local to /opt/homebrew. If you wish to configure the php.ini or the nf file, you can find it in the location shown below. With Zend OPcache v8.1.11, Copyright (c), by Zend Technologies Configuring the php.ini File Zend Engine v4.1.11, Copyright (c) Zend Technologies If PHP is installed correctly, you should get output in the terminal similar to the example below. In the terminal, enter the following command. The following steps will show you how to get the PHP installed version by using the terminal application.Ĥ. brew install phpĭepending on the speed of your internet connection, it will take a minute or longer to install PHP. To install PHP, enter the following line into the macOS terminal. If you get a “command not found” error, you may need to install Homebrew. You can check that Homebrew is installed by simply checking the version. You need to have Homebrew installed before you proceed any further. Then, find and load the terminal application.Ģ. Click on Terminal.Īlternatively, you can go to finder and open the Applications folder and then the Utilities folder. You can find it by going to launchpad and searching terminal. Load the terminal application on your Mac. This tutorial focuses on installing PHP on the latest version of macOS via the Homebrew package manager.ġ. It is important to note that versions of macOS 10.0.0 to 12.0.0 (Monterey) have PHP preinstalled. Thankfully, the homebrew installation is relatively easy to do. However, a prerequisite is that you have Homebrew installed on your Mac computer. Installing PHP onto a computer running macOS is relatively straightforward. We recommend using the latest version of macOS for the best experience. These instructions have been tested on an Intel-based Mac, but we have noted any changes for use on an Apple silicon Mac (M1 and M2). However, we like to run our web development on a low-powered Raspberry Pi. For example, you could set up a virtual machine running Ubuntu, Docker, or something like Xampp. There are plenty of alternatives for setting up a web development environment on your Mac. We also show you how to configure Apache and NGINX to use PHP. This tutorial will take you through the process of installing PHP without using any extra packages apart from Homebrew. In this tutorial, I go through all the steps of installing the PHP programming language on macOS.Ī development server running on your local machine is extremely useful for rapidly testing your programs.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |