OS X Mavericks 10.9.4 configuration apache+mysql+php Detailed graphics tutorial

Source: Internet
Author: User
Tags socket error phpmyadmin

Many times we need to develop their own programs in the local testing, this time the PHP operating environment is essential, this article is based on the author on the Internet to find some information and their own practice to write out, so that their future reference, but also hope to have the same needs of students can be more a reference.


I use a black apple here, the specific parameters are configured as follows:


Cpu:intel Xeon e3-1230 v2

Motherboard: Asrock B75 Pro 3

Graphics: Colorful Rainbow igame HD5870-GD5 CH Edition

Memory: Shiba 4gb*2 DDR3 1600

System hard drive: crucial/Spotlight M4 64G MSATA (on his own X230, plus a mSATA to SATA)

Storage HDD: Seagate SV35 2TB SATA3 (st2000vx000)

Power: TI-G vp550p

Black Apple Implementation, please visit: http://bbs.feng.com/read-htm-tid-7534160.html


To build the environment:

The first thing to say is that OS X Mavericks itself has integrated the apache+php environment, as long as we can open their own, before the old version (specifically do not remember) you just once into the "system Preferences" → "sharing" and then turn on "web sharing" You can open the Apache service.

650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M02/47/E4/wKioL1QCwMviUfRlAAEM5a3_0HI128.jpg "title=" 2673c92a-8e4c-4d53-b004-5af3c41514b8.png "alt=" Wkiol1qcwmviufrlaaem5a3_0hi128.jpg "/>

However, in this version of the author has been canceled in this graphical setup interface, so I use the command line to open the Apache service.


Turn on apache/web sharing


Open the terminal and run the start Apache command:

sudo apachectl start

To stop a service command:

sudo apachectl stop

Restart command:

sudo apachectl restart

To view the Apache version command:

Httpd-v

The Apache versions integrated in OS X Mavericks are as follows:

imac:~ user$ httpd-vserver version:apache/2.2.26 (Unix) Server built:dec 10 2013 22:09:38

After you open the Apache service, you can access http://localhost or http://127.0.0.1 directly in the browser, if "

It works!" It means the Apache service has been successfully opened!

650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M02/47/E2/wKiom1QCwo7CBGaLAABzUXYv8tU940.jpg "title=" 1dee5174-32f3-42ed-b4e8-787b4ea0f6aa.png "alt=" Wkiom1qcwo7cbgalaabzuxyv8tu940.jpg "/>

Site root directory


After opening the Apache service, we need to know the location of the Web file in the system, if you have the Linux configuration experience should not be unfamiliar. There are two directories in OS X Mavericks that can run your Web program directly, one is the system-level Web root, and the other is the user-level root directory, so keep looking down:


The system-level directory is:

/library/webserver/documents/

The user-level directory is:

~/sites

650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M00/47/E2/wKiom1QCxI_zUKt6AACKLKFGLUk739.jpg "title=" 58b74ea8-1605-488b-b297-0acef6500234.png "alt=" Wkiom1qcxi_zukt6aacklkfgluk739.jpg "/>


~/site is the "site" directory under the current user directory, which may not be available in OS X Mavericks, so a directory with the same name needs to be created manually. The Setup method is simple and is entered directly into the terminal:

sudo mkdir ~/sites

After establishing the "Sites" folder, check if the folder below has "current user name. conf" This file.

/etc/apache2/users/

If not, then you need to create one that is named "Current user name. conf", which can be created using either VI or Nano, one of the two editors.

sudo vi/etc/apache2/users/username.conf

After creation, write the following lines into the Conf file above (note that the information in your environment is modified):

<directory "/users/username/sites/" >options Indexes multiviewsallowoverride allorder allow,denyAllow from all </Directory>

Once the file is saved, the appropriate permissions are given:

sudo chmod 755/etc/apache2/users/username.conf

Next reboot the Apache server:

sudo apachectl restart

At this point you can already access the user-level Web directory via Http://localhost/~username.

(Note: Please change username to your own username)


Open PHP


The PHP 5.4.24 version is integrated in OS X mavericks and needs to be opened manually, and you can open this file with the VI or Nano editor:

sudo vi/etc/apache2/httpd.conf

Then search for "PHP" and find the following sentence:

LoadModule Php5_module libexec/apache2/libphp5.so

Remove the previous # number, then esc:wq! save to exit

This time the user-level Web directory is empty, in order to verify the success of the configuration, here in the "site" directory to create a test file:

VI ~/sites/index.php

