ubuntu LNMP Mac

安装 homebrew

安装 Nginx

安装

1
2
brew search nginx
brew install nginx

启动、关闭 nginx

1
nginx -s reload|reopen|stop|quit

配置

1
2
3
4
cd /usr/local/etc/nginx/
mkdir conf.d
vim nginx.conf
vim ./conf.d/default.conf

nginx.conf 内容

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
worker_processes  1;

error_log /usr/local/var/log/nginx/error.log warn;

pid /usr/local/var/run/nginx.pid;


events {
#worker_connections 1024;
worker_connections 256;
}

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 /usr/local/var/log/nginx/access.log main;

port_in_redirect off;
sendfile on;
keepalive_timeout 65;
include /usr/local/etc/nginx/conf.d/*.conf;
include servers/*;
}

default.conf 文件内容

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
server {
listen 80;
server_name localhost;
# root /usr/local/var/www/

# /usr/local/var/www/
# root /Users/username/Sites/; # 该项要修改为你准备存放相关网页的路径
root /usr/local/var/; # 该项要修改为你准备存放相关网页的路径

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

#proxy the php scripts to php-fpm
location ~ \.php$ {
include /usr/local/etc/nginx/fastcgi.conf;
fastcgi_intercept_errors on;
fastcgi_pass 127.0.0.1:9000;
include fastcgi_params;
}

}

安装 MYSQL

测试

Nginx 配置文件 root 对应目录下新建 index.php

1
2
3
<?
phpinfo();
?>

安装 php

参考资料

Mac 下安装 LNMP(Nginx+PHP5.6)环境
Mac OSX 10.9 搭建 nginx+mysql+php-fpm 环境


来源:http://leunggeorge.github.io/

0%