Build PHP environment on "Juincen" Mac

Source: Internet
Author: User

Today is 2017 August 20, into the Yunnan Douen network three days, because the work needs, so read the next PHP, hope in the future to communicate with you learn.

Apache is providing HTTP services.

Setting up a PHP environment on a Mac is really simple and does not require any integrated environment Mamp (mac+apache+mysql+php). The Mac OS system comes with PHP and Apache. We pull up the terminal tool and tap the following command:

Php-v
Apachectl-v

You can see that the PHP version on my computer is 5.6,apache version 2.4.

1. Configure Apache

Then we have to change a place, I create a new folder in the user directory apache-www, for the HTTP service to hold the file (PHP file or HTML file).

Apache has a very important file is httpd.conf, this file in/ect/apache2

To modify the httpd.conf file, tap the command:

sudo vim httpd.conf

File modification of the following two places

LoadModule Php5_module ... This place does not have the previous # number, remove the comment.

Change the path behind DocumentRoot and directory to the newly created folder below the user directory, pointing to it.

There is also a listen 80, you can modify the port number.

and then save. (about how to operate the file in the terminal command line self-baidu ~)

Open the Apache-www folder under the user directory, create a new file index.php, and write a line of code:

<? PHP     Phpinfo ();? >

Open Apache service, Terminal knock Command: (sudo requires root user privileges to open)

sudo apachectl start

Open the browser, enter http://127.0.0.1/index.php, you can access the Apache-www directory under the index.php file, output php some information.

Close Apache service to knock the following command:

sudo apachectl stop

Build PHP environment on "Juincen" Mac

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.