1.更新apt-get源

1
apt-get update

2.安装Nginx

1
apt-get install nginx

nginx相关操作

1
2
3
service nginx start
service nginx restart
service nginx stop

3.安装php

1
apt-get install php5-fpm php5-gd php5-mysql php5-memcache php5-curl

4.配置Nginx让其支持php

1
2
cd /etc/nginx/conf.d #进入nginx虚拟站点配置目录
vi xxx.com.conf #创建域名配置文件

然后把下面的代码拷贝进去

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
server {
listen 80;
server_name phpmyadmin.xxx.com;
root /home/wwwroot/phpMyadmin;
index index.php;
location / {
try_files $uri $uri/ =404;
}
location ~ \.php$ {
include snippets/fastcgi-php.conf;
#
# # With php5-cgi alone:
# fastcgi_pass 127.0.0.1:9000;
# # With php5-fpm:
fastcgi_pass unix:/var/run/php5-fpm.sock;
}
}

附上nginx方向代理到nodeJs的配置

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
server{
listen 80;
server_name open.xxx.com;
access_log off;
location / {
#proxy_cache_key "$scheme://$host$request_uri";
#proxy_cache cache_one;
#proxy_cache_valid 200 304 3h;
#proxy_cache_valid 301 3d;
#proxy_cache_valid any 10s;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
#proxy_set_header Referer http://xxxx;
proxy_set_header Host $host;
#proxy_hide_header Set-Cookie;
proxy_pass http://xx.xx.xx.xx:8080;
}
}