[mac系统使用brew配置nginx php mysql]mac系统使用brew配置nginx+php+mysql+PostgreSQL步骤

更新时间:2020-01-31    来源:PostgreSQL    手机版     字体:

【www.bbyears.com--PostgreSQL】

今天由于工作需要,必须在OSX下配置PHP的开发运行环境,经过一番折腾,终于搞定了!主要参考了Install Nginx, PHP-FPM, MySQL and phpMyAdmin on OS X Mavericks or Yosemite这篇文章,推荐英文好的同学直接看原文。

下面记录一下!(请按照顺序配置)

 

I. zsh

 

请参考zsh + oh-my-zsh 默认shell的最佳替代品

II. xcode

 

xcode里面包含了很多命令行工具,为我们后续的操作提供技术支持!所以第一件事情就是安装最新版的xcode,请在Mac App Store中自行安装!

安装完毕后运行一下,然后同意协议,稍等片刻,等安装完毕后关闭xcode,最后运行

 

xcode-select --install

 

进入下一阶段!

III. Brew

第二步请确认你是否已经安装了OSX下的包管理工具brew了!如果没有安装,请移步http://brew.sh/速度安装好!

IV. PHP

 

有了brew,剩下的问题就很简单了!我们先添加水龙头(软件源)

 

brew tap homebrew/dupes
brew tap homebrew/php

 

基础安装

 

brew install --without-apache --with-fpm --with-mysql php56


如果你有更多的需求,可以搜索包库,直接安装你想要的包,比如需要添加pdo,我们不需要重新编译php,而是这样子!

 

brew search php56

brew install php56-pdo

 

系统路径

安装完毕后,我们想要将php加入系统路径,我们可以先查看brew安装php的路径

 

brew --prefix homebrew/php/php56

 

然后加入系统路径:

临时加入:

 

export PATH="$(brew --prefix homebrew/php/php56)/bin:$PATH"
或者永久:

# If you use Bash   
echo 'export PATH="/usr/local/sbin:$PATH"' >> ~/.bash_profile
. ~/.bash_profile

# If you use ZSH
echo 'export PATH="/usr/local/sbin:$PATH"' >> ~/.zshrc
. ~/.zshrc

 

开机启动

 

mkdir -p ~/Library/LaunchAgents
ln -sfv /usr/local/opt/php56/homebrew.mxcl.php56.plist ~/Library/LaunchAgents/

 

启动PHP-FPM

 

launchctl load -w ~/Library/LaunchAgents/homebrew.mxcl.php56.plist

launchctl unload -w ~/Library/LaunchAgents/homebrew.mxcl.php56.plist


配置文件

配置文件位于/usr/local/etc/php/5.6/,看看吧!

查看运行

 

lsof -Pni4 | grep LISTEN | grep php
V. mysql

brew install mysql

 

开机启动

 

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

 

运行mysql

 

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

 

开始安全配置

 

mysql_secure_installation
VI. nginx

brew install nginx

 

自动启动

 

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

 

运行NGINX

 

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

本文来源:http://www.bbyears.com/shujuku/85048.html

热门标签

更多>>

本类排行