How to build PHP's basic operating environment on Mac Machine
1, first Mac OS X built-in Apache and PHP
Check the method that contains PHP: in terminal input
-v
Detect if Apache is already available: in terminal input sudo apachectl-v
sudo apachectl -v
2, enter http://localhost in the browser will appear an HTML page
3, now we want to configure it to display PHP pages
Run "sudo vi/etc/apache2/httpd.conf" in the terminal to open the Apache configuration file. (If you are not accustomed to the terminal and VI can be set in the Finder to display all the system hidden files, remember the need to restart the Finder, so that you can find the corresponding files, edit as you like, but you need to note that some of the file changes need to open the root account, But on the whole it is safe to use sudo on the terminal to temporarily gain root privileges. )
Find "#LoadModule php5_module libexec/apache2/libphp5.so", remove the previous #, Save (enter: W at the command line) and Exit VI (enter: Q on the command line).
4, do the following configuration (this is mainly for the post-site configuration, temporarily can not configure)
Run "sudo cp/etc/php.ini.default/etc/php.ini" so that you can configure various PHP functions via php.ini. Like what:
The maximum value of the PHP commit file is adjusted by the following two items, such as the maximum value of the imported data in phpMyAdmin
Upload_max_filesize = 2M
Post_max_size = 8M
, such as using display_errors to control whether or not to display the PHP program error
Display_errors = Off
Run "sudo apachectl restart" and restart Apache so PHP is ready to use.
Run "cp/library/webserver/documents/index.html.en/library/webserver/documents/info.php", That is, copy the Index.html.en file and rename it to info.php in the root directory of Apache.
Run "vi/library/webserver/document/info.php" in the terminal so that you can edit the info.php file in VI. In "It s works!" Add the following "
5, now let's create a PHP file, but this file must be placed in the Apache directory:/library/webserver/document/
Create a helloworld.php
echo 'Hello World!';?>
Then enter in the browser: http://localhost/helloworld.php