Home > Backend Development > PHP7 > body text

How to install php7 on macbook pro

藏色散人
Release: 2023-02-18 08:20:02
Original
3679 people have browsed it

How to install php7 on macbook pro: 1. Install Homebrew; 2. Install PHP7 through brew and execute commands such as "$ brew install php70"; 3. Configure Apache; 4. Restart Apache.

How to install php7 on macbook pro

The operating environment of this article: macOS10.15 system, php7 version, macbook pro 2020 computer

How to install php7 on macbook pro?

Mac installation PHP7:

After a long wait, after our PHP5.6 was released, our latest PHP7 was finally released (waiting Wait, where is our 6?), according to the official statement, the current PHP7 is twice as fast as PHP5.6, so if we want to try it out, how can we experience it?

In fact, we have several ways to install it.

First, we can go to the official website and download the source code to compile it, so I won’t go into details about this.

Second, we can use our third-party package to install, such as homebrew. This article will describe how to install using this method.

Installation method

First we need to install Homebrew

Install through brew:

$ brew tap homebrew/dupes  
$ brew tap homebrew/versions  
$ brew tap homebrew/homebrew-php  
   
// 创建目录 
sudo mkdir /usr/local/var
sudo chmod 777 /usr/local/var 
//修改成你自己的用户名和组
sudo chown -R <username>:<group> /usr/local/sbin   
sudo mkdir /usr/local/sbin/
//安装PHP7  
$ brew install php70  
//删掉以前安装的PHP5.6  
//你可以根据自己的情况来修改  
$ brew unlink php56
$ brew link php70
//大功告成
$ php -v
PHP 7.0.0 (cli) (built: Dec  2 2015 13:06:23) ( NTS )
Copyright (c) 1997-2015 The PHP Group
Zend Engine v3.0.0, Copyright (c) 1998-2015 Zend Technologies
Copy after login

Configure Apache

$ sudo vim /etc/apache2/httpd.conf
Copy after login

Find this line and comment it out (about line 168)

#Comment out the PHP5 module   
#LoadModule php5_module libexec/apache2/libphp5.so
#Enable PHP 7 module  
LoadModule php7_module /usr/local/opt/php70/libexec/apache2/libphp7.so  <FilesMatch \.php$>
SetHandler application/x-httpd-php
</FilesMatch>
Copy after login

Restart Apache

sudo apachectl restart
Copy after login

Go to your Apache’s default directory/Library/WebServer/Documents and add an info.php document.

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

Finally go to your http://localhost/info.php to see the test below. If you see relevant information, it means it has been installed.

Recommended learning: "PHP Video Tutorial"

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

Related labels:
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