Configure Apache + PHP + MySQL in mac OS X 10.8

Source: Internet
Author: User
Tags phpmyadmin

The contents of configuring Apache+php+mysql in Mac OS X 10.8 include:

    1. Configure Apache
    2. Configure PHP
    3. Install MySQL
    4. Configure Phpadmin
    5. Set the database default character set

I. Configuring Apache

1. Launch Apache

Open Terminal, enter:

sudo apachectl start

Open the browser and enter:

http://localhost

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 ~/Sitescp /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 fromall</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:

sudo apachectl restart

To restart Apache, you can access it in the browser at this time:

http://localhost/~apple

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 /etcsudo cp php.ini.defaultphp.inisudo apachectl restart

In Terminal input:

cd ~/Sitesvi info.php

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

#mysqlalias 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 的默认字符集设置为 utf8alter database mydb defaultcharacter 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

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.