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%