Configure the php development environment on Mac: Apache + php + MySql to start Apache
There are two methods
1. enable network sharing
Choose System Preference settings> Sharing, and tick in front of Internet sharing.
2. open the terminal and enter
sudo apachectl start
Enter the password, enter the computer password, and then enter
sudo apachectl -v
You can view Apache version information.
Server version: Apache/2.2.24 (Unix)Server built: Jul 7 2013 18:05:17
Enter http: // localhost in the browser, and It works will appear! Page
Run PHP
1. find the Apache configuration file, open the Finder under the/etc/apache2/directory, select "go"-"Go to Folder", and enter "/etc/apache2 /", find "httpd. conf file, click open with document to edit, click Command + F, search # LoadModule php5_module libexec/apache2/libphp5.so,
Remove the # of the blue line and save it. if the text is locked and cannot be unlocked, there are two solutions:
A) select the file, right-click the File, select "show Introduction", click the small lock icon in the lower right corner, enter the computer password to unlock, and then select the + key on the left, select the user who logs on to the current computer and set the permission to read and write. if it still does not work, change the permission of the folder at the upper level again.
B) copy the file to the desktop, modify it, and copy it to the original folder to replace the previous file.
2. restart Apache and enter
sudo apachectl restart
3. enter
sudo 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.
4. open info. php and add It after It works. And then restart Apache again. enter http: // localhost/info. php in the browser. a page showing php information appears ,.
Configure MySql
1. on the http://dev.mysql.com/downloads/mysql/website, select the Mac OS x platform and select download in the figure. I started downloading. the installation was incorrect. later, the version shown in the download figure was successfully installed.
Double-click the dmg file
Double-click the first installation, double-click the third installation, double-click the second installation, and the second is the configuration file. after installation, you can choose to start or close MySql in system preference settings.
2. change the password
Enter the password on the terminal. here, you can change the password to 12345. you can also customize the password for others.
/usr/local/mysql/bin/mysqladmin -u root password 12345
Use phpMyAdmin
PhpMyAdmin is a MySql management program developed with PHP, which is very practical.
1. download phpMyAdmin at the URL
2. decompress the downloaded file, put it in the/Library/WebServer/Documents/folder, and name it phpmyadmin.
3. copy config. sample. inc. php from/Library/WebServer/Documents/phpmyadmin, name it config. inc. php, and put it in the current folder.
4. edit config. inc. php and modify
$cfg['Servers']]$i]['host'] = 'localhost';
Is
$cfg['Servers']]$i]['host'] = '127.0.0.1';
If you want to log on without a password, change false in the following statement to true.
$cfg['Servers'][$i]['AllowNoPassword'] = false
5. enter http: // localhost/phpmyadmin in the browser, enter the username "root", and the password you just changed. if the password is not changed, follow the password-free operation in the previous step, and then you can log on directly.
PS: After the configuration is complete, you still need to download a php development tool for php Development. There are also a lot of php development tools under mac. you can Google Baidu on your own. Please note, after installing the development tool, remember to put the project in the same directory file as phpmyadmin when suggesting the php project. you can create a new folder to store the php project. otherwise, it cannot be run (I have not personally verified it as instructed by a great god)