First, start Apache
There are two ways
1. Turn on network sharing
Open "System Preferences", "sharing", before "Internet sharing" that item to hit √.
2. Open Terminal, enter
- sudo apachectl start
You need to enter the password, enter the computer password, and then enter
sudo apachectl-v
can view version information for Apache
Server version:apache/2.2.24 (Unix)
Server Built:jul 7 2013 18:05:17
When you enter http://localhost in the browser, the IT works! appears The page
Second, run PHP
1, find the Apache configuration file, in the directory/etc/apache2/, open Finder, select "Go"-"Go to Folder", enter "/etc/apache2/", find the "httpd.conf" file, choose to open with the document to edit, Click Command+f, Search #loadmodule php5_module libexec/apache2/libphp5.so, remove the line's # number, and then save, if there is a text lock, can not unlock the situation, there are two ways to solve
A) Select the file, right-click after selecting "Show Info", click on the lower right corner of the small lock icon, enter the computer password to unlock, and then select the left of the + sign key, select their current computer login user, set the permissions to read and write, if still not, will be the same level folder permissions again modified once.
b) Copy the file to the desktop, modify it, and then copy it to the original folder to replace the previous file.
2. Restart Apache in the terminal input
sudo apachectl restart
PHP is ready for use.
3, in the terminal input
sudo 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.
4. Open info.php, add <?php phpinfo () after it works, and then restart Apache again, enter http://localhost/info.php in the browser, and a page will appear with PHP information.
Third, configure MySQL
1. On the http://dev.mysql.com/downloads/mysql/website, select the Mac OS x platform and select the download in the diagram,
After you double-click the DMG file to install it, you can choose to start or close MySQL in System Preferences.
2. Change the password
In the terminal input, here to change the password is 12345, but also for other, custom can
/usr/local/mysql/bin/mysqladmin-u Root Password 12345
Iv. Use of phpMyAdmin
phpMyAdmin is a PHP-developed program for managing MySQL, very practical
1, download phpMyAdmin, in the URL http://www.phpmyadmin.net/home_page/downloads.php select the appropriate version of the download, I chose the phpmyadmin-4.0.8-all-languages.tar.bz2
2, the downloaded files are extracted, put into the/library/webserver/documents/folder, and named phpMyAdmin.
3. Copy the config.sample.inc.php in/library/webserver/documents/phpmyadmin and name it config.inc.php, and put it under the current folder.
4, edit config.inc.php, modify one of the
$cfg [' Servers ']] $i [' host '] = ' localhost ';
For
$cfg [' Servers ']] $i [' host '] = ' 127.0.0.1 ';
Then, if you want to login without a password, change the false in the following statement to True
$cfg [' Servers '] [$i] [' allownopassword '] = False
5, enter http://localhost/phpmyadmin in the browser, enter the user name "root", and just change the password, if not changed password, then follow the previous step of the no password operation, and then you can directly login.
PS: To this configuration to complete, PHP development also need to download a PHP development tools, Mac PHP development tools are also quite a lot, we Google Baidu, we need to remind that, after installing the development tools, in the proposed PHP project, remember to put the project in and phpmyadmin the same directory file , you can create a new folder specifically for PHP projects, otherwise, it will not work (I personally verify).
Configure the PHP development environment under Mac: Apache+php+mysql+phpmyadmin