Home Backend Development PHP Tutorial Share detailed tutorials on perfectly installing PHP7 on Mac systems

Share detailed tutorials on perfectly installing PHP7 on Mac systems

Jun 16, 2017 am 10:54 AM

This article mainly introduces the detailed tutorial for the perfect installation of PHP7 on Mac system. Friends who need it can refer to it

After PHP released version 5.6, I have been waiting until the leap-forward PHP7 version is released. Then the question arises Okay, where is version 6? According to the official statement, the current PHP7 is twice as fast as PHP5.6. Some friends say it is ten times faster. Anyway, it is faster. I am used to Mac system, so I will explain in detail how to install PHP7 on Mac system!

Generally there are several ways to install it.

First, we can go to the official website and download the source code to compile. I also tried this method, but in the end I compiled and installed make test. At this step, an error was reported, so I boldly tried the second method!

Second, use the third-party package homebrew to install, which is very fast and effective!

Installation tutorial:

1. First we need to install Homebrew

One command to install perfectly :http://brew.sh/index_zh-cn.html

2. Enter the following command in the terminal

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

// 创建目录,如果你没有创建过该目录

sudo mkdir /usr/local/var

sudo chmod 777 /usr/local/var

//修改成你自己的用户名和组,如果你没有创建过该目录

sudo mkdir /usr/local/sbin/

sudo chown -R <username>:<group> /usr/local/sbin//由于我本身一直在使用5.6版本,故上述步骤省略,下面进入正题

//添加PHP库

brew tap homebrew/dupes

brew tap homebrew/versions

brew tap homebrew/homebrew-php

//关闭老版本的PHP56或55或更早版本 进程

brew unlink php56

//开始安装PHP7

brew install php70

//开启PHP70进程

brew link php70

//输入命令,查看是否成功

php -v

//成功后显示下面信息

PHP 7.0.8 (cli) (built: Jul 13 2016 15:19:21) ( NTS )

Copyright (c) 1997-2016 The PHP Group

Zend Engine v3.0.0, Copyright (c) 1998-2016 Zend Technologies

Copy after login

3. Modify the Apache configuration file

1

2

3

4

sudo vim /etc/apache2/httpd.conf

//找到大约168行,该语句,屏蔽后,根据自己的路径,添加php7的.so文件

#LoadModule php5_module libexec/apache2/libphp5.so

LoadModule php7_module /usr/libexec/apache2/libphp7.so

Copy after login

Explain, my libphp7.so file directory is this, it seems to be installed by default Result

LoadModule php7_module /usr/local/Cellar/php70/7.0.0-rc.4/libexec/apache2/libphp7.so

4. Restart Apache

1

sudo apachectl restart

Copy after login

5. If you find that the php file is output directly to the browser, then you need to modify the following configuration

1

sudo vim /etc/apache2/httpd.conf

Copy after login

