mac上php+nginx配置
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配置的更多相关文章
- Mac上通过docker配置PHP开发环境
这篇文章介绍的内容是关于Mac上通过docker配置PHP开发环境,有着一定的参考价值,现在分享给大家,有需要的朋友可以参考一下 更多PHP相关知识请关注我的专栏PHPzhuanlan.zhihu. ...
- Mac上Node环境配置
公司配备Mac笔记本,以前没用过mac开发项目,一开始依然是从node官网下载安装包,后来领导说最好是用brew安装软件,这样比较方便,安装和卸载,只要在命令行输入相应的 install 和 unin ...
- Mac上Hive安装配置
Mac上Hive安装配置 1.安装 下载hive,地址:http://mirror.bit.edu.cn/apache/hive/ 之前我配置了集群,tjt01.tjt02.tjt03,这里hive安 ...
- Mac上利用VScode配置c/c++开发环境
Mac上利用VScode配置c/c++开发环境 哭辽,Typora里面最好不要插入表情,不然保存会闪退 首先你要有一个vscode 在扩展里面下载c/c++ 第一步 ⬆+com+p 打开命令模式:选择 ...
- Mac直播服务器Nginx配置对HLS的支持
在上一篇中Mac上搭建直播服务器Nginx+rtmp,我们已经搭建了nginx+rtmp直播服务器.下面需要对Nginx服务器增加对HLS的支持.在Nginx增加对HLS种支持比较简单,只是简单的修改 ...
- 在Mac上使用Nginx和FastCGI部署Flask应用
最近在学习Flask,本文介绍一下如何部署Flask开发的应用,同时也学习一下Nginx的使用,这只是在Mac上的一个实验. 应用 这里使用的应用就是官方的文档中给出的Flaskr. 安装Nginx ...
- mac上使用zsh配置环境变量
Mac配置环境变量的地方 一./etc/profile (建议不修改这个文件 ) 全局(公有)配置,不管是哪个用户,登录时都会读取该文件. 二./etc/bashrc (一般在这个文件中添加系统级环境 ...
- Mac上VMWare Fusion配置多台cent os
一.创建虚拟机(准备工作) 1.使用VMWare Fusion 创建第一台虚拟机 2.选择操作系统(本次使用的是使用cent os 6.5 64bit 系统) 3.选择磁盘大小(楼主mac上的磁盘大小 ...
- Mac上搭建Nginx + rtmp
介绍 nginx是非常优秀的开源服务器,用它来做hls或者rtmp流媒体服务器是非常不错的选择,本人在网上整理了安装流程,分享给大家并且作备忘. 安装步骤 1.先安装brew: /usr/bin/ru ...
随机推荐
- HDUOJ---(4708)Rotation Lock Puzzle
Rotation Lock Puzzle Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Oth ...
- HDUOJ-Counting Triangles
Counting Triangles Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Other ...
- mac下安装mysql 1820 重置默认密码
mac安装mysql时会给出一个临时密码 记录下来 2018-03-17T02:14:10.809431Z 1 [Note] A temporary password is generated for ...
- python学习笔记013——内置函数dir()
1 描述 dir() 函数 不带参数时,返回当前范围内的变量.方法和定义的类型列表: 带参数时,返回参数的属性.方法列表. 如果参数包含方法__dir__(),该方法将被调用. 如果参数不包含__di ...
- [Android开发那点破事]解决android.os.NetworkOnMainThreadException
[Android开发那点破事]解决android.os.NetworkOnMainThreadException 昨天和女朋友换了手机,我的iPhone 4S 换了她得三星I9003.第一感觉就是好卡 ...
- WM_MOUSELEAVE 和 WM_MOUSEHOVER 使用
原文链接: http://www.cnblogs.com/weiqubo/archive/2011/04/14/2016323.html 默认情况下,窗口是不响应 WM_MOUSELEAVE 和 WM ...
- ubuntu的apt-get提示资源被锁定
一.错误提示 E: Could not : Resource temporarily unavailable) E: Unable to lock the administration directo ...
- 转 MySQL中的行级锁,表级锁,页级锁
对mysql乐观锁.悲观锁.共享锁.排它锁.行锁.表锁概念的理解 转载. https://blog.csdn.net/puhaiyang/article/details/72284702 实验环境 ...
- FAQ系列 | 如何保证主从复制数据一致性(转)
导读 MySQL主从复制环境中,如何才能保证主从数据的一致性呢? 关于主从复制 现在常用的MySQL高可用方案,十有八九是基于 MySQL的主从复制(replication)来设计的,包括常规的一主一 ...
- html5中script的async属性
html5中script的async属性 我兴奋于html5的原因之一是一些久久未能实现的特性现在可以真正运用于实际项目中了. 如我们使用placeholder效果蛮久了但是那需要javascript ...