Enter the following:

<?php echo phpinfo ();? >

Remember to restart the Apache server:

sudo apachectl restart

This time by: Http://localhost/~username to access the test page.

650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M00/47/E3/wKiom1QC1RPAvHtOAACJD6oOM5I802.jpg "title=" B7f1a0f3-7e08-422e-953c-718bc0f47edb.png "alt=" Wkiom1qc1rpavhtoaacjd6oom5i802.jpg "/>


Install MySQL


MySQL is not integrated in Mavericks and requires manual installation. You can click on this link to download the MySQL installation package, please download Mac OS X ver. 10.6 (x86,64-bit), DMG Archive (can work properly under Mavericks).

650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M01/47/E3/wKiom1QC1gSQFg4AAAHv75HLFkg976.jpg "title=" Snip20120806_5-600x403.png "alt=" Wkiom1qc1gsqfg4aaahv75hlfkg976.jpg "/>

Click to download, will jump to a registration/login page, you do not need to register and do not need to sign in, direct click the Login box below: No Thanks, just take me to the downloads! You can skip this step to start the download directly, the entire DMG package is about 113MB.


After downloading the DMG, double-click you will extract three files and a RedMe.txt document. These three files are:


    • Mysql5.5.xxx.pkg

    • Mysqlstartupitem.pkg

    • Mysqlprefpane

You will need to install each of these three files one after another, and the system may prompt you because the package is from an unidentified developer and cannot be installed. In this case, you can press and hold the command key, then right-click on the installation file, then click "Open" in the context menu, so you can bypass this security limit (you can, of course, change the system Preferences-security and privacy-in general to open "any source" application).


After three files are installed, go to "system Preferences", at the bottom of the panel you will see a MySQL setting, click on it to start MySQL, or you can also open the following command:

Sudo/usr/local/mysql/support-files/mysql.server start

If you want to view the MySQL version, you can use the following command:

/usr/local/mysql/bin/mysql-v

After running the above command, you will log in to MySQL directly from the command line and enter the command \q to exit.


650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M01/47/E3/wKiom1QC1-Sx9lefAAGvUqQdHN4685.jpg "title=" D3cd07a7-0541-40f9-ad9c-d71f7392e56f.png "alt=" Wkiom1qc1-sx9lefaagvuqqdhn4685.jpg "/>


Here MySQL is configured to complete and can be run. But to make it easier to use, you'd better set up the system environment variable, which means that the MySQL command can be started directly on any path (no need to enter a long string of exact paths).


Setting environment variables is also very convenient, directly with the command (here I use VI editor example):

cd; VI. bash_profile

Then press the letter I into the edit mode, the following code is pasted into the sentence:

Export path= "/usr/local/mysql/bin: $PATH"

Then press ESC to exit the editor, and then enter: Wq (don't forget the colon) to save the exit. Of course, if you use the Nano or other editor, the operation may not be the same as this, anyway, it means to write the above sentence into the. bash_profile file.


The next step is to reload the Shell to make the above environment variable effective:

SOURCE ~/.bash_profile

After that you can use the MySQL command in any directory of the terminal, you can run mysql-v to try.


In the final step, you should also set a root user password for your MySQL command as follows:

mysqladmin-u root password ' here to fill in the password you want to set '

(Remember that the password must be wrapped in half-width single quotation marks.)


Above the mysqladmin command, I did not write the full path. Because we have set the environment variables above, if you do not set the environment variables, you need to use/usr/local/mysql/bin/mysqladmin ******** to run.


Installing PhpMyAdmin


Before you install PhpMyAdmin, first fix the 2002 socket error:

sudo mkdir/var/mysqlsudo ln-s/tmp/mysql.sock/var/mysql/mysql.sock

Then go to the PhpMyAdmin website to download the installation package, recommended to download english.tar.gz. After extracting, rename the extracted folder to "phpMyAdmin", and put it in the "site" directory (~/sites) created above. You can then access the phpMyAdmin page from the browser:

Http://localhost/~username/phpmyadmin

(Please change username to your username)


When this is done, you can then visit http://localhost/~username/phpmyadmin/(replacing username with your username) to manage your database through Phpmysql.


The above is a complete tutorial on configuring apache+mysql+php on OS X Mavericks.


This article is from the "Happy Seven Love" blog, please be sure to keep this source http://cnkenny.blog.51cto.com/1217232/1547118

OS X Mavericks 10.9.4 configuration apache+mysql+php Detailed graphics tutorial

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.