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. ajax操作登录

    js文件中的内容(ajax.operate.js) ;(function ($, window) { var _ajaxOperate = window.ajaxOperate || {}; _aja ...

  2. android程序监听home键与电源键

    01 private final BroadcastReceiver homePressReceiver = new BroadcastReceiver() { 02 final String SYS ...

  3. web项目在eclipse workspace中的位置

    workspace\.metadata\.plugins\org.eclipse.wst.server.core\tmp0\wtpwebapps\项目名

  4. Jmeter --- 逻辑控制之if控制器

    一.背景 在实际工作中,当使用Jmeter做性能脚本或者接口脚本时,有可能会遇到需要对不同的条件做不同的操作,基于这种诉求,在Jmeter中可使用if控制器来实现 二.实际操作 逻辑控制器位置: 在线 ...

  5. EXTJS 5 学习笔记1 - Class System

    1. Name Conventions 命名规范      1) Classes 类          a. 类名只能包含数字字母 only contain alphanumeric characte ...

  6. scrapy 的一个例子

    1.目标: scrapy 是一个爬虫构架,现用一个简单的例子来讲解,scrapy 的使用步骤 2.创建一个scrapy的项目: 创建一个叫firstSpider的项目,命令如下: scrapy sta ...

  7. Android开发7——android.database.CursorIndexOutOfBoundsException:Index -1 requested

    android中数据库处理使用cursor时,游标不是放在为0的下标,而是放在为-1的下标处开始的. 也就是说返回给cursor查询结果时,不能够马上从cursor中提取值. 下面的代码会返回错误Us ...

  8. android获取对话框文本注意事项

    1.View注意设置成final类型如final View layout=.. . 2.获取文本框对象时候格式EditText e = (EditText)layout.findViewById(R. ...

  9. [na]代理arp导致的问题(路由卷)

    已过期... 一 理论概述 \ 二 实验 实验一:代理arp在nat中的作用(实验发现一下是错的) 实验二.代理arp导致的问题 pc访问服务器想让走路由器(写32bit静态路由),右边的R arp ...

  10. MSSQLid清零

    truncate table [cellphone2016].[dbo].[tp_phone_9]