方法一:多个.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. 使用NPIO操作Excel

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

  2. install window7

    install window7 http://www.zhujixc.com/win7home/http://jingyan.baidu.com/album/5bbb5a1b3e301713eba17 ...

  3. NGUI系列教程九(自制ListView)

    在NGUI中可以很方便的实现ListView的控件,ListView就好比IOS或Android平台中使用手势上下拖动的控件.在Unity3D中实现ListView的原理无非就两种,第一种是摄像机不动 ...

  4. python学习笔记25(文件管理 os包)

    os包我们经常会与文件和目录打交道,对于这些操作python提供了一个os模块,里面包含了很多操作文件和目录的函数.如果你对linux基本操作了解的话,下面的一些os方法应该会很熟悉的,因为基本和li ...

  5. Code for the Homework1

    作业要求: http://www.cnblogs.com/bingc/p/4919692.html 代码(未使用Eigen): #include <iostream> #include & ...

  6. MySQL中字符串函数详细介绍

    MySQL字符串函数对于针对字符串位置的操作,第一个位置被标记为1. ASCII(str)返回字符串str的 最左面字符的ASCII代码值.如果str是空字符串, 返回0.如果str是NULL,返回N ...

  7. C#实现IDispose模式

    .net的GC机制有两个问题:首先GC并不能释放所有资源,它更不能释放非托管资源.其次,GC也不是实时的,所有GC存在不确定性.为了解决这个问题.NET提供了析构函数 public class Dis ...

  8. C#学习笔记(二)

    1.注释:注销,解释2.单行://多行:/**/文档注释:///按enter主食要保证 别人一看就明白3.快速对期待吗:ctrl+k+d,按住ctrl不放,按k,迅速抬起,再按d(按D得时候k已经抬起 ...

  9. PAT-乙级-1013. 数素数 (20)

    1013. 数素数 (20) 时间限制 100 ms 内存限制 65536 kB 代码长度限制 8000 B 判题程序 Standard 作者 CHEN, Yue 令Pi表示第i个素数.现任给两个正整 ...

  10. HTML可编辑下拉框

    <div style="position:relative;">   <select style="width:120px;" onchang ...