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. Android开发(七)——判断网络状态

    项目中难免会出现使用网络的情况,使用网络前得进行网络判断,看网上的网友一般有多种实现版本. 第一种: // 是否有网络连接 public static boolean isNetworkConnect ...

  2. java基础篇---文件上传(smartupload组件)

    文件上传几乎是所有网站都具有的功能,用户可以将文件上传到服务器的指定文件夹中,也可以保存在数据库中,本篇主要说明smartupload组件上传. 在讲解smartupload上传前,我们先来看看不使用 ...

  3. jvm面试题

     1.虚拟机的类加载机制 1.1.什么是虚拟机的类加载机制 在代码编译后,就会生成JVM(Java虚拟机)能够识别的二进制字节流文件(*.class).而JVM把Class文件中的类描述数据从文件加载 ...

  4. [net]netcat 做网络端口监听

    nc命令说明:https://www.cnblogs.com/nmap/p/6148306.html 如下: nc -vz -w domain/ip &> /dev/null & ...

  5. Linux下的微秒级别的定时器

    /* * @FileName: test_sleep.c * @Author: wzj * @Brief: * * * @History: * * @Date: 2012年02月07日星期二22:20 ...

  6. if else练习 (解一元二次方程)

    public class cccc { /** * @param args */ public static void main(String[] args) { int a=10,b=11,c=12 ...

  7. 【进阶修炼】——改善C#程序质量(9)

    140,使用默认的访问修饰符. 如果不加访问修饰符,成员变量的默认是private的,类默认是internal的.为了明确访问的权限,我倒是建议都加上访问修饰符,这省不了多少代码. 141,不知道该不 ...

  8. openvpn之安装篇

    之前整过openvpn,现把一些过程记录下来,方便以后查阅. #!/bin/bash cd /usr/local/srcyum install pam-devel.x86_64 -ywget http ...

  9. SQL server 分页方法小结

    这里面介绍一下常用的分页方法: 1.使用top来分页 select top @pageSize * from table where id not in (select top @pageSize*( ...

  10. MapReduce 图解流程超详细解答(1)-【map阶段】

    转自:http://www.open-open.com/lib/view/open1453097241308.html 在MapReduce中,一个YARN  应用被称作一个job, MapReduc ...