【Nginx配置虚拟主机】

每一个

server {

listen       80;

        server_name  www.a.com;

.....

}

就表示一台虚拟域名,

然后对应的,在 /etc/hosts 修改:

vim
 /etc/hosts

-------------------------------------------------------------------------------

【/usr/local/server/nginx/conf/nginx.conf】注意提前备份一份

#user  nobody;

worker_processes  1;



#error_log  logs/error.log;

#error_log  logs/error.log  notice;

#error_log  logs/error.log  info;



#pid        logs/nginx.pid;





events {

    worker_connections  1024;

}





http {

    include       mime.types;

    default_type  application/octet-stream;



    #log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '

    #                  '$status $body_bytes_sent "$http_referer" '

    #                  '"$http_user_agent" "$http_x_forwarded_for"';



    #access_log  logs/access.log  main;



    #da kai mu lu , By renxing

    autoindex on;

    autoindex_exact_size off;

    autoindex_localtime on;





    sendfile        on;

    #tcp_nopush     on;



    #keepalive_timeout  0;

    keepalive_timeout  65;



    #gzip  on;



    server {

        listen       80;

        server_name  localhost;



        #charset koi8-r;



        #access_log  logs/host.access.log  main;



        location / {

            root   /usr/local/server/nginx/html/qgzs/app;
  
##定位项目到指定目录

            index  index.html index.htm index.php;

        }



        #error_page  404              /404.html;



        # redirect server error pages to the static page /50x.html

        #

        error_page   500 502 503 504  /50x.html;

        location = /50x.html {

            root   html;

        }



        # proxy the PHP scripts to Apache listening on 127.0.0.1:80

        #

        #location ~ \.php$ {

        #    proxy_pass   http://127.0.0.1;

        #}



        # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000

        #



##配置nginx支持thinkphp的 PATHINFO 模式

location /usr/local/server/nginx/html/qgzs/app {  

    index index.php;  

    if (!-e $request_filename) {  

       
rewrite ^/test/tp/(.*)$ /test/tp/index.php/$1 last;  

        break;  

    }  





location ~ .+\.php($|/) 

    set $script $uri;  

    set $path_info "/";  

    if ($uri ~ "^(.+\.php)(/.+)") {  

         
 set $script     $1;  

           
set $path_info  $2;  

    }   

        

   
 root   /usr/local/server/nginx/html/qgzs/app;

     fastcgi_pass   127.0.0.1:9000;

     fastcgi_index index.php?IF_REWRITE=1;  

     fastcgi_param PATH_INFO $path_info;  

     fastcgi_param SCRIPT_NAME $script;  

   
 fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;

   
 include        fastcgi_params;

}



##END配置





        # deny access to .htaccess files, if Apache's document root

        # concurs with nginx's one

        #

        #location ~ /\.ht {

        #    deny  all;

        #}

        }





    # another virtual host using mix of IP-, name-, and port-based configuration

    #

    #server {

    #    listen       8000;

    #    listen       somename:8080;

    #    server_name  somename  alias  another.alias;



    #    location / {

    #        root   html;

    #        index  index.html index.htm;

    #    }

    #}





    # HTTPS server

    #

    #server {

    #    listen       443 ssl;

    #    server_name  localhost;



    #    ssl_certificate      cert.pem;

    #    ssl_certificate_key  cert.key;



    #    ssl_session_cache    shared:SSL:1m;

    #    ssl_session_timeout  5m;



    #    ssl_ciphers  HIGH:!aNULL:!MD5;

    #    ssl_prefer_server_ciphers  on;



    #    location / {

    #        root   html;

    #        index  index.html index.htm;

    #    }

    #}



}

