The contents of configuring Apache+php+mysql in Mac OS X 10.8 include:
- Configure Apache
- Configure PHP
- Install MySQL
- Configure Phpadmin
- Set the database default character set
I. Configuring Apache
1. Launch Apache
Open Terminal, enter:
Open the browser and enter:
You should see "It works!" Page, which is located in the/library/webserver/documents/directory, which is the default root directory for Apache.
2. Configure user access to Directory
In the terminal, enter:
mkdir ~/Sites cp /Library/WebServer/Documents/index.html.en index.html |
Create a new directory named sites in the user directory, as the access path to the user directory, and copy the/library/webserver/documents/index.html to the user directory
Input:
Cd/etc/apache2/users/sudo VI apple.conf
Note: Where Apple is your user name.
In VI, press I to start typing, and enter the following:
<Directory "/Users/apple/Sites/" > Options Indexes MultiViews AllowOverride All Order allow,deny Allow from all </Directory> |
When the input is complete, press ESC, then enter: Wq, save and Close VI.
Note: The first line of the file is used to specify the location of the user directory, where Apple is your user name.
In the terminal, enter:
To restart Apache, you can access it in the browser at this time:
Two. Configure PHP
In the terminal, enter:
cd /etc/apache2/ sudo vi httpd.conf |
In VI, enter/php to search for text containing PHP and find:
#LoadModule php5_module libexec/apache2/libphp5.so |
Delete the previous # and then save the exit. (Press Shift+i to enter, press ESC to exit edit, press X to delete the current character, and #, enter: Wq, save and exit.) )
In Terminal input:
cd /etc sudo cp php.ini. default php.ini sudo apachectl restart |
In Terminal input:
Then enter the following in the info.php:
In the browser input:
http: //localhost/~apple/info.php |
Three. Install MySQL
1. Download MYSQL-5.6.12-OSX10.7-X86_64.DMG from the official MySQL website and double-click to open the DMG file.
2. Run mysql-5.6.12-osx10.7-x86_64.pkg, install the main package;
3. Run mysqlstartupitem.pkg, let MySQL boot automatically run;
4. Run Mysql.prefpane to add MySQL service management options to System preferences;
In Terminal input:
sudo chmod +w bashrcsudo VI/ETC/BASHRC
Add the following two command aliases at the end of the BASHRC to make it easy to use MySQL quickly
#mysql alias mysql= ‘/usr/local/mysql/bin/mysql‘ alias mysqladmin= ‘/usr/local/mysql/bin/mysqladmin‘ |
Tip: After you add a command alias in BASHRC, you need to restart the terminal.
To modify the MySQL default password, enter in the terminal:
mysqladmin -u root password "123" |
Where 123 positions You can specify any password.
If you want to change the password you can enter
mysqladmin-u root-p Password "123"
You need to enter the correct password before changing the password.
Four. Configure Phpadmin
1. Download the phpadmin, unzip to the ~/sites directory, and rename the directory to: phpMyAdmin;
2. In the browser, enter:
http: //localhost/~apple/phpmyadmin/setup/ |
Add a server configuration.
Five. Set the database default character set
In Terminal input:
mysql -u root -p # 创建名为 mydb 的数据库 create database mydb; # 将 mydb 的默认字符集设置为 utf8 alter database mydb default character set = utf8; |
Note: MySQL defaults to use the character set is Latin1, does not support Chinese, need to set a bit OH.
Fix it:)
P.S.
Online about the configuration of Php+mysql on Mac documents more, this article only for my use requirements, simple to record the steps. :)
Configure Apache + PHP + MySQL in mac OS X 10.8