方法一:多个.conf方法

1. 到/usr/local/nginx/ 新建一个目录 vhosts  并创建两个conf文件,如:wodejj.com.conf ,xiaobing.com.conf。

内容如下:

 log_format xiaobing_main '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';
#注意此处要放在server段的前面 不然会有“nginx: [emerg] duplicate "log_format" name "access" in /*****/conf/*****.conf:9” 的错误。 server {
listen ;
server_name www.xiaobing.com;#其它的conf文件更改此位置的域名 就可以实现多域名的配置了,
#charset koi8-r; access_log logs/www.xiaobing.com.log xiaobing_main; location / {
root /data/xiao_bing; # 此处 是网页文件的存放目录要改到实际位置
index index.php index.html index.htm;
} error_page /.html; # redirect server error pages to the static page /50x.html
#
error_page /50x.html;
location = /50x.html {
root html;
} # proxy the PHP scripts to Apache listening on 127.0.0.1:
#
#location ~ \.php$ {
# proxy_pass http://127.0.0.1;
#} # pass the PHP scripts to FastCGI server listening on 127.0.0.1:
#
location ~ \.php$ {
root /data/xiaobing;
fastcgi_pass 127.0.0.1:;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME /data/xiao_bing/$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;
}
}

2. 将以上创建 的多个域名配置文件 conf ,包含到/usr/local/nginx/conf/nginx.conf 的配置文件中

方法及内容是:
     #include all hosts file;
     include /usr/local/nginx/vhosts/*;

3. 重启nginx

/usr/local/nginx/sbin/nginx -s reload

nginx多域名的配置方法的更多相关文章

  1. Nginx服务器的Websockets配置方法

    这篇文章主要介绍了简介Nginx服务器的Websockets配置方法,是使用Nginx服务器的网管的必备知识XD~需要的朋友可以参考下 Nginx 1.3.13 已经发布了,该版本支持 Connect ...

  2. nginx实现防盗链配置方法介绍

    有些朋友觉得防盗链就是防止图片,其实有很多东西要进行防盗链了,下面我来介绍在nginx中实现防盗链配置方法有对图片防盗链与下载资源等. 防盗链配置 假设网站域名是 www.php100.com. 编辑 ...

  3. nginx虚拟域名的配置以及测试验证

    1.保证该机器上安装了nginx 未安装请看:centos/linux下的安装Nginx 2.使用root用户编辑配置文件 vim /usr/local/nginx/conf/nginx.conf 3 ...

  4. Linux JDK Tomcat Nginx MariaDB 安装,Nginx 多域名转发配置

    安装JDK rpm包下载地址(jdk-7u17 ): http://www.oracle.com/technetwork/java/javase/downloads/java-archive-down ...

  5. Linux下Nginx安全证书ssl配置方法

    分享下我是如何一步步在Nginx上配置SSL的.首先,确保安装了OpenSSL库,并且安装Nginx时使用了–with-http_ssl_module参数. 初学者或者菜鸟建议使用LNMP进行一键安装 ...

  6. Nginx 设置域名转向配置

    #运行用户 #user www-data; #启动进程,通常设置成和cpu的数量相等 worker_processes 2; #全局错误日志及PID文件 error_log logs/error.lo ...

  7. apache将不带www域名301重定向到带www的域名的配置方法

    #强制重定向到wwwRewriteEngine OnRewriteCond %{HTTP_HOST} ^jb51.net/ [NC]RewriteRule ^(.*)$ http://www.jb51 ...

  8. nginx负载均衡的配置方法

    upstream www.***.com { server ; server ; server ; } server { listen ; server_name www.***.com; #char ...

  9. windows下wamp多域名的配置

    前面的话 本文将详细介绍windows下wamp多域名的配置方法 修改hosts文件 hosts文件的位置:系统盘→“windows”→“System32”→“drivers”→“etc” 打开hos ...

随机推荐

  1. butterknife7.0.1使用

    1.官网:http://jakewharton.github.io/butterknife/ Introduction Annotate fields with @Bind and a view ID ...

  2. Can’t create handler inside thread that has not called Looper.prepare()

    1)在Android 2.3以前,为防止ANR(Application Not Responding),Google是不赞成将网络连接等一系列耗时操作直接放到应用主线程进行的,推荐将这类操作放在子线程 ...

  3. PL/SQL数据导入导出浅谈(1)

    近来需要通过PL/SQL向Oracle中导数据,特此总结一下 试例表:test 字段:id;name;org; 1.直接复制粘贴(当数据量不是特别大的时候) 1)使用select * from tes ...

  4. 使用NPIO操作Excel

    using System; using System.Collections.Generic; using System.Linq; using System.Text; using NPOI.SS. ...

  5. ios Base64编解码工具类及使用

    为了避免明码传递http内容,可以用base64编码后传输,收到方再解码,也方便了2进制数据的字符串式传输. 对于ios来说,google给提供了一个很好的工具类,方便进行base64编解码,当然也可 ...

  6. JS 生成GUID

    js 代码: function GUID() { this.date = new Date(); /* 判断是否初始化过,如果初始化过以下代码,则以下代码将不再执行,实际中只执行一次 */ if (t ...

  7. vs中使用过的扩展和好的nuget库

    扩展 ReAttach ReAttach gives you an easy way to ReAttaching your prior debug targets. ReAttach stores ...

  8. JavaScript中常谈的对象

    为浏览器编写代码时,总少不了window对象 window对象表示JavaScript程序的全局环境 同时 也表示应用的主窗口 到处都是对象 window对象 常用的属性和方法介绍 location ...

  9. 小小地预览HTML5

    程序示例 <!doctype html> <html> <head> <title>First </title> <meta char ...

  10. 1050 棋盘染色 2 - Wikioi

    题目描述 Description 有一个5*N的棋盘,棋盘中的一些格子已经被染成了黑色,你的任务是对最少的格子染色,使得所有的黑色能连成一块. 输入描述 Input Description 第一行一个 ...