Detailed graphic and text explanation of setting up PHP development environment under Macbook Pro

黄舟
Release: 2023-03-07 07:54:01
Original
5412 people have browsed it

新学PHP, it is the first time to set up a PHP development environment on Macbook, so it is recorded and provides a reference for other learning partners.

Tools/Materials

  • Apache 2.4.16

  • ##PHP

  • Macbook Pro

  • MySQL 5.7

Start Apache

First introduce a few commands

// Start Apache service
sudo apachectl start
// Restart the Apache service
sudo apachectl restart
// Stop the Apache service
sudo apachectl s
top // View Apache Version
httpd -v

Mac OS comes with Apache, you just need to start Apache.

1. Open the terminal and enter the command: sudo apachectl start

Detailed graphic and text explanation of setting up PHP development environment under Macbook Pro2. Open the browser and enter localhost in the address bar. If It Works
string appears, it means Apache has been started successfully
Detailed graphic and text explanation of setting up PHP development environment under Macbook Pro3. Under Macbook pro, the root directory of Apache's website server is in the /Library/WebServer/
Documents path
Detailed graphic and text explanation of setting up PHP development environment under Macbook Pro

Configuring PHP

1. Mac OS also comes with PHP. You only need to add Apache’s support for PHP in Apache’s

configuration file in the terminal Enter the command:
sudo vim /etc/apache2/httpd.conf
Open the httpd.conf file

localhost:~ alexkw$ sudo vim /etc/apache2/httpd.conf
Copy after login

2. Remove the

comment symbol from the content marked in the red box. LoadModule php5_module libexec/apache2/libphp5.so
Then save

Detailed graphic and text explanation of setting up PHP development environment under Macbook Pro3. Restart the Apache service

localhost:~ alexkw$ sudo apachectl restart
Copy after login

4. Enter /Library/WebServer/Documents,

In this Create a new test PHP page in the directory and enter the command: sudo vim test.php

Detailed graphic and text explanation of setting up PHP development environment under Macbook Pro5. Enter the following code in test.php

Install MySQL

Use MySQL Workbentch to manage databases on mac

The above is the detailed content of Detailed graphic and text explanation of setting up PHP development environment under 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