Home > Backend Development > PHP7 > Learn the detailed tutorial to perfectly install PHP7 on Mac system

Learn the detailed tutorial to perfectly install PHP7 on Mac system

coldplay.xixi
Release: 2023-02-17 16:46:01
forward
3856 people have browsed it

Learn the detailed tutorial to perfectly install PHP7 on Mac system

##Installation tutorial:

1. Start Apache

First we start the Apache service that comes with the system.

Open Terminal and enter the following command:

// 开启Apache服务
sudo apachectl start
// 查看Apache版本号
sudo apachectl -v
Copy after login
Copy after login

图 Terminal输入命令打开apache服务及查看版本号

Then we verify whether the apache service we opened can be used, open the browser and enter:

http://localhost
Copy after login
Copy after login
Related learning recommendations:

PHP programming from entry to proficiency

Running PHP

Before running our php, we need to change our php Configuration file, open Finder, "Go -> Go to Folder...", enter:

/etc/apache2/
Copy after login
Copy after login
Find our httpd.conf configuration file:


Learn the detailed tutorial to perfectly install PHP7 on Mac system

Use text editing After the configuration file is modified, we only need to restart our Apache service to make the modification take effect. Enter in Terminal:

LoadModule php7_module libexec/apache2/libphp7.so
Copy after login
Copy after login
Next we want to know the version of php on our Mac.

We enter in Terminal: Learn the detailed tutorial to perfectly install PHP7 on Mac system

sudo apachectl restart
Copy after login
Copy after login
to open our info.php file, use a text editor to add after "It works":

// 在Apache的根目录下复制index.html.en文件并重命名为info.php。
sudo cp /Library/WebServer/Documents/index.html.en /Library/WebServer/Documents/info.php
Copy after login
Copy after login
and then restart our Apache again.

After restarting, we enter in the browser URL bar:

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


Learn the detailed tutorial to perfectly install PHP7 on Mac system

## Use the The third-party package homebrew is used to install it, which is very fast and effective! Installation tutorial: 1. Start ApacheFirst we start the Apache service that comes with the system.

Open Terminal and enter the following command:

http://localhost/info.php
Copy after login

Then we verify whether the apache service we opened can be used, open the browser and enter:

// 开启Apache服务
sudo apachectl start
// 查看Apache版本号
sudo apachectl -v
Copy after login
Copy after login

Run PHP

Before running our php, we need to change our php configuration file, open Finder, "Go->Go to Folder...", enter: 图 Terminal输入命令打开apache服务及查看版本号

http://localhost
Copy after login
Copy after login
Find us httpd.conf configuration file:

Use a text editor to uncomment the following line:

/etc/apache2/
Copy after login
Copy after login


Learn the detailed tutorial to perfectly install PHP7 on Mac systemConfiguration After the file is modified, we only need to restart our Apache service for the modification to take effect. Enter in Terminal:

LoadModule php7_module libexec/apache2/libphp7.so
Copy after login
Copy after login

Next we want to know the version of php on our Mac.

We enter in Terminal:

sudo apachectl restart
Copy after login
Copy after login
Learn the detailed tutorial to perfectly install PHP7 on Mac system to open our info.php file, use a text editor to add after "It works":
// 在Apache的根目录下复制index.html.en文件并重命名为info.php。
sudo cp /Library/WebServer/Documents/index.html.en /Library/WebServer/Documents/info.php
Copy after login
Copy after login

and then restart our Apache again.

After restarting, we enter in the browser URL bar:

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

The above is the detailed content of Learn the detailed tutorial to perfectly install PHP7 on Mac system. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:csdn.net
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