- The -DBIND8COMPAT=1 gets you over a problem in the DNS files because MacOS X has definitions for Bind9 and PHP expects Bind8 definitions.DEAPI is needed if you build it for Apache 1.3.31.O3 enables the gcc optimizer.
- How to install and configure Apache, MySQL and PHP on Mac OS X 10.7 Lion and OS X 10.6 Snow Leopard. OSX 10.8 Mountain Lion Version OSX 10.9 Mavericks Version Apache and PHP already come preloaded in OS X 10.7 Lion and 10.6 Snow Leopard, the versions on 10.7 Lion are PHP 5.3.6 and Apache 2.2.20, these 2 pieces of Open Source software are part of the “AMP” stack with MySQL the missing third.
PHP is a server-side scripting language mainly designed for web development, but it can also be used as a general-purpose programming language. Helps you power your blog, website, and web apps PHP, a recursive acronym for Hypertext Preprocessor, is a versatile code that can be easily mixed with HTML code and it can also be used in combination.
Recommend switching to Docker
If you are running macOS Mojave or higher, the recommended solutions in this tutorial may no longer work. For those reasons, I recommend following my latest tutorial on installing Apache, MySQL, and PHP on macOS using Docker.
As noted in my posts on installing Apache, PHP and MySQL on Mac OS X, Mac OS X comes pre-installed with Apache and PHP. Unfortunately, the pre-installed version of PHP with macOS is outdated:
- Mac OS 10.11 (El Capitan) pre-installed with PHP 5.5
- Mac OS 10.12 (Sierra) pre-installed with PHP 5.6
- Mac OS 10.14 (Mojave) pre-installed with PHP 7.1
- Mac OS 10.15 (Catalina) pre-installed with PHP 7.3
Many of these PHP versions are already end of life. In fact, macOS Mojave was the first time the pre-installed version was recent - although still not the latest PHP version.
So what do you do if you want to upgrade or install a different PHP version on your Mac? Well, you could use Homebrew. But I found a pre-packaged alternative - PHP OSX.
PHP OSX is a package installer for PHP versions 5.3 to 7.3 (current). It's available for Mac OS 10.6+ (Snow Leopard to Mojave). While installing PHP OSX is just a few steps, I'll walk you through each of them.
Installing PHP
First, choose the version of PHP you want to install. In this example, I'll install PHP 7.2 as that is the latest stable version of PHP. However, if you want to install PHP 7.1 that is available as well.
If you're not comfortable executing scripts from the Internet, you can do the install by hand.
Configuring Apache
Provided you are using the pre-installed version of Apache, PHP OSX will add the
/etc/apache2/other/+php-osx.conf
configuration file which will automatically be loaded by Apache.If you had previously enabled PHP (as I did), you'll need to comment out the following line in
/etc/apache2/httpd.conf
:If you are running an older version of Mac OS X, the line may be:
Php 7 Form Example
Updating your PATH
Although Apache will now run the new version of PHP, the command line will not. In order for the command line to use the new version of PHP you will need to update your
PATH
.If you don't want to run the command above every time you open a new terminal, you can update the
PATH
in your .bash_profile
.Configuring PHP
Finally, you will want to update some of the PHP configuration values. PHP OSX installs a PHP INI file for you to change. To edit this file, run:
If you kept all of your local PHP configuration within a single INI file (as I did), you can simply append it to the PHP OSX file with:
That's it!
Now you'll just need to review your PHP code to ensure it's compatible with your newly installed PHP version. And for that, I recommend PHP Shift.
Find this interesting? Let's continue the conversation on Twitter.
Introduction
PHP is a server-side scripting language. Originally it was designed for web development but it can also be used as a general-purpose language. It was created by Rasmus Lerdorf in 1994. Originally it stood for Personal home page but now It stands for Hyper Text Preprocessor. PHP code can be embedded into HTML. PHP is basically an interpreted language implemented by a web server or CGI executable. In this tutorial, we will learn the steps to install PHP on macOS.
Prerequisites
- MacOS
- Login as an administrator on terminal
- Homebrew package installer must be configured on the system.
Installation
1) Installation of PHP includes following steps.
Update the local repository index of Homebrew package installer
Following command can be used to update the local repository index of homebrew package installer.
2) Install PHP
The latest version of PHP is PHP 7.1. it can be easily installed with a single command as follows.
In case, no similar formulae found, we need to tap into the other PHP repositories by running the following command.
Php 7 Form Validation
PHP 7.1 is installed inside /usr/local/Cellar. In order to execute php globally, we need to set path in .bash_profile stored in the user's home directory. Open the file using VI editor and add the following line.
Verify PHP
To verify correct version of PHP is installed on our system, we can execute the following command.
Hence, we have successfully installed and get started with PHP version 7.1.12.
Next TopicHow to Install Python on Mac