brew的安装:
ruby -e "$(curl -fsSL https://raw.github.com/Homebrew/homebrew/go/install)”
php安装和配置
brew search php55
brew info php55—查看安装时是否需要带上参数--with-fpm
brew install php55 —with-fpm
brew install php-mcrypt(加密用的,不一定要安装的)
安装之后使用php -v查看版本,如果不是你安装的版本需要更改path
执行下列命令更改:
cd
vim .profile
export PATH=/usr/local/bin:$PATH
以下是对php-fpm.conf配置文件的相关修改
1.用户名修改:
user = zhaoye--用户
group = staff—用户组
2.端口
listen = 127.0.0.1:9000=>listen = /opt/run/php.socket(这里的socket是要给以后nginx配置用的)
3.php.ini配置文件修改
date.timezone = Asia/Shanghai
4.找到homebrew-php.josegonzalez.php55.plist (通过brew info php55查找)
拷贝到~/Library/LaunchAgents,因为是端口大于1024的都不是root启动
mv homebrew-php.josegonzalez.php55.plist php-fpm.plist(修改文件名)
修改php-fpm.plist文件
如下可以作为参考
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>KeepAlive</key>
<false/>(这里不能为true,否则一直保持)
<key>Label</key>
<string>php-fpm</string>(启动服务的命令名)
<key>ProgramArguments</key>
<array>
<string>/usr/local/sbin/php-fpm</string>
<string>--fpm-config</string>
<string>/usr/local/etc/php/5.5/php-fpm.conf</string>(读取配置文件的路径)
</array>
<key>RunAtLoad</key>
<true/>
<key>UserName</key>
<string>mac</string>
<key>WorkingDirectory</key>
<string>/usr/local/var</string>
<key>StandardErrorPath</key>
<string>/var/log/php/php-fpm.log</string>
</dict>
</plist>

最后通过
launchctl load -w ~/Library/LaunchAgents/php-fpm.plist
launchctl start php-fpm
启动
到这里php就已经OK了

调试:
可以安装brew install php-xdebug+google_xdebug用来调试
cd /etc/php/5.5/conf.d
给ext-xdebug.ini添加xdebug.remote_enable = On开启调试模式

nginx安装和配置
1.brew install nginx
2.修改nginx的启动plist文件
根据brew info nginx可以看到/usr/local/opt/nginx/homebrew.mxcl.nginx.plist
cp /usr/local/opt/nginx/homebrew.mxcl.nginx.plist /Library/LaunchDaemons/nginx.plist
(nginx是80端口是需要root启动的,所以拷贝到根目录下的Library/LaunchDaemons)
修改nginx.plist文件
参考如下
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Label</key>
<string>nginx</string>(启动服务名)
<key>RunAtLoad</key>
<true/>
<key>KeepAlive</key>
<false/>(被杀掉之后自己能启动)
<key>UserName</key>
<string>root</string>
<key>ProgramArguments</key>
<array>
<string>/usr/local/opt/nginx/bin/nginx</string>(nginx配置路径)
<string>-g</string>
<string>daemon off;</string>
</array>
<key>WorkingDirectory</key>
<string>/usr/local</string>
</dict>
</plist>
3.修改nginx配置文件

cd /usr/local/etc/nginx回到nginx配置文件目录
这里是新建了2个目录site-enabled,site-available用于配置文件(为了升级时减少修改量)
site-available里面存在真正的配置文件,site-enabled里面建链接指向site-available里面的配置文件
具体操作如下:
mkdir sites-enabled
mkdir sites-available
在site-available里面添加配置文件:localhost,test-seekyun.com
修改nginx.conf
参考如下:
user zhaoye admin;
worker_processes 1;

#error_log logs/error.log;
#error_log logs/error.log notice;
#error_log logs/error.log info;

#pid logs/nginx.pid;

events {
worker_connections 1024;
}

