1.建立wwwroot(/home/wwwrooot)

另建立一个wwwroot/test/index.html(网站目录)

2.建立vhost文件(/usr/local/nginx/conf/vhost)

3.配置nginx.conf,加入:include vhost/*.conf;

http{
......
include vhost/*.conf; // 注意这里是放在http{}里面,而不是外面
}

另配置vhost/test.conf

server {
listen ;
server_name test.zhouzhongjie.com;
root /home/wwwroot/test;
location / {
index index.html index.htm index.php;
#autoindex on;
}
location ~ \.php$ {
fastcgi_pass 127.0.0.1:;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
} }

server_name:下划线,域名,ip,localhost

server_name: _

server_name:  xxx.com

server_name: 22.22.22.22

server_name:localhost   // 不推荐这种

server
{
listen 8001;
#listen [::]:80;
server_name localhost;
index index.html index.htm index.php default.html default.htm default.php;
root /home/wwwrooot/test; #include other.conf;
#error_page 404 /404.html; # Deny access to PHP files in specific directory
#location ~ /(wp-content|uploads|wp-includes|images)/.*\.php$ { deny all; } #include enable-php.conf; location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$
{
expires 30d;
} location ~ .*\.(js|css)?$
{
expires 12h;
} location ~ /.well-known {
allow all;
} location ~ /\.
{
deny all;
} access_log off;
}

修改配置文件后需要重新加载

./nginx  -s reload

最后重启nginx,

linux nginx配置多个网站的更多相关文章

  1. linux nginx 配置php

    linux nginx 配置php   下载php源码 解压 configure ./configure --prefix=/usr/local/php --enable-fpm --with-mcr ...

  2. linux nginx配置新项目加域名(设置绑定域名)

    转自:linux nginx配置新项目加域名 找到nginx的配置文件 nginx/nginx.conf 第一种方,法直接在nginx.com里面配置 user www www; worker_pro ...

  3. Linux Debian 7部署LEMP(Linux+Nginx+MySQL+PHP)网站环境

    我们在玩VPS搭建网站环境的时候,都经常看到所谓的LAMP.LNMP.LEMP,LAMP, 其中的A代表APECHE WEB驱动环境,LNMP中的N代表NGINX驱动环境,只不过海外的叫法NGINX ...

  4. Linux - Nginx配置反向代理。

    Nginx配置反向代理. 准备两台服务器 http://192.168.70.66 http://192.168.70.62 设置正则匹配(192.168.70.66) vim /usr/local/ ...

  5. linux nginx 配置ssl证书访问

    http://www.linuxidc.com/Linux/2013-08/88271.htm 一.什么是 SSL 证书,什么是 HTTPSSSL 证书是一种数字证书,它使用 Secure Socke ...

  6. Linux nginx 配置 location 语法 正则表达式

    location语法:location [=|~|~*|^~] /uri/ { - }默认:否上下文:server这个指令随URL不同而接受不同的结构.你可以配置使用常规字符串和正则表达式.如果使用正 ...

  7. Nginx配置HTTPS证书网站

    前提: 1.主机需要先安装openssl     2.编译安装nginx时,要加上--with-http_ssl_module  这个ssl模块 现在开始配置:(我当时配置时,主机已安装了openss ...

  8. linux nginx配置新项目加域名

    找到nginx的配置文件 nginx/nginx.conf 第一种方,法直接在nginx.com里面配置 user www www; worker_processes auto; error_log ...

  9. [Linux] Nginx服务下统计网站的QPS

    单位时间的请求数就是QPS,那么在nginx服务的网站下,如果要统计QPS并且按从高到低排列,需要使用awk配合sort进行处理awk做的主要工作是把access每行日志按分隔符分开,然后循环每一行, ...

随机推荐

  1. django 目录结构修改

    ├── manage.py └── myxunlei ├── settings.py ├── settings.pyc ├── urls.py ├── urls.pyc ├── wsgi.py └── ...

  2. 基于jQuery果冻式按钮焦点图切换代码

    基于jQuery果冻式按钮焦点图切换代码.这是一款基于jQuery+CSS3实现的图片切换代码.效果图如下: 在线预览   源码下载 实现的代码. html代码: <div class=&quo ...

  3. jquery复选框 选中事件 及其判断是否被选中_常用笔记

    checkbox的change事件可监听是否选中状态,也可添加onclick事件. var dom=$('.checkbox'); 1. 判断checkbox是否被选中 var dom=$('.che ...

  4. Linux 下编译出现 undefined reference to `pthread_create'

    这是由于没有链接线程库的原因,只要在编译的时候加入: -lpthread 参数即可. arm-linux-gcc serial.c -o serial -lpthread 查看 ubuntu 版本的命 ...

  5. python基础归结

    00.python程序格式 #开头的语句是注释,其他每一行都是一个语句. 语句以冒号(:)结尾时,缩进的语句视为代码块(没有C语言中{}区分代码块). 约定俗称, 4个空格缩进,Tab或空格均可以,但 ...

  6. Extjs4.2 TreeView TreeStore 移除节点不触发delete(remove node don't trigger delete method)

    当我们操作treeview的时候,新增节点,如果成功则新增node,如果失败的话我们不想node还显示出来,可以通过监听sync的failure事件,失败时候移除node,但是第一次肯定达到了预期效果 ...

  7. hbase源码系列(十四)Compact和Split

    先上一张图讲一下Compaction和Split的关系,这样会比较直观一些. Compaction把多个MemStore flush出来的StoreFile合并成一个文件,而Split则是把过大的文件 ...

  8. jQuery(五):文本操作

    text()可以获取或设置元素的文本内容.例如: 示例: <!DOCTYPE html> <html lang="en"> <head> < ...

  9. 重装MAC系统 “安装器有效负载签名检查失败” 解决方法

    部分朋友反应安装macOS Sierra的时候会提示:"安装器有效负载签名检查失败" 其实这是系统时间不对的原因,把系统时间修改正确就好了. 1,如果电脑正常运行,那么进系统偏好设 ...

  10. github fork 同步

    git remote -v git remote add upstream url git fetch upstream git checkout master git merge upstream/ ...