Find the line Include /private/etc/apache2/other/*.conf

Enter this file

Modify the file content to the following code:

1

2

3

4

5

6

7

<IfModule php7_module>

AddType application/x-httpd-php .php

AddType application/x-httpd-php-source .phps

<IfModule dir_module>

DirectoryIndex index.html index.php

</IfModule>

</IfModule>

Copy after login

6. Restart apache again and repeat step 4

to your Apache’s default directory/Library/WebServer/Documents Next, add an info.php file.

1

2

3

<?php

phpinfo();

?>

Copy after login

http://localhost/info.php The long-lost scene should be in front of you!

Experiments from Qianfeng PHP You can try it multiple times. Then the problem comes. After installation, the previous project may be inaccessible. Check it out. There is a problem with MySQL. Then just restart your mysql is enough!

1

sudo /Library/StartupItems/MySQLCOM/MySQLCOM restart

Copy after login

Finally

Let me know how to add the mysql path to the environment variable on Mac

1. Open the terminal and enter: cd ~

will enter the ~ folder

2. Then enter: touch .bash_profile

After pressing Enter to execute,

3. Then enter: open -e .bash_profile

will open this file in TextEdit (if it was previously If no environment variables have been configured, this should be a blank document). If there is content, please enter it before the end character. If there is no content, please enter the following statement directly:

1

export PATH=${PATH}:/usr/local/mysql/bin

Copy after login

The above is the detailed content of Share detailed tutorials on perfectly installing PHP7 on Mac systems. For more information, please follow other related articles on the PHP Chinese website!

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

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

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. Best Graphic Settings
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. How to Fix Audio if You Can't Hear Anyone
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
WWE 2K25: How To Unlock Everything In MyRise
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

How to install Android apps on Linux? How to install Android apps on Linux? Mar 19, 2024 am 11:15 AM

Installing Android applications on Linux has always been a concern for many users. Especially for Linux users who like to use Android applications, it is very important to master how to install Android applications on Linux systems. Although running Android applications directly on Linux is not as simple as on the Android platform, by using emulators or third-party tools, we can still happily enjoy Android applications on Linux. The following will introduce how to install Android applications on Linux systems.

How to set up WeChat Mac to automatically convert voice messages into text - How to set up voice to text conversion How to set up WeChat Mac to automatically convert voice messages into text - How to set up voice to text conversion Mar 19, 2024 am 08:28 AM

Recently, some friends have consulted the editor about how to set up WeChat Mac to automatically convert voice messages into text. The following is a method for setting up WeChat Mac to automatically convert voice messages into text. Friends in need can come and learn more. Step 1: First, open the Mac version of WeChat. As shown in the picture: Step 2: Next, click &quot;Settings&quot;. As shown in the picture: Step 3: Then, click &quot;General&quot;. As shown in the picture: Step 4: Then check the option &quot;Automatically convert voice messages in chat to text&quot;. As shown in the picture: Step 5: Finally, close the window. As shown in the picture:

3 Ways to Convert HEIC Photos to JPG on Mac 3 Ways to Convert HEIC Photos to JPG on Mac Mar 15, 2024 pm 08:43 PM

By default, iPhone takes photos from the camera in HEIC format. HEIC stands for High Efficiency Image Container and can hold more pixel data than PNG or JPG files, taking up significantly less space on iPhone storage compared to other formats. These files work best on iPhones but are not widely accepted on the internet because they often result in blurry/grainy pictures when you share them with non-Apple devices. To ensure that HEIC images are compatible on other devices, you may need to convert them to JPG format. This article will introduce how to convert HEIC images to JPG on Mac. How to Convert HEIC Photos to JPG on Mac [3 Methods] Method

How to install Podman on Ubuntu 24.04 How to install Podman on Ubuntu 24.04 Mar 22, 2024 am 11:26 AM

If you have used Docker, you must understand daemons, containers, and their functions. A daemon is a service that runs in the background when a container is already in use in any system. Podman is a free management tool for managing and creating containers without relying on any daemon such as Docker. Therefore, it has advantages in managing containers without the need for long-term backend services. Additionally, Podman does not require root-level permissions to be used. This guide discusses in detail how to install Podman on Ubuntu24. To update the system, we first need to update the system and open the Terminal shell of Ubuntu24. During both installation and upgrade processes, we need to use the command line. a simple

How to Install and Run the Ubuntu Notes App on Ubuntu 24.04 How to Install and Run the Ubuntu Notes App on Ubuntu 24.04 Mar 22, 2024 pm 04:40 PM

While studying in high school, some students take very clear and accurate notes, taking more notes than others in the same class. For some, note-taking is a hobby, while for others, it is a necessity when they easily forget small information about anything important. Microsoft's NTFS application is particularly useful for students who wish to save important notes beyond regular lectures. In this article, we will describe the installation of Ubuntu applications on Ubuntu24. Updating the Ubuntu System Before installing the Ubuntu installer, on Ubuntu24 we need to ensure that the newly configured system has been updated. We can use the most famous &quot;a&quot; in Ubuntu system

Detailed steps to install Go language on Win7 computer Detailed steps to install Go language on Win7 computer Mar 27, 2024 pm 02:00 PM

Detailed steps to install Go language on Win7 computer Go (also known as Golang) is an open source programming language developed by Google. It is simple, efficient and has excellent concurrency performance. It is suitable for the development of cloud services, network applications and back-end systems. . Installing the Go language on a Win7 computer allows you to quickly get started with the language and start writing Go programs. The following will introduce in detail the steps to install the Go language on a Win7 computer, and attach specific code examples. Step 1: Download the Go language installation package and visit the Go official website

How to format a drive using GUID on Mac How to format a drive using GUID on Mac Apr 12, 2024 am 09:13 AM

Formatting the drive of your Mac system is crucial for proper functioning. It helps prevent various system problems and makes your Mac more stable overall. While naturally Mac supports various partitioning schemes, GUID offers more modern and versatile features compared to other options. Also essential for newer Macs and supports larger drives, giving you the best compatibility and stability. This guide will take an in-depth look at how to format a drive using a GUID on macOS. That said, let's get started. Why GUID is important for macOS installation A GUID (full form of Globally Unique Identifier) ​​is a partitioning scheme that helps install and run the macOS operating system. It is better than traditional MBR (main lead

How to post to Moments on WeChat Mac - How to post to Moments on WeChat Mac How to post to Moments on WeChat Mac - How to post to Moments on WeChat Mac Mar 18, 2024 pm 05:43 PM

Friends, do you know how to post Moments on WeChat Mac? Today I will explain how to post Moments on WeChat Mac. If you are interested, come and take a look with me. I hope it can help everyone. Step 1: After opening WeChat, click the Moments button on the left. Step 2: Next, click the camera button on the upper right side. Step 3: Enter the text content you want to send. Step 4: Next, click on who can watch. Step 5: In the pop-up box, select the viewable conditions and click OK. Step 6: Finally, click the Publish button.

See all articles