Building a development environment for PHP (detailed graphic and text explanation)
This article mainly introduces how to build PHP under Mac Development environment tutorial, Mac OS X has built-in Apache and PHP, which is very convenient to use. This article takes Mac OS X 10.6.3 as an example. Friends who need it can refer to
Mac OS This article takes Mac OS X 10.6.3 as an example. The main contents include:
(1) Start Apache
(2) Run PHP
(3) Install MySQL
(4) Use phpMyAdmin
(5) Configure PHP’s MCrypt extension library
(6) Set up virtual host
1. Start Apache
There aretwomethods:
Open "System Preferences" -> "Sharing" -> "Web Sharing"
Open "terminal", and then (note: the password required for sudo is System root account password)
Run "sudo apachectl start", and then enter the account password, so that Apache will run.
Run "sudo apachectl -v", you will see the Apache version number in Mac OS X 10.6.3:
Server version: Apache/2.2.14 (Unix)
Server built: Feb 11 2010 14:40:31
In this way, enter "http://localhost" in the browser, you can see a message with the content "It works!" page, which is located under "/Library/WebServer/Documents/", which is the default root directory of Apache.
Note: Turning on Apache means turning on "Web Sharing". At this time, networked users will access "/Library (resource library)/WebServer/" through "http://[local IP]/" Documents/" directory, access the "/Users/[user name]/Sites/" directory through "http://[local IP]/~[user name]", you can set the "Security ( "Firewall" in "Security" to prevent this access.
2. Run PHP
1. Run "sudo vi /etc/apache2/httpd.conf" in the terminal to open the Apache configuration file.(If you are not used to operating terminals and vi, you can set it to display all system hidden files in Finder. Remember to restart Finder, so that you can find the corresponding files and edit them as you like, but you need to pay attention to the modification of certain files. You need to open the root account, but overall it is safer to use sudo on the terminal to temporarily obtain root permissions.)
Find "#LoadModule php5_module libexec/apache2/libphp5.so" and remove the # sign in front. Save (enter: w on the command line) and exit vi (enter: q on the command line).
Simple: Go directly to the path of /etc/apache2/httpd.conf to open the httpd.conf configuration file, and then search globally to find "#LoadModule php5_module libexec/apache2/libphp5.so", remove the # and you can .
2. Run "sudo cp /etc/php.ini.default /etc/php.ini" so that you can configure various PHP functions through php.ini.
To put it simply, go directly to the /etc/php.ini.default path to find a copy of the php.ini.default file, and change the name to php.ini (used to configure various PHP functions Used)
For example: adjust the maximum value of PHP submitted files through the following two items, such as the maximum value of imported data in phpMyAdmin
upload_max_filesize = 2M
post_max_size = 8M
;For example, use display_errors to control whether to display errors of the PHP program
display_errors = Off
3. Run "sudo apachectl restart" to restart Apache so that PHP can be used .
Run "cp /Library/WebServer/Documents/index.html.en /Library/WebServer/Documents/info.php", that is, copy the index.html.en file in the root directory of Apache And rename it to info.php
Run "vi /Library/WebServer/Document/info.php" in the terminal, so that you can edit the info.php file in vi. Add " " after "It's works!" and save it. In this way, you can see information about PHP in http://localhost/info.php, for example, the version number is 5.3.1.
To put it simply, go directly to the /Library/WebServer/Documents/index.html.en path to find the index.html.en file, change the name to index.php
and edit the index. php is the following code:
4. Interface demonstration
Enter http:/ in the browser /localhost/index.php, the following screen appears indicating that the basic PHP environment has been set up.
#Thank you all for reading, I hope you will benefit a lot.
The above content refers to this article to build http://www.cnblogs.com/On1Key/p/5799522.html
Recommended tutorial: "php tutorial"
The above is the detailed content of Building a development environment for PHP on Mac (detailed explanation with pictures and text). For more information, please follow other related articles on the PHP Chinese website!