Configure the php development environment on Mac: Apache + php + MySql + phpmyadmin, apachephpmyadmin
1. Start Apache
There are two methods
1. Enable network sharing
Open "system preference settings"-> "share", and tick before "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
2. run PHP
1. Find the Apache configuration file, go to the/etc/apache2/directory, open the Finder, select "go to"-"Go to folder", and enter "/etc/apache2 /", find "httpd. conf "file, select open with document for editing, click Command + F, search # LoadModule php5_module libexec/apache2/libphp5.so, remove the # Number of the row, and then save, 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 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
PHP can be used.
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 <? Php phpinfo () ;?>, Restart Apache again and enter http: // localhost/info. php In the browser. A page showing php information appears ,.
3. Configure MySql
1. On the http://dev.mysql.com/downloads/mysql/website, select the Mac OS X platform and select download from the figure,
After you double-click the dmg file to install MySql, you can choose to start or disable 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
4. 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'] = '2017. 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 personally verify it ).