nginx 配置thinkphp与laravel

2 篇文章 0 订阅
2 篇文章 0 订阅

thinkphp:

server {
    listen       80;
    server_name  www.tp5_1.com;
    index index.html index.htm index.php;
    root E:/allen/project/WWW/user/tp5.1.29/public;
    
    index  index.html index.htm index.php;
    error_page  404              /404.html;
    location = /404.html {
        return 404 'Sorry, File not Found!';
    }
    error_page  500 502 503 504  /50x.html;
    location = /50x.html {
        root   E:/allen/project/WWW/tp5/public;
    }
    location / {
        try_files $uri @rewrite;
    }
    location @rewrite {
        set $static 0;
        if  ($uri ~ \.(css|js|jpg|jpeg|png|gif|ico|woff|eot|svg|css\.map|min\.map)$) {
            set $static 1;
        }
        if ($static = 0) {
            rewrite ^/(.*)$ /index.php?s=/$1;
        }
    }
    location ~ /Uploads/.*\.php$ {
      deny all;
    }
    location ~ \.php/ {
        if ($request_uri ~ ^(.+\.php)(/.+?)($|\?)) { }
       fastcgi_pass 127.0.0.1:9000;
       include fastcgi_params;
       fastcgi_param SCRIPT_NAME     $1;
       fastcgi_param PATH_INFO       $2;
       fastcgi_param SCRIPT_FILENAME $document_root$1;
    }
    location ~ \.php$ {
    fastcgi_pass 127.0.0.1:9000;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        include fastcgi_params;
    }
    location ~ /\.ht {
        deny  all;
    }
}

laravel:

server {
    listen       80;
    #如果需要配置ssl
    #listen       80;
    #listen       443;
    #ssl on;
    #ssl_certificate      cert/2992361_yunjiankong.yingtongkeji.com.pem;
    #ssl_certificate_key  cert/2992361_yunjiankong.yingtongkeji.com.key;
    #ssl_session_timeout 5m;
    #ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:ECDHE:ECDH:AES:HIGH:!NULL:!aNULL:!MD5:!ADH:!RC4;
    #ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
    #ssl_prefer_server_ciphers on;
    
    server_name  new.awt.com;
    index index.html index.htm index.php;
    root E:/allen/project/WWW/project/new_awt/public;
    location ~ .*\.(php|php5)?$
    {
        fastcgi_pass  127.0.0.1:9000;
        fastcgi_index index.php;
        fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
        include fastcgi_params;
    }
    location ~ {
        try_files $uri $uri/ /index.php?$query_string;
    }
    location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$
    {
        expires 1d;
    }
    location ~ .*\.(js|css)?$
    {
        expires 1d;
    }
    location / {
        if (!-e $request_filename) {
            rewrite ^/index.php?(.*)$ /index.php?s=$1 last;
            break;
        }
    }
    #access_log  /usr/local/nginx_log/laravel.log;
}
以上配置写法纯属参考,并不是唯一方案。

nginx允许目录列表

#主要就是再localhost:80端口的配置文件中做出如下配置
#有两点
#第一:sendfile on; 可以直接写再http模块中
#第二:location / {index index.html index.php index.htm; autoindex on;}

server {
    listen       80;
    server_name  localhost;
    index index.html index.htm index.php;
    root C:/phpstudy_pro/WWW;
	location / {
		index index.html index.php index.htm;
		autoindex on;
	}
    location ~ .*\.(php|php5)?$
    {
        fastcgi_pass  127.0.0.1:9000;
        fastcgi_index index.php;
        fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
        include fastcgi_params;
    }
    #access_log  /usr/local/nginx_log/laravel.log;
}
server {
	listen       80;
	server_name  www.jjzshome.com;
	root   		 "D:/phpstudy_pro/WWW/shichangyibu/www.jjzshome.com";
	location / {
		index index.html index.php;
		autoindex  off;
		rewrite ^/(.*)$ https://$host/$1 permanent;
	}
	
	location ~ \.php(.*)$ {
		fastcgi_pass   127.0.0.1:9000;
		fastcgi_index  index.php;
		fastcgi_split_path_info  ^((?U).+\.php)(/?.+)$;
		fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
		fastcgi_param  PATH_INFO  $fastcgi_path_info;
		fastcgi_param  PATH_TRANSLATED  $document_root$fastcgi_path_info;
		include        fastcgi_params;
	}
	
	error_log  D:/phpstudy_pro/Extensions/Nginx1.15.11/logs/www_jjzshome_com_error.log;
	access_log D:/phpstudy_pro/Extensions/Nginx1.15.11/logs/www_jjzshome_com_assess.log;
}


server {
	listen       443 ssl;
	server_name  www.jjzshome.com;
	root   		 "D:/phpstudy_pro/WWW/shichangyibu/www.jjzshome.com";
	
	ssl_certificate     D:/phpstudy_pro/Extensions/Nginx1.15.11/conf/ssl/www.jjzshome.com/8943351_www.jjzshome.com.pem;
    ssl_certificate_key D:/phpstudy_pro/Extensions/Nginx1.15.11/conf/ssl/www.jjzshome.com/8943351_www.jjzshome.com.key;
	
    ssl_session_timeout 5m;
    ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:ECDHE:ECDH:AES:HIGH:!NULL:!aNULL:!MD5:!ADH:!RC4;
    ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
    ssl_prefer_server_ciphers on;
	
	location / {
		index index.html index.php;
		
		error_page 400 D:/phpstudy_pro/WWW/error/400.html;
		error_page 403 D:/phpstudy_pro/WWW/error/403.html;
		error_page 404 D:/phpstudy_pro/WWW/error/404.html;
		error_page 500 D:/phpstudy_pro/WWW/error/500.html;
		error_page 501 D:/phpstudy_pro/WWW/error/501.html;
		error_page 502 D:/phpstudy_pro/WWW/error/502.html;
		error_page 503 D:/phpstudy_pro/WWW/error/503.html;
		error_page 504 D:/phpstudy_pro/WWW/error/504.html;
		error_page 505 D:/phpstudy_pro/WWW/error/505.html;
		error_page 506 D:/phpstudy_pro/WWW/error/506.html;
		error_page 507 D:/phpstudy_pro/WWW/error/507.html;
		error_page 509 D:/phpstudy_pro/WWW/error/509.html;
		error_page 510 D:/phpstudy_pro/WWW/error/510.html;
		autoindex  off;
	}
	
	location ~ \.php(.*)$ {
		fastcgi_pass   127.0.0.1:9000;
		fastcgi_index  index.php;
		fastcgi_split_path_info  ^((?U).+\.php)(/?.+)$;
		fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
		fastcgi_param  PATH_INFO  $fastcgi_path_info;
		fastcgi_param  PATH_TRANSLATED  $document_root$fastcgi_path_info;
		include        fastcgi_params;
	}
	
	error_log  D:/phpstudy_pro/Extensions/Nginx1.15.11/logs/www_jjzshome_com_error.log;
	access_log D:/phpstudy_pro/Extensions/Nginx1.15.11/logs/www_jjzshome_com_assess.log;
}
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值