http {
include mime.types;
default_type application/octet-stream;

#log_format main '$remote_addr - $remote_user [$time_local] "$request" '
# '$status $body_bytes_sent "$http_referer" '
# '"$http_user_agent" "$http_x_forwarded_for"';

#access_log logs/access.log main;

sendfile on;
#tcp_nopush on;

#keepalive_timeout 0;
keepalive_timeout 65;

#gzip on;

include /usr/local/etc/nginx/sites-enabled/*;

# another virtual host using mix of IP-, name-, and port-based configuration
#
#server {
# listen 8000;
# listen somename:8080;
# server_name somename alias another.alias;

# location / {
# root html;
# index index.html index.htm;
# }
#}

# HTTPS server
#
#server {
# listen 443;
# server_name localhost;

# ssl on;
# ssl_certificate cert.pem;
# ssl_certificate_key cert.key;

# ssl_session_timeout 5m;

# ssl_protocols SSLv2 SSLv3 TLSv1;
# ssl_ciphers HIGH:!aNULL:!MD5;
# ssl_prefer_server_ciphers on;

# location / {
# root html;
# index index.html index.htm;
# }
#}

}

里面的include /usr/local/etc/nginx/sites-enabled/*;标识了
其实际配置是在site-enabled里面,site-enabled里面的
test-seekyun.com -> ../sites-available/test-seekyun.com
是一个软链接指向../sites-available/test-seekyun.com
test-seekyun.com配置文件内容如下:
server {
listen 80;
server_name jk.myseekyun.com;(这里的服务名等下是要在/etc/hosts加上的)

#charset koi8-r;

#access_log logs/host.access.log main;

root /Users/zhaoye/workspace/jkweb;(php代码工程所在的目录)

location / {
index index.html index.htm index.php;
if (!-f $request_filename) {
rewrite ^.*$ /index.php last;
}
}

#error_page 404 /404.html;

# redirect server error pages to the static page /50x.html
#
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}

# proxy the PHP scripts to Apache listening on 127.0.0.1:80
#
#location ~ \.php$ {
# proxy_pass http://127.0.0.1;
#}

# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
#
location ~ \.php$ {
fastcgi_pass unix:/opt/run/php.socket;(这个是和上面php-fpm.conf里面的socket)
include fastcgi_params;
fastcgi_index index.php;
fastcgi_split_path_info ^(.+\.php)(.*)$;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param PATH_INFO $fastcgi_path_info;
}

location /favicon.ico {
error_log /dev/null crit;
return 404;
}

# deny access to .htaccess files, if Apache's document root
# concurs with nginx's one
#
#location ~ /\.ht {
# deny all;
#}
}

localhost配置文件如下:
server {
listen 80;

#charset koi8-r;

#access_log logs/host.access.log main;

root /Users/zhaoye/workspace/;(php代码所在的目录)

location / {
index index.html index.htm index.php;
autoindex on;
}

#error_page 404 /404.html;

# redirect server error pages to the static page /50x.html
#
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}

# proxy the PHP scripts to Apache listening on 127.0.0.1:80
#
#location ~ \.php$ {
# proxy_pass http://127.0.0.1;
#}

# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
#
location ~ \.php$ {
fastcgi_pass unix:/opt/run/php.socket;(这个是和php-fpm.conf名称配置一致)
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}

# deny access to .htaccess files, if Apache's document root
# concurs with nginx's one
#
#location ~ /\.ht {
# deny all;
#}
}
cd site-enabled
ln -s site-available/localhost
ln -s site-available/test-seekyun.com
到这里所有的nginx配置都可以了

4.sudo -s(需要root启动)
launchctl load -w /Library/LaunchDaemons/nginx.plist
launchctl start nginx最后通过launchctl启动nginx服务
launchctl stop nginx关闭nginx服务

mac上php+nginx配置的更多相关文章

  1. Mac上通过docker配置PHP开发环境

    这篇文章介绍的内容是关于Mac上通过docker配置PHP开发环境,有着一定的参考价值,现在分享给大家,有需要的朋友可以参考一下 更多PHP相关知识请关注我的专栏PHP​zhuanlan.zhihu. ...

  2. Mac上Node环境配置

    公司配备Mac笔记本,以前没用过mac开发项目,一开始依然是从node官网下载安装包,后来领导说最好是用brew安装软件,这样比较方便,安装和卸载,只要在命令行输入相应的 install 和 unin ...

  3. Mac上Hive安装配置

    Mac上Hive安装配置 1.安装 下载hive,地址:http://mirror.bit.edu.cn/apache/hive/ 之前我配置了集群,tjt01.tjt02.tjt03,这里hive安 ...

  4. Mac上利用VScode配置c/c++开发环境

    Mac上利用VScode配置c/c++开发环境 哭辽,Typora里面最好不要插入表情,不然保存会闪退 首先你要有一个vscode 在扩展里面下载c/c++ 第一步 ⬆+com+p 打开命令模式:选择 ...

  5. Mac直播服务器Nginx配置对HLS的支持

    在上一篇中Mac上搭建直播服务器Nginx+rtmp,我们已经搭建了nginx+rtmp直播服务器.下面需要对Nginx服务器增加对HLS的支持.在Nginx增加对HLS种支持比较简单,只是简单的修改 ...

  6. 在Mac上使用Nginx和FastCGI部署Flask应用

    最近在学习Flask,本文介绍一下如何部署Flask开发的应用,同时也学习一下Nginx的使用,这只是在Mac上的一个实验. 应用 这里使用的应用就是官方的文档中给出的Flaskr. 安装Nginx ...

  7. mac上使用zsh配置环境变量

    Mac配置环境变量的地方 一./etc/profile (建议不修改这个文件 ) 全局(公有)配置,不管是哪个用户,登录时都会读取该文件. 二./etc/bashrc (一般在这个文件中添加系统级环境 ...

  8. Mac上VMWare Fusion配置多台cent os

    一.创建虚拟机(准备工作) 1.使用VMWare Fusion 创建第一台虚拟机 2.选择操作系统(本次使用的是使用cent os 6.5 64bit 系统) 3.选择磁盘大小(楼主mac上的磁盘大小 ...

  9. Mac上搭建Nginx + rtmp

    介绍 nginx是非常优秀的开源服务器,用它来做hls或者rtmp流媒体服务器是非常不错的选择,本人在网上整理了安装流程,分享给大家并且作备忘. 安装步骤 1.先安装brew: /usr/bin/ru ...

随机推荐

  1. iOS 网络编程 TCP/UDP HTTP

    一.HTTP协议的主要特点: 1. CS模式 2. 简单快速:只需要传送请求方法和路径.(常用方法有GET,HEAD,POST) 3. 灵活:任意对象都可以,类型由Content-Type加以标记 4 ...

  2. PC上的番茄工作法软件 Pomodairo 1.9 详细攻略

    http://www.zhantuo.com/archives/673155 番茄钟软件 Pomodairo 1.9: 我觉得这款软件特别好,完全符合番茄工作法的要求. 你可以通过add new 来增 ...

  3. Android 布局详解 -三表格布局(TableLayout)以及重要属性

              TableLayout跟TableRow 是一组搭配应用的布局,TableLayout置底,TableRow在TableLayout的上方,而Button.TextView等控件就 ...

  4. TFS 切换登录用户的方法[转]

    来自:http://blog.csdn.net/tiangaojie123abc/article/details/12121929 方法一 用VS2010开发项目,一直困扰着我的是不知道怎么去切换TF ...

  5. if语句的数据驱动优化(Java版)

    举个栗子,如果我要输出数字对应的中文描述,我可以用这种方法来写: int num=2; if (num==1){ System.out.println("一"); } else i ...

  6. 使用DevExpress改变WinForm皮肤(VS)

    基于步入DevExpress的使用(VS),进一步使用DevExpress改变WinForm皮肤,适合初学者. 提示: 1.对于DevExpress菜单中的RepositoryItemComboBox ...

  7. DBA_实践指南系列3_Oracle Erp R12系统克隆Clone(案例)

    2013-12-03 Created By BaoXinjian

  8. vim 折叠

    zR 打开全部折叠 zr 打开当前折叠 zM 关闭全部折叠 zm 关闭当前折叠

  9. OCR 介绍文章

    光学字符识别技术:让电脑像人一样阅读 微软亚洲研究院,霍强: https://www.msra.cn/zh-cn/news/features/ocr-20150720 文章,我们应该做什么样的研究 h ...

  10. composer安装第三方的库packagist.org(laravel框架引入第三方库)

    建立composer.json composer require phpoffice/phpexcel //安装一个excel扩展库 composer require gregwar/captcha ...