MacOSXMavericksorYosemite install Nginx, PHP, Mysql,

Source: Internet
Author: User
Tags install homebrew php cli test web server
Translation: blog. frd. mninstall-nginx-php-fpm-mysql-and-phpmyadmin-on-OS-x-mavericks-using-homebrew recently made Ubuntu very uncomfortable. First, it was difficult to use the input method, sogou released Ubuntu14.04's input method, but it is far from easy to use in Win. Second, I don't have qq, so I have to contact my colleagues at the company.

Http://blog.frd.mn/install-nginx-php-fpm-mysql-and-phpmyadmin-on-os-x-mavericks-using-homebrew/ Ubuntu recently used very uncomfortable, the first is the input method is very difficult to use, said sogou released Ubuntu14.04 input method, but far from Win input method is easy to use. Second, I don't have qq, so I have to contact my colleagues at the company.

Http://blog.frd.mn/install-nginx-php-fpm-mysql-and-phpmyadmin-on-os-x-mavericks-using-homebrew/
Recently, Ubuntu is very uncomfortable to use. First, it is difficult to use the input method. sogou released the Ubuntu input method, but it is far from easy to use in Win. Second, there is no qq, it is very difficult to communicate with colleagues in the company, although qq can chat on the web page, but it is not enough to pass a file. Without many applications, it is difficult to use the Web version. In short, Ubuntu is uncomfortable. So I moved the dusty Mac Mini in my house to the company's elegant writing program.

First, I upgraded my Mac to Mac10.10.1 OS X Yosemite (you can upgrade it free of charge in the App Store ). Then Xcode will upgrade to the latest version of Version6.1, and finally install (or update) Xcode Command Line Tools.

Install Xcode Command Line Tools

Open the terminal, enter the following command, press enter, and a box will pop up. Click Install to continue.

xcode-select --install

After the installation is complete, open Xcode, go to Preferences-> Locations, and check whether Xcode Command Line Tools is the latest version.
Mine is like this.

Make sure you are using Xcode 6.1! Then install homebrew

Homebrew

Homebrew in Mac is equivalent to apt-get and yum in Linux, and various installation packages of the latest version can be obtained.

First, you need Xquartz

curl http://xquartz-dl.macosforge.org/SL/XQuartz-2.7.7.dmg -o /tmp/XQuartz.dmgopen /tmp/XQuartz.dmg

Run the following command to install homebrew:

ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"

After the installation is complete, run the following command to check whether the installation is successful

brew doctor

Then update and upgrade the brew source.

brew update && brew upgrade
PHP-FPM

Because brew does not include php-fpm by default, you must add

brew tap homebrew/dupesbrew tap homebrew/php

Run the following command to install php and php-fpm, which may take a long time.

brew install --without-apache --with-fpm --with-mysql php55
Set PHP CLI

If you want to run php In the command line, you need to change the environment variable in the bash shell.
# If you use Bash

echo 'export PATH="$(brew --prefix homebrew/php/php55)/sbin:$PATH"' >> ~/.bash_profile && . ~/.bash_profile

# If you use ZSH

echo 'export PATH="$(brew --prefix homebrew/php/php55)/sbin:$PATH"' >> ~/.zshrc && . ~/.zshrc
Enable php automatically
mkdir -p ~/Library/LaunchAgentscp /usr/local/opt/php55/homebrew.mxcl.php55.plist ~/Library/LaunchAgents/
Run php-fpm
launchctl load -w ~/Library/LaunchAgents/homebrew.mxcl.php55.plist
Check that php-fpm listens to port 9000.
lsof -Pni4 | grep LISTEN | grep php

Output:
Php-fpm 69659 frdmn 6u IPv4 0x8d8ebe505a1ae01 0t0 TCP 127.0.0.1: 9000 (LISTEN)
Php-fpm 69660 frdmn 0u IPv4 0x8d8ebe505a1ae01 0t0 TCP 127.0.0.1: 9000 (LISTEN)
Php-fpm 69661 frdmn 0u IPv4 0x8d8ebe505a1ae01 0t0 TCP 127.0.0.1: 9000 (LISTEN)
Php-fpm 69662 frdmn 0u IPv4 0x8d8ebe505a1ae01 0t0 TCP 127.0.0.1: 9000 (LISTEN)

Mysql

Run the following command to install Mysql

brew install mysql

Set automatic restart

ln -sfv /usr/local/opt/mysql/*.plist ~/Library/LaunchAgents

Enable Database Service

launchctl load ~/Library/LaunchAgents/homebrew.mxcl.mysql.plist
Security Settings

Run the following command to delete anonymous users and disable remote root logon.

mysql_secure_installation> Enter current password for root (enter for none):

If the root password is not set, press Enter.

> Change the root password? [Y/n]

Press enter and enter your root password.

> Remove anonymous users? [Y/n]

Press enter.

> Disallow root login remotely? [Y/n]

Press enter.

> Remove test database and access to it? [Y/n]

Press enter.

> Reload privilege tables now? [Y/n]

Press enter to refresh the permission.

Test Database Connection
mysql -u root -p

Enter the root password:

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.mysql>

Exit

/qBye
PhpMyAdmin

First install autoconf

brew install autoconf

Set $ PHP_AUTOCONF

# If you use Bashecho 'PHP_AUTOCONF="'$(which autoconf)'"' >> ~/.bash_profile && . ~/.bash_profile# If you use ZSHecho 'PHP_AUTOCONF="'$(which autoconf)'"' >> ~/.zshrc && . ~/.zshrc

Install phpMyAdmin

brew install phpmyadmin
Nginx

Install Nginx

brew install nginx

Set Self-start

sudo cp -v /usr/local/opt/nginx/*.plist /Library/LaunchDaemons/sudo chown root:wheel /Library/LaunchDaemons/homebrew.mxcl.nginx.plist
Test Web Server

Start nginx

sudo launchctl load /Library/LaunchDaemons/homebrew.mxcl.nginx.plist

Now listening to port 8080 by default, run the following command to test

curl -IL http://127.0.0.1:8080

Output:

HTTP/1.1 200 OK
Server: nginx/1.6.2
Date: Mon, 19 Oct 2014 19:07:47 GMT
Content-Type: text/html
Content-Length: 612
Last-Modified: Mon, 19 Oct 2014 19:01:32 GMT
Connection: keep-alive
ETag: "5444dea7-264 ″
Accept-Ranges: bytes

Stop Nginx Service
sudo launchctl unload /Library/LaunchDaemons/homebrew.mxcl.nginx.plist
Configure to create nginx folders and configuration files

Original article address: Install Nginx, PHP, and Mysql on Mac OS X Mavericks or Yosemite. Thank you for sharing your thanks.

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.