Home>Article>Backend Development> Detailed graphic and text explanation of setting up PHP development environment under Macbook Pro

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

黄舟
黄舟 Original
2017-03-30 10:06:21 5326browse

新学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
stringappears, 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 filein the terminal Enter the command:
sudo vim /etc/apache2/httpd.conf
Open the httpd.conf file

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

2. Remove the

commentsymbolfrom 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

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!

Statement:
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