Mac install PHP nginx mysql

Source: Internet
Author: User
Tags fpm install php install homebrew vars fpms

Under the Mac install PHP nginx mysql root Linux almost, we recommend that you use the Brew Management kit installation.

1, install homebrew

Http://brew.sh/index_zh-cn.html

The installation method will change, so install the official method above to load. Installing Homebrew-cask

    1. $ brew Tap Caskroom/cask

Homebrew-cask installs something, more.

2, change the source or add agent

Brew Management Toolkit, which is downloaded from GitHub by default, is often used by walls. and turtle speed.

View copy print?
    1. $ Brew Install Git
    2. $ cd/usr/local/homebrew
    3. $ git Remote Set-url origin https://git.coding.net/homebrew/homebrew.git

If you do not want to change the source, you can add agent, if your agent, not by the wall, and relatively fast

View copy print?
    1. Zhangyingdemacbook-pro:homebrew zhangying$ Cat ~/.CURLRC
    2. socks5="127.0.0.1:1080"

3, installing Nginx MySQL

    1. $ brew Install Nginx MySQL

4, install PHP

View copy print?
  1. Add an extension library
  2. $ brew Tap Homebrew/dupes
  3. $ brew Tap Homebrew/versions
  4. $ brew Tap homebrew/php
  5. $ Brew Search PHP //View available versions of PHP
  6. $ brew Install PHP54 //install required version
  7. The default is PHP, so the PHP environment to point to the new
  8. $ echo ' Export path= ' $ (brew--prefix homebrew/php/php54)/bin: $PATH "' >> ~/.bash_profile
  9. $ echo ' Export path= ' $ (brew--prefix homebrew/php/php54)/sbin: $PATH "' >> ~/.bash_profile
  10. $ echo ' export path= '/usr/local/bin:/usr/local/sbin: $PATH "' >> ~/.bash_profile
  11. $ source ~/.bash_profile //Update configuration

5, configuration file directory

    1. /usr/local/etc/nginx
    2. /usr/local/etc/php
    3. /usr/local/cellar/mysql/5.7.16

6, start-up, with Nginx as an example

View copy print?
    1. $ ln-s/usr/local/opt/nginx/*.plist ~/library/launchagents/
    2. $ launchctl Load ~/library/launchagents/homebrew.mxcl.nginx.plist //Load
    3. $ launchctl Unload ~/library/launchagents/homebrew.mxcl.nginx.plist //Cancel load

7,sudo No password

View copy print?
    1. $ sudo su
    2. # Visudo
    3. %admin all = Member of Nopasswd:all//admin Group, sudo does not enter password

8, if you do not want to self-start, you can use the startup script

View copy print?
    1. #!/bin/bash
    2. param= $
    3. Start ()
    4. {
    5. #启动nginx
    6. sudo nginx //nginx requires root user to start
    7. #启动mysql
    8. Mysql.server start
    9. #启动php-FPM
    10. fpms= ' ps aux | Grep-i "PHP-FPM" | grep-v grep | awk ' {print $} '
    11. if [!-n "$fpms"]; Then
    12. php-fpm
    13. echo "php-fpm Start"
    14. Else
    15. echo "php-fpm already Start"
    16. Fi
    17. }
    18. Stop ()
    19. {
    20. #停止nginx
    21. sudo nginx-s stop
    22. #停止mysql
    23. Mysql.server stop
    24. #停止php-FPM
    25. fpms= ' ps aux | Grep-i "PHP-FPM" | grep-v grep | awk ' {print $} '
    26. echo $fpms | xargs kill-9
    27. For pid in $fpms; do
    28. if echo $pid | egrep-q ' ^[0-9]+$ '; Then
    29. echo "php-fpm Pid $pid Kill"
    30. Else
    31. echo "$pid is not A php-fpm pid"
    32. Fi
    33. Done
    34. }
    35. Case $param in
    36. ' start ')
    37. start;;
    38. ' Stop ')
    39. stop;;
    40. ' restart ')
    41. Stop
    42. start;;
    43. *)
    44. echo "Usage:./web.sh Start|stop|restart";;
    45. Esac

Mac install PHP nginx mysql

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.