How to build the basic runtime environment of php on 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
Enter http: // localhost in the browser to display an html webpage.
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 ).
Make the following configuration (this is mainly for 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"
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.