zoukankan      html  css  js  c++  java
  • lighttpd配置虚拟主机/php等WEB环境

    lighttpd(1.4.37)配置如下

    server.document-root = "/var/www/lighttpd/"
    
    server.port = 8888
    server.username = "nobody"
    server.groupname = "nobody"
    
    server.max-worker = 2
    server.max-keep-alive-requests =4000
    
    server.errorlog = "/tmp/lighttpd.error.log"
    accesslog.filename = "/tmp/lighttpd.access.log"
    
    
    server.modules = (
        "mod_access",
        "mod_accesslog",
        "mod_fastcgi",
        "mod_proxy",
        "mod_redirect",
        "mod_compress",
        "mod_rewrite",
        "mod_expire"
    )
    
    var.document_root = "/usr/local/openresty/nginx/html/"
    
    mimetype.assign = (
        ".html"    =>    "text/html",
        ".txt"    =>    "text/plain",
        ".jpg"    =>    "image/jpeg",
        ".png"    =>    "image/png",
        ".js"    =>    "application/x-javascript",
        ".css"    =>    "text/css"
    )
    
    static-file.exclude-extensions=(".fcgi", ".php", ".rb")
    index-file.names = ("index.html")
    
    dir-listing.activate = "disable"
    
    $HTTP["host"] == "www.anotherweb.com" {
        server.document-root = document_root + "ci/"
        $HTTP["url"] =~ "^/download/" {
            dir-listing.activate = "enable"
        }
        url.rewrite-once = (
            "/(.*).(.*)" => "$0",
            "/(css|files|img|js|stats)/" => "$0",
            "^/([^.]+)$" => "/index.php/$1"
        )
        fastcgi.server = (
            ".php" => 
            ((
                "host"    =>    "127.0.0.1",
                "port"    =>    9000,
                #"check-local" => "disable",
                #"broken-scriptfilename" => "enable"
            ))
        )
    } else $HTTP["host"] =~ "(.*.|)mywebsite.com" {
        #server.document-root = "/usr/local/openresty/nginx/html/"
        
        $HTTP["referer"] !~ "^($|http://.*.mywebsite.com)" {
            $HTTP["url"] =~ "/images" {
                #url.access-deny = ("")
                url.redirect = (".*"    => "http://www.mywebsite.com/")
            }
        }
        proxy.balance = "round-robin"
        proxy.server = (
            "/" => ((
                "host"    =>    "127.0.0.1",
                "port"    =>    8081
            ))
        )
    } else $HTTP["host"] =~ "" {
        alias.url = ( "/download/" => "/tmp/download/")
        index-file.names = ( "index.html", "index.php" )
    
        compress.allowed-encodings = ("gzip", "deflate")
        compress.cache-dir = "/tmp/cache/lighttpd/compress/"
        compress.filetype = ( "application/x-javascript", "text/css", "text/html", "text/plain" )
    
        $HTTP["url"] =~ ".(png)" {
            expire.url = ( "" => "access 1 hours")
            #expire.url = ( "" => "access 30 days")
            #expire.url = ( "" => "access 5 minutes")
            #expire.url = ( "" => "access 30 months")
            #expire.url = ( "" => "access 1 years")
        }
    }

    nginx(openresty/1.7.2.1)配置如下

    #user  nobody;
    worker_processes  2;
    
    #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;
    
        sendfile        on;
    
        keepalive_timeout  65;
    
        server {
            listen       8080;
            server_name anotherweb.com www.anotherweb.com;
    
            gzip on;
            gzip_comp_level 4;
            gzip_types text/css text/javascript application/javascript application/octet-stream;
    
            #access_log  logs/host.access.log  main;
    
            error_page   500 502 503 504  /50x.html;
            location = /50x.html {
                root   html;
            }
    
            location / {
                root           html/ci;
                index         index.html;
                try_files $uri $uri/ /index.php/$query_string;
            }
    
            location ~ .php($|/) {
                root           html/ci;
                client_max_body_size 10m;
    
                fastcgi_pass   127.0.0.1:9000;
                fastcgi_index  index.php;
                fastcgi_split_path_info ^(.+.php)(.*)$;
                fastcgi_param   PATH_INFO $fastcgi_path_info;
                fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
                include        fastcgi_params;
            }
        }
    
        server {
            listen       8080;
            server_name  www.mywebsite.com image.mywebsite.com mywebsite.com;
            default_type  text/html;
    
            location / {
                proxy_pass http://127.0.0.1:8081; 
            }
    
            location /images {
                valid_referers none blocked www.mywebsite.com mywebsite.com;
                if ($invalid_referer) {
                    return 403;
                }
                proxy_pass http://127.0.0.1:8081/images; 
            }
        }
    }
  • 相关阅读:
    转:理想主义终结年代的七种兵器
    基础地理空间框架
    coldplay 全集下载
    S40 用google sync同步通讯录(转)
    分享一个关于Steve Jobs演讲的分析
    转:我们时代的思想责任与尊严
    nginx 视频流
    vue 使用路由重复跳转同一页面
    批处理文件编写
    ZBB – ZERO Bug Bounce
  • 原文地址:https://www.cnblogs.com/ciaos/p/4902897.html
Copyright © 2011-2022 走看看