这一次,我们重新定义智慧互联网

微信号:foreverbestvip

详细了解

每一次尝试都代表着时代的进步

微信号:foreverbestvip

详细了解

这一刻,我们都是世界的佼佼者

微信号:foreverbestvip

详细了解

智慧互联网产品开发的领航者

微信号:foreverbestvip

详细了解

Nginx单域名配置多个二级目录网站

免费 - Sunrise - - 浏览量: 0 - 文章来源

upstream hyperf {
    server 127.0.0.1:9501;
    ip_hash;
}

server {
    listen 80 default_server;
    listen [::]:80 default_server;

    server_name _;
    index index.php index.html index.htm;
    root /www/blog/public;

    charset utf-8;
    etag on;
    gzip on;
    gzip_vary on;
    gzip_http_version 1.0;
    gzip_min_length 1k;
    gzip_buffers 4 16k;
    gzip_comp_level 2;
    gzip_disable msie6;
    gzip_types text/plain text/css application/json application/javascript application/x-javascript text/javascript text/xml application/xml application/xml+rss;
    client_max_body_size 110m;
    client_body_buffer_size 1024k;
    keepalive_timeout   60;
    sendfile on;
    sendfile_max_chunk 512k;
    tcp_nopush on;
    tcp_nodelay on;

    error_page 404 403 500 502 503 504 /404.html;

    location = /404.html {
        root /usr/share/nginx/html;
    }

    location = /favicon.ico { access_log off; log_not_found off; }
    location = /robots.txt  { access_log off; log_not_found off; }

    location / {
        try_files $uri $uri/ /index.php$is_args$query_string;

        if (!-e $request_filename) {
            rewrite ^/(.*)$ /index.php?s=$1 last;
        }

        location ~ \.php$ {
            if (!-f $request_filename) {
                return 404;
            }

            fastcgi_split_path_info ^(.+\.php)(/.+)$;
            # fastcgi_pass   127.0.0.1:9000;
            fastcgi_pass unix:/var/run/php/php7.4-fpm.sock;
            fastcgi_index index.php;
            include fastcgi_params;
            fastcgi_param SCRIPT_FILENAME $realpath_root$fastcgi_script_name;
            fastcgi_param DOCUMENT_ROOT $realpath_root;
            fastcgi_intercept_errors off;
            fastcgi_buffer_size 32k;
            fastcgi_buffers 16 16k;
            fastcgi_connect_timeout 300;
            fastcgi_send_timeout 300;
            fastcgi_read_timeout 600;
        }

        access_log /var/log/nginx/blog-access.log;
        error_log /var/log/nginx/blog-error.log error;
    } 

    location ^~ /laravel {
        root /www/frameworks/laravel/public;
        try_files $uri $uri/ /laravel/index.php$is_args$query_string;

        if (!-e $request_filename) {
            rewrite ^ /laravel/index.php last;
        }

        location ~ \.php$ {
            if (!-f $request_filename) {
                return 404;
            }

            fastcgi_split_path_info ^(.+\.php)(/.+)$;
            # fastcgi_pass   127.0.0.1:9000;
            fastcgi_pass unix:/var/run/php/php7.4-fpm.sock;
            fastcgi_index index.php;
            include fastcgi_params;
            fastcgi_param SCRIPT_FILENAME $realpath_root$fastcgi_script_name;
            fastcgi_param DOCUMENT_ROOT $realpath_root;
            fastcgi_intercept_errors off;
            fastcgi_buffer_size 32k;
            fastcgi_buffers 16 16k;
            fastcgi_connect_timeout 300;
            fastcgi_send_timeout 300;
            fastcgi_read_timeout 600;
        }

        access_log /var/log/nginx/frameworks-laravel-access.log;
        error_log /var/log/nginx/frameworks-laravel-error.log error;
    }

    location ^~ /symfony {
        root /www/frameworks/symfony/public;
        try_files $uri $uri/ /symfony/index.php$is_args$query_string;

        if (!-e $request_filename) {
            rewrite ^ /symfony/index.php last;
        }

        location ~ \.php$ {
            if (!-f $request_filename) {
                return 404;
            }

            fastcgi_split_path_info ^(.+\.php)(/.+)$;
            # fastcgi_pass   127.0.0.1:9000;
            fastcgi_pass unix:/var/run/php/php7.4-fpm.sock;
            fastcgi_index index.php;
            include fastcgi_params;
            fastcgi_param SCRIPT_FILENAME $realpath_root$fastcgi_script_name;
            fastcgi_param DOCUMENT_ROOT $realpath_root;
            fastcgi_intercept_errors off;
            fastcgi_buffer_size 32k;
            fastcgi_buffers 16 16k;
            fastcgi_connect_timeout 300;
            fastcgi_send_timeout 300;
            fastcgi_read_timeout 600;
        }

        access_log /var/log/nginx/frameworks-symfony-access.log;
        error_log /var/log/nginx/frameworks-symfony-error.log error;
    }

    location ^~ /thinkphp {
        root /www/frameworks/thinkphp/public;
        try_files $uri $uri/ /thinkphp/index.php$is_args$query_string;

        if (!-e $request_filename) {
            rewrite ^ /thinkphp/index.php last;
        }

        location ~ \.php$ {
            if (!-f $request_filename) {
                return 404;
            }

            fastcgi_split_path_info ^(.+\.php)(/.+)$;
            # fastcgi_pass   127.0.0.1:9000;
            fastcgi_pass unix:/var/run/php/php7.4-fpm.sock;
            fastcgi_index index.php;
            include fastcgi_params;
            fastcgi_param SCRIPT_FILENAME $realpath_root$fastcgi_script_name;
            fastcgi_param DOCUMENT_ROOT $realpath_root;
            fastcgi_intercept_errors off;
            fastcgi_buffer_size 32k;
            fastcgi_buffers 16 16k;
            fastcgi_connect_timeout 300;
            fastcgi_send_timeout 300;
            fastcgi_read_timeout 600;
        }

        access_log /var/log/nginx/frameworks-thinkphp-access.log;
        error_log /var/log/nginx/frameworks-thinkphp-error.log error;
    }

    location ^~ /slim {
        root /www/frameworks/slim/public;
        try_files $uri $uri/ /slim/index.php$is_args$query_string;

        if (!-e $request_filename) {
            rewrite ^ /slim/index.php last;
        }

        location ~ \.php$ {
            if (!-f $request_filename) {
                return 404;
            }

            fastcgi_split_path_info ^(.+\.php)(/.+)$;
            # fastcgi_pass   127.0.0.1:9000;
            fastcgi_pass unix:/var/run/php/php7.4-fpm.sock;
            fastcgi_index index.php;
            include fastcgi_params;
            fastcgi_param SCRIPT_FILENAME $realpath_root$fastcgi_script_name;
            fastcgi_param DOCUMENT_ROOT $realpath_root;
            fastcgi_intercept_errors off;
            fastcgi_buffer_size 32k;
            fastcgi_buffers 16 16k;
            fastcgi_connect_timeout 300;
            fastcgi_send_timeout 300;
            fastcgi_read_timeout 600;
        }

        access_log /var/log/nginx/frameworks-slim-access.log;
        error_log /var/log/nginx/frameworks-slim-error.log error;
    }

    location ^~ /yii {
        root /www/frameworks/yii/web;
        try_files $uri $uri/ /yii/index.php$is_args$query_string;

        if (!-e $request_filename) {
            rewrite ^ /yii/index.php last;
        }

        location ~ \.php$ {
            if (!-f $request_filename) {
                return 404;
            }

            fastcgi_split_path_info ^(.+\.php)(/.+)$;
            # fastcgi_pass   127.0.0.1:9000;
            fastcgi_pass unix:/var/run/php/php7.4-fpm.sock;
            fastcgi_index index.php;
            include fastcgi_params;
            fastcgi_param SCRIPT_FILENAME $realpath_root$fastcgi_script_name;
            fastcgi_param DOCUMENT_ROOT $realpath_root;
            fastcgi_intercept_errors off;
            fastcgi_buffer_size 32k;
            fastcgi_buffers 16 16k;
            fastcgi_connect_timeout 300;
            fastcgi_send_timeout 300;
            fastcgi_read_timeout 600;
        }

        access_log /var/log/nginx/frameworks-yii-access.log;
        error_log /var/log/nginx/frameworks-yii-error.log error;
    }

    location ^~ /codeigniter {
        root /www/frameworks/codeigniter/public;
        try_files $uri $uri/ /codeigniter/index.php$is_args$query_string;

        if (!-e $request_filename) {
            rewrite ^ /codeigniter/index.php last;
        }

        location ~ \.php$ {
            if (!-f $request_filename) {
                return 404;
            }

            fastcgi_split_path_info ^(.+\.php)(/.+)$;
            # fastcgi_pass   127.0.0.1:9000;
            fastcgi_pass unix:/var/run/php/php7.4-fpm.sock;
            fastcgi_index index.php;
            include fastcgi_params;
            fastcgi_param SCRIPT_FILENAME $realpath_root$fastcgi_script_name;
            fastcgi_param DOCUMENT_ROOT $realpath_root;
            fastcgi_intercept_errors off;
            fastcgi_buffer_size 32k;
            fastcgi_buffers 16 16k;
            fastcgi_connect_timeout 300;
            fastcgi_send_timeout 300;
            fastcgi_read_timeout 600;
        }

        access_log /var/log/nginx/frameworks-codeigniter-access.log;
        error_log /var/log/nginx/frameworks-codeigniter-error.log error;
    }

    location ^~ /zendframework {
        root /www/frameworks/zendframework/public;
        try_files $uri $uri/ /zendframework/index.php$is_args$query_string;

        if (!-e $request_filename) {
            rewrite ^ /zendframework/index.php last;
        }

        location ~ \.php$ {
            if (!-f $request_filename) {
                return 404;
            }

            fastcgi_split_path_info ^(.+\.php)(/.+)$;
            # fastcgi_pass   127.0.0.1:9000;
            fastcgi_pass unix:/var/run/php/php7.4-fpm.sock;
            fastcgi_index index.php;
            include fastcgi_params;
            fastcgi_param SCRIPT_FILENAME $realpath_root$fastcgi_script_name;
            fastcgi_param DOCUMENT_ROOT $realpath_root;
            fastcgi_intercept_errors off;
            fastcgi_buffer_size 32k;
            fastcgi_buffers 16 16k;
            fastcgi_connect_timeout 300;
            fastcgi_send_timeout 300;
            fastcgi_read_timeout 600;
        }

        access_log /var/log/nginx/frameworks-zendframework-access.log;
        error_log /var/log/nginx/frameworks-zendframework-error.log error;
    }

    location ^~ /cakephp {
        root /www/frameworks/cakephp/webroot;
        try_files $uri $uri/ /cakephp/index.php$is_args$query_string;

        if (!-e $request_filename) {
            rewrite ^ /cakephp/index.php last;
        }

        location ~ \.php$ {
            if (!-f $request_filename) {
                return 404;
            }

            fastcgi_split_path_info ^(.+\.php)(/.+)$;
            # fastcgi_pass   127.0.0.1:9000;
            fastcgi_pass unix:/var/run/php/php7.4-fpm.sock;
            fastcgi_index index.php;
            include fastcgi_params;
            fastcgi_param SCRIPT_FILENAME $realpath_root$fastcgi_script_name;
            fastcgi_param DOCUMENT_ROOT $realpath_root;
            fastcgi_intercept_errors off;
            fastcgi_buffer_size 32k;
            fastcgi_buffers 16 16k;
            fastcgi_connect_timeout 300;
            fastcgi_send_timeout 300;
            fastcgi_read_timeout 600;
        }

        access_log /var/log/nginx/frameworks-cakephp-access.log;
        error_log /var/log/nginx/frameworks-cakephp-error.log error;
    }

    location ^~ /phalcon {
        root /www/frameworks/phalcon/public;
        try_files $uri $uri/ /phalcon/index.php$is_args$query_string;

        if (!-e $request_filename) {
            rewrite ^ /phalcon/index.php last;
        }

        location ~ \.php$ {
            if (!-f $request_filename) {
                return 404;
            }

            fastcgi_split_path_info ^(.+\.php)(/.+)$;
            # fastcgi_pass   127.0.0.1:9000;
            fastcgi_pass unix:/var/run/php/php7.4-fpm.sock;
            fastcgi_index index.php;
            include fastcgi_params;
            fastcgi_param SCRIPT_FILENAME $realpath_root$fastcgi_script_name;
            fastcgi_param DOCUMENT_ROOT $realpath_root;
            fastcgi_intercept_errors off;
            fastcgi_buffer_size 32k;
            fastcgi_buffers 16 16k;
            fastcgi_connect_timeout 300;
            fastcgi_send_timeout 300;
            fastcgi_read_timeout 600;
        }

        access_log /var/log/nginx/frameworks-phalcon-access.log;
        error_log /var/log/nginx/frameworks-phalcon-error.log error;
    }

    location ^~ /phpixie {
        root /www/frameworks/phpixie/web;
        try_files $uri $uri/ /phpixie/index.php$is_args$query_string;

        if (!-e $request_filename) {
            rewrite ^ /phpixie/index.php last;
        }

        location ~ \.php$ {
            if (!-f $request_filename) {
                return 404;
            }

            fastcgi_split_path_info ^(.+\.php)(/.+)$;
            # fastcgi_pass   127.0.0.1:9000;
            fastcgi_pass unix:/var/run/php/php7.4-fpm.sock;
            fastcgi_index index.php;
            include fastcgi_params;
            fastcgi_param SCRIPT_FILENAME $realpath_root$fastcgi_script_name;
            fastcgi_param DOCUMENT_ROOT $realpath_root;
            fastcgi_intercept_errors off;
            fastcgi_buffer_size 32k;
            fastcgi_buffers 16 16k;
            fastcgi_connect_timeout 300;
            fastcgi_send_timeout 300;
            fastcgi_read_timeout 600;
        }

        access_log /var/log/nginx/frameworks-phpixie-access.log;
        error_log /var/log/nginx/frameworks-phpixie-error.log error;
    }

    location ^~ /fuelphp {
        root /www/frameworks/fuelphp/public;
        try_files $uri $uri/ /fuelphp/index.php$is_args$query_string;

        if (!-e $request_filename) {
            rewrite ^ /fuelphp/index.php last;
        }

        location ~ \.php$ {
            if (!-f $request_filename) {
                return 404;
            }

            fastcgi_split_path_info ^(.+\.php)(/.+)$;
            # fastcgi_pass   127.0.0.1:9000;
            fastcgi_pass unix:/var/run/php/php7.4-fpm.sock;
            fastcgi_index index.php;
            include fastcgi_params;
            fastcgi_param SCRIPT_FILENAME $realpath_root$fastcgi_script_name;
            fastcgi_param DOCUMENT_ROOT $realpath_root;
            fastcgi_intercept_errors off;
            fastcgi_buffer_size 32k;
            fastcgi_buffers 16 16k;
            fastcgi_connect_timeout 300;
            fastcgi_send_timeout 300;
            fastcgi_read_timeout 600;
        }

        access_log /var/log/nginx/frameworks-fuelphp-access.log;
        error_log /var/log/nginx/frameworks-fuelphp-error.log error;
    }

    location ^~ /hyperf {
        proxy_pass http://hyperf/;
    }
}

谈谈你的看法

请文明发言!