使用VPS后,没有安装控制面板,什么都需要自己配置,还真是麻烦,这里记录了nginx下多站点的配置(ubuntu环境)。
在/usr/local/nginx/下新建vhosts文件夹:
mkdir vhosts
进入,新建第一个站点的配置文件, 如:
vi yilee.info.conf
内容为:
server
{
listen 80;
server_name yilee.info www.yilee.info;
index index.html index.htm index.php;
root /home/wwwroot;
include ../conf/wordpress.conf;
location ~ .*\.(php|php5)?$
{
fastcgi_pass unix:/tmp/php-cgi.sock;
fastcgi_index index.php;
include fcgi.conf;
}
{
listen 80;
server_name yilee.info www.yilee.info;
index index.html index.htm index.php;
root /home/wwwroot;
include ../conf/wordpress.conf;
location ~ .*\.(php|php5)?$
{
fastcgi_pass unix:/tmp/php-cgi.sock;
fastcgi_index index.php;
include fcgi.conf;
}
location /status {
stub_status on;
access_log off;
}
location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$
{
expires 30d;
}
location ~ .*\.(js|css)?$
{
expires 12h;
}
}
这里需要注意server_name为域名,root为站点的位置。
其他站点的配置文件和上面类似,只需更改server_name和root即可。
打开nginx的配置文件:
vi ../conf/nginx.conf
引入上面的配置文件即可,可以用通配符。
include /usr/local/nginx/vhosts/*.conf;
最后重启nginx即可:
/usr/local/nginx/sbin/nginx -s reload