Home > Backend Development > PHP7 > body text

How to install PHP7 on macOS

不言
Release: 2023-02-17 12:00:02
Original
3970 people have browsed it

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
Copy after login

For PHP 7.1

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

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
Copy after login

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
Copy after login

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
Copy after login

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

<?php phpinfo();?>
Copy after login

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
Copy after login

to

LoadModule php5_module libexec/apache2/libphp5.so
Copy after login

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!

Related labels:
php
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template