Ubuntu配置Nginx虚拟主机和支持ThinkPHP的更多相关文章

  1. 配置Nginx虚拟主机

    实验环境 一台最小化安装的CentOS 7.3虚拟机 配置基本环境 1. 安装nginx yum install -y epel-* yum isntall -y nginx vim 2. 建立虚机主 ...

  2. 在 CentOS7 上配置 nginx 虚拟主机

    创建配置文件保存目录,其中 sites-available 用来实际保存配置文件,sites-enabled 用来保存符号链接 : mkdir /etc/nginx/sites-available m ...

  3. Nginx 虚拟主机下支持Pathinfo并隐藏入口文件的完整配置

    server { listen 80; server_name zuqiu.com; # 设置你的域名 index index.html index.htm index.php; root D:/wn ...

  4. 配置nginx虚拟目录配置文件支持tp的pathinfo

    lnmp自带的包不好用, 经测试,在相应的conf文件加入这句话即可: location / { if (!-e $request_filename) { rewrite ^(.*)$ /index. ...

  5. Nginx 虚拟主机 VirtualHost 配置

    Nginx 是一个轻量级高性能的 Web 服务器, 并发处理能力强, 对资源消耗小, 无论是静态服务器还是小网站, Nginx 表现更加出色, 作为 Apache 的补充和替代使用率越来越高. 我在& ...

  6. Nginx网络架构实战学习笔记(一):Nginx简介、安装、信号控制、nginx虚拟主机配置、日志管理、location 语法、Rewrite语法详解

    文章目录 nginx简介 nginx安装 nginx信号控制 nginx虚拟主机配置 日志管理 location 语法 精准匹配的一般匹配 正则匹配 总结 Rewrite语法详解 nginx简介 Ng ...

  7. nginx虚拟主机配置

    nginx虚拟主机配置   虚拟主机的概念虚拟主机,就是把一台物理服务器划分成多个"虚拟"的服务器,每一个虚拟主机都可以有独立的域名和独立的目录nginx虚拟主机的配置nginx的 ...

  8. Nginx高性能服务器安装、配置、运维 (5) —— Nginx虚拟主机配置

    六.Nginx虚拟主机配置 建立基于域名的虚拟主机: (1)建立基于域名的虚拟主机配置文件(以abc.com为例): (2)更改虚拟主机配置文件: 更改配置如下(更改部分即可): server { l ...

  9. Nginx教程(二) Nginx虚拟主机配置

    Nginx教程(二) Nginx虚拟主机配置 1 虚拟主机管理 1.1 Nginx管理虚拟主机 虚拟主机使用的是特殊的软硬件技术,它把一台运行在因特网上的服务器主机分成一台台“虚拟”的主机,每台虚拟主 ...

随机推荐

  1. Asp.net mvc 中Action 方法的执行(二)

    [toc] 前面介绍了 Action 执行过程中的几个基本的组件,这里介绍 Action 方法的参数绑定. 数据来源 为 Action 方法提供参数绑定的原始数据来源于当前的 Http 请求,可能包含 ...

  2. jquery ui-----弹出窗口 dialog

    jquery ui 提供了强大的dialog功能,基本能满足开发的功能. 先上一个简单的例子: [代码] <script> $(function() {   $( "#dialo ...

  3. sql语句添加删除外键及其约束

    --删除外键 ALTER TABLE t_base_role_module DROP CONSTRAINT fk_t_base_role_module_t_base_defined_url; --增加 ...

  4. es6重点笔记:数值,函数和数组

    本篇全是重点,捡常用的怼,数值的扩展比较少,所以和函数放一起: 一,数值 1,Number.EPSILON:用来检测浮点数的计算,如果误差小于这个,就无误 2,Math.trunc():取整,去除小数 ...

  5. win7 使用anaconda安装tensorflow并且在jupyter notebook上启动

    记录一下学习深度学习的小事情: 1.tensorflow 现在只支持windows 64位系统: 2.因为实验室的电脑比较老旧,Gpu配置低,所以选择安装的是tensorflow Cpu版本,对于学习 ...

  6. Python装饰器小代码

    # coding=utf-8import timedef outer(fun): def inner(): start = time.time() fun() runtime = time.time( ...

  7. linux_vi快捷键

    vi有哪些快捷方式? 到行头: 0 ^ home 到行尾: $ shif+a(编辑模式) end 退出保存: wq . x .wq!(强制退出保存) 强制退出不保存: q! 光标移到文件最后一行: s ...

  8. JS实现倒计时

    HTML部分: <div class="div"> <div id="div"> </div> </div> C ...

  9. Rhel-Server 5.5 安装ORACLE10

    VMWARE + REDHAT + ORA10 先说一下环境,操作系统为Microsoft Windows Server 2003,安装的是虚拟机VMware Workstation Version ...

  10. android 通过getDimension,getDimensionPixelOffset和getDimensionPixelSize获取dimens.xml文件里面的变量值

    dimens.xml里写上三个变量: <dimen name="activity_vertical_margin1">16dp</dimen> <di ...