Home > Backend Development > PHP Tutorial > Super simple tutorial on setting up a PHP environment on Mac

Super simple tutorial on setting up a PHP environment on Mac

angryTom
Release: 2023-04-08 07:08:01
forward
4495 people have browsed it

Super simple tutorial on setting up a PHP environment on Mac

Enable the Apache service

The Mac system comes with the Apache service, you just need to enable it. Open the terminal and enter the following command to start the Apache service.

sudo apachectl start
Copy after login

Open the browser and enter http://localhost in the address bar. If It Works appears, it means the Apache service is started successfully.

Super simple tutorial on setting up a PHP environment on Mac


The default root directory of Apache’s website server is in the path below. Recommended: "PHP Tutorial"

/Library/WebServer/Documents
Copy after login

The page opened above is the source file accessed: /Library/WebServer/Documents/index.html.en

Configure PHP environment

Mac system also comes with its own PHP environment, just open it.
Edit file /etc/apache2/httpd.conf Find the following line, then remove the # comment in front, and save it.

LoadModule php*_module libexec/apache2/libphp*.so
Copy after login

Where * represents the PHP version on your machine.

Create a new file named phpinfo.php under /Library/WebServer/Documents, enter the following code in it, and save it.

<?phpphpinfo();?>
Copy after login

Open the browser and enter http://localhost/phpinfo.php in the address bar. If the following message pops up, it means that the PHP environment is configured successfully.

Super simple tutorial on setting up a PHP environment on Mac


Done!

For more PHP related knowledge, please visit PHP Chinese website!

The above is the detailed content of Super simple tutorial on setting up a PHP environment on Mac. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:jianshu.com
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