首页 技术 正文
技术 2022年11月12日
0 收藏 491 点赞 3,338 浏览 2005 个字

mac下面安装php nginx mysql根linux下面差不多,建议大家使用brew管理工具包安装。

1,安装homebrew

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

安装方法会改变的,所以安装官方上面的方法来装。安装 homebrew-cask

  1. $ brew tap caskroom/cask

homebrew-cask安装的东西,更多。

2,换源或者加代理

brew管理工具包,默认是从github上面下载,github经常被墙。并且龟速。

  1. $ brew install git
  2. $ cd /usr/local/Homebrew
  3. $ git remote set-url origin https://git.coding.net/homebrew/homebrew.git

如果不想换源话,可以加代理,前提是你的代理,不被墙,并且比较快

  1. zhangyingdeMacBook-Pro:Homebrew zhangying$ cat ~/.curlrc
  2. socks5=”127.0.0.1:1080″

3,安装nginx mysql

  1. $ brew install nginx mysql

4,安装php

  1. //添加扩展库
  2. $ brew tap homebrew/dupes
  3. $ brew tap homebrew/versions
  4. $ brew tap homebrew/php
  5. $ brew search php //查看php的可用版本
  6. $ brew install php54 //安装所需版本
  7. //默认是有php的,所以php的环境要指向新的
  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 //更新配置

5,配置文件目录

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

6,开机启动,以nginx为例

  1. $ ln -s /usr/local/opt/nginx/*.plist ~/Library/LaunchAgents/
  2. $ launchctl load ~/Library/LaunchAgents/homebrew.mxcl.nginx.plist   //加载
  3. $ launchctl unload ~/Library/LaunchAgents/homebrew.mxcl.nginx.plist     //取消加载

7,sudo无密码

  1. $ sudo su
  2. # visudo
  3. %admin   ALL = NOPASSWD:ALL  //admin组的成员,sudo不用输入密码了

8,如果不想自启动,可以用启动脚本

    1. #!/bin/bash
    2. param=$1
    3. start()
    4. {
    5. #启动nginx
    6. sudo nginx    //nginx需要root用户来启动
    7. #启动mysql
    8. mysql.server start
    9. #启动php-fpm
    10. fpms=`ps aux | grep -i “php-fpm” | grep -v grep | awk ‘{print $2}’`
    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 $2}’`
    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
相关推荐
python开发_常用的python模块及安装方法
adodb:我们领导推荐的数据库连接组件bsddb3:BerkeleyDB的连接组件Cheetah-1.0:我比较喜欢这个版本的cheeta…
日期:2022-11-24 点赞:878 阅读:9,499
Educational Codeforces Round 11 C. Hard Process 二分
C. Hard Process题目连接:http://www.codeforces.com/contest/660/problem/CDes…
日期:2022-11-24 点赞:807 阅读:5,913
下载Ubuntn 17.04 内核源代码
zengkefu@server1:/usr/src$ uname -aLinux server1 4.10.0-19-generic #21…
日期:2022-11-24 点赞:569 阅读:6,746
可用Active Desktop Calendar V7.86 注册码序列号
可用Active Desktop Calendar V7.86 注册码序列号Name: www.greendown.cn Code: &nb…
日期:2022-11-24 点赞:733 阅读:6,503
Android调用系统相机、自定义相机、处理大图片
Android调用系统相机和自定义相机实例本博文主要是介绍了android上使用相机进行拍照并显示的两种方式,并且由于涉及到要把拍到的照片显…
日期:2022-11-24 点赞:512 阅读:8,142
Struts的使用
一、Struts2的获取  Struts的官方网站为:http://struts.apache.org/  下载完Struts2的jar包,…
日期:2022-11-24 点赞:671 阅读:5,305