search
HomeBackend DevelopmentPHP7How to install PHP7 on macOS

How to install PHP7 on macOS

Apr 08, 2019 am 09:40 AM
php

PHP stands for HyperText Preprocessor and is a server-side programming language. Initially it was developed for web development but now it is also used as a general purpose language. This article will introduce you to installing PHP on macOS.

How to install PHP7 on macOS

Requirements

Before you start installing node.js and npm, you must meet the following conditions

Terminal: Must have Mac Terminal access.

homebrew: homebrew is a popular package manager for Mac operating systems. It is suitable for installing most open source software such as Node.

Download and Install PHP on MacOS

The following steps help install PHP 7.2 or 7.1 or 5.6 on macOS.

Open a terminal and run the following command

For PHP 7.2

$ curl -s http://php-osx.liip.ch/install.sh | bash -s 7.2

For PHP 7.1

$ curl -s http://php-osx.liip.ch/install.sh | bash -s 7.1

Works with PHP 5.6 - Runs with OSX 10.11 El Capitan or lower.

$ curl -s http://php-osx.liip.ch/install.sh | bash -s 5.6

Verify PHP Installation

The version of PHP for MacOS is maintained by php osx and will not overwrite the current php binaries installed on the system. Installed in /usr/local/php5. Therefore, the new php binary is located in /usr/local/php5/bin/php.

$ export PATH=/usr/local/php5/bin:$PATH

To verify that the correct version of PHP is installed on your system, execute the following command.

$ php -v  

PHP 7.2.2 (cli) (built: Feb  1 2018 13:23:34) ( NTS )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.2.0, Copyright (c) 1998-2018 Zend Technologies
    with Zend OPcache v7.2.2, Copyright (c) 1999-2018, by Zend Technologies
    with Xdebug v2.6.0, Copyright (c) 2002-2018, by Derick Rethans

Also, create a phpinfo.php in the web root directory with the following content and access the file in the web browser.

<?php phpinfo();?>

Restore php to default

If you don't need the latest installed PHP, just edit /etc/apache2/httpd.conf and uncomment the line below .

From:

LoadModule php5_module /usr/local/php5/libphp5.so

to

LoadModule php5_module libexec/apache2/libphp5.so

and delete the files php-osx.conf and entropy-php.conf from the /etc/apache2/other directory.

This article has ended here. For more other exciting content, you can pay attention to the PHP Video Tutorial column on the PHP Chinese website!

The above is the detailed content of How to install PHP7 on macOS. For more information, please follow other related articles on the PHP Chinese website!

Statement
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

SublimeText3 Linux new version

SublimeText3 Linux new version

SublimeText3 Linux latest version

Dreamweaver Mac version

Dreamweaver Mac version

Visual web development tools

WebStorm Mac version

WebStorm Mac version

Useful JavaScript development tools

PhpStorm Mac version

PhpStorm Mac version

The latest (2018.2.1) professional PHP integrated development tool

DVWA

DVWA

Damn Vulnerable Web App (DVWA) is a PHP/MySQL web application that is very vulnerable. Its main goals are to be an aid for security professionals to test their skills and tools in a legal environment, to help web developers better understand the process of securing web applications, and to help teachers/students teach/learn in a classroom environment Web application security. The goal of DVWA is to practice some of the most common web vulnerabilities through a simple and straightforward interface, with varying degrees of difficulty. Please note that this software