• nginx其他目录下上传站点


    1、查看主配置文件
    
    [root@bogon ~]# cat /etc/nginx/nginx.conf
    user  root root;
    worker_processes auto;
    
    worker_rlimit_nofile 51200;
    
    
    events
    	{
    		use epoll;
    		worker_connections 65535;
    	}
    
    http
    	{
    		include       mime.types;
    		default_type  application/octet-stream;
    
    		server_names_hash_bucket_size 128;
    		client_header_buffer_size 32k;
    		large_client_header_buffers 4 32k;
    		client_max_body_size 50m;
    
    		sendfile on;
    		server_tokens off;
    		tcp_nopush     on;
    		keepalive_timeout 60;
    		tcp_nodelay on;
    
    		fastcgi_connect_timeout 300;
    		fastcgi_send_timeout 300;
    		fastcgi_read_timeout 300;
    		fastcgi_buffer_size 256k;
    		fastcgi_buffers 4 256k;
    		fastcgi_busy_buffers_size 256k;
    		fastcgi_temp_file_write_size 256k;
    
    		gzip on;
    		gzip_min_length  1k;
    		gzip_buffers     4 16k;
    		gzip_http_version 1.0;
    		gzip_comp_level 3;
    		gzip_types       text/plain text/xml text/css application/x-javascript application/xml application/xml+rss text/javascript application/atom+xml;
    		gzip_vary on;
                    log_format  access  '$remote_addr - $remote_user [$time_local] "$request" '
                                        '$status $body_bytes_sent "$http_referer" '
                                        '"$http_user_agent" $http_x_forwarded_for';
    
    server
    	{
            	listen       80;
            	server_name 192.168.0.204;              #填写 ip 或者域名
            	index index.html index.htm default.html index.php;
            	root  //www/wwwroot/website/;
    
            	if (!-e $request_filename) {            #访问路径的文件不存在则重写URL转交给ThinkPHP处理
                		rewrite  ^/(.*)$  /index.php/$1  last;
                		break;
            }
            
    
    		location ~ [^/].php(/|$)
    	    		{
            			try_files $uri =404;
    				fastcgi_pass  127.0.0.1:9000;
    				fastcgi_index index.php;
    				include fastcgi.conf;                   #注意这个include 这个配置文件是nginx自带的,一定要有
    	
    				#下面这 8 行统称为fastcgi_params的配置,nginx也有自带的fastcgi_params,但是报错,按照下面的就行
    				#宝塔面板里面 直接把这 8 行写到了一个pathinfo.conf文件里面,用一句话include pathinfo.conf代替
    
    				set $real_script_name $fastcgi_script_name;
    				if ($fastcgi_script_name ~ "^(.+?.php)(/.+)$") {
                    			set $real_script_name $1;
                    			set $path_info $2;
     				}
    				fastcgi_param SCRIPT_FILENAME $document_root$real_script_name;
    				fastcgi_param SCRIPT_NAME $real_script_name;
    				fastcgi_param PATH_INFO $path_info;
    
    
        			}
    
    		location /status {
    			stub_status on;
    			access_log   off;
    		}
    
    		location ~ .*.(gif|jpg|jpeg|png|bmp|swf)$
    			{
    				expires      15d;
    			}
    
    		location ~ .*.(js|css)?$
    			{
    				expires      6h;
    			}
    		access_log  /var/www/ceshi.access.log  access;
    		error_log  /var/www/ceshi.error.log;
    	}
    include /etc/nginx/conf.d/*.conf;         #nginx使用include配置多虚拟主机,需要加 ';'
    
    }
    
    
    2、创建其他站点目录
    
    [root@bogon ~]# mkdir /website/
    
    
    3、在目录下放静态文件
    
    注意:静态文件名必须是index.html   其他的不行,不能改名字
    
    [root@bogon ~]# cd /website/
    [root@bogon website]# echo hello >> index.html 
    [root@bogon website]# cat index.html 
    hello
    
    
    4、配置nginx子配置文件
    
    [root@bogon conf.d]# cat /etc/nginx/conf.d/test6.conf 
    server
        {
            listen       8085;
            server_name 192.168.0.204;              #填写 ip 或者域名
            index index.html index.htm default.html index.php;
            root  /var/www/www.test.com/;
    
            if (!-e $request_filename) {            #访问路径的文件不存在则重写URL转交给ThinkPHP处理
                rewrite  ^/(.*)$  /index.php/$1  last;
                break;
            }
            
    
    	location ~ [^/].php(/|$)
    	    {
            	try_files $uri =404;
    		fastcgi_pass  127.0.0.1:9000;
    		fastcgi_index index.php;
    		include fastcgi.conf;                   #注意这个include 这个配置文件是nginx自带的,一定要有
    	
    		#下面这 8 行统称为fastcgi_params的配置,nginx也有自带的fastcgi_params,但是报错,按照下面的就行
    		#宝塔面板里面 直接把这 8 行写到了一个pathinfo.conf文件里面,用一句话include pathinfo.conf代替
    
    		set $real_script_name $fastcgi_script_name;
    		if ($fastcgi_script_name ~ "^(.+?.php)(/.+)$") {
                    	set $real_script_name $1;
                    	set $path_info $2;
     		}
    		fastcgi_param SCRIPT_FILENAME $document_root$real_script_name;
    		fastcgi_param SCRIPT_NAME $real_script_name;
    		fastcgi_param PATH_INFO $path_info;
    
    
        	}       
    
    
            location /status {
                stub_status  on;
                access_log   off;
            }
    
    	location /favicon.ico {
    	    root html;
    	}
    
            location ~ .*.(gif|jpg|jpeg|png|bmp|swf)$
                {
                    expires      15d;
                }
    
            location ~ .*.(js|css)?$
                {
                    expires      6h;
                }
            access_log  /var/www/ceshi.access.log  access;
            error_log  /var/www/ceshi.error.log;
        }
    
    
    5、重新加载nginx
    
    [root@bogon ~]# nginx -s reload
    
    
    6、访问测试
    
    [root@bogon conf.d]# curl http://127.0.0.1:8083
    hello
    
    测试成功
    

      

  • 相关阅读:
    git 从创建到推送到远程,到拉取,实操
    《React后台管理系统实战 :三》header组件:页面排版、天气请求接口及页面调用、时间格式化及使用定时器、退出函数
    《React后台管理系统实战 :一》:目录结构、引入antd、引入路由、写login页面、使用antd的form登录组件、form前台验证、高阶函数/组件
    《React后台管理系统实战 :二》antd左导航:cmd批量创建子/目录、用antd进行页面布局、分离左导航为单独组件、子路由、动态写左导航、css样式相对陷阱
    《React后台管理系统实战 :四》产品分类管理页:添加产品分类、修改(更新)产品分类
    go的变量与常量
    Go 语言最简单程序的结构
    go的安装与测试
    java
    go语言
  • 原文地址:https://www.cnblogs.com/effortsing/p/10037881.html
Copyright © 2020-2023  润新知