How to build a basic php running environment on a mac machine-php Tutorial

Source: Internet
Author: User
How to build a basic php runtime environment on a mac Machine 1. first, MacOSX has built-in Apache and PHP methods to detect the inclusion of php: enter php-v on the terminal to check whether apache exists: enter the sudoapachectl-vsudoapachectl-v2 in the terminal, enter localhost in the browser will show an html web page 3, now we want to configure to make it show p how to build the basic php runtime environment on the mac machine

1. Mac OS X has built-in Apache and PHP

Methods for detecting php inclusion: Enter

php -v

Check whether apache exists: enter sudo apachectl-v on the terminal

sudo apachectl -v

2. enter http: // localhost in the browser to display an html webpage.

3. now we need to configure it to display php web pages.

Run "sudo vi/etc/apache2/httpd. conf" on the terminal to open the Apache configuration file. (If you are not familiar with operating terminal and vi, you can set to display all system hidden files in the Finder. remember to restart the Finder so that you can find the corresponding file and edit it as you like, note that you need to enable the root account to modify some files, but it is safer to use sudo on the terminal to temporarily obtain the root permission .)
Find "# LoadModule php5_module libexec/apache2/libphp5.so", remove the # sign, save it (enter w in the command line), and exit vi (enter q in the command line ).

4. make the following configuration (this is mainly for the later website configuration, you do not need to configure it now)

Run "sudo cp/etc/php. ini. default/etc/php. ini" to configure various php functions through PHP. ini. For example:
Use the following two items to adjust the maximum value of the submitted PHP file, for example, the maximum value of imported data in phpMyAdmin.
Upload_max_filesize = 2 M
Post_max_size = 8 M
For example, display_errors is used to control whether the PHP program reports errors.
Display_errors = Off
Run "sudo apachectl restart" and restart Apache so that PHP can be used.
Run "cp/Library/WebServer/Documents/index.html. en/Library/WebServer/Documents/info.php", copy the index.html. en file in the apacheroot directory, and rename it info. php.
Run "vi/Library/WebServer/Document/info. php" on the terminal to edit the info. php file in vi. In "It's works !" Add"

5. now we create a php file, but this file must be placed in the apache Directory:/Library/WebServer/Document/

Create a helloworld. php


  

Enter http: // localhost/helloworld. php in the browser.

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.