nginx的配置

nginx的配置

      部署服务器的时候,跟nginx打交道是必不可少的,然鹅,本人对里面的配置并不是很熟悉,十分惭愧!这不最近工作中就碰到问题了,折腾了好久,总算搞定了。现在来记录下

 1 #BINDING-XXX.php7.XXX.wang-START
 2 server
 3 {
 4     listen 80;
 5     server_name XXXXXX;
 6     index index.php index.html index.htm default.php default.htm default.html;
 7     root /data/www/esw;
 8 
 9 #    include XXX-php-74.conf;
10 #    include /www/server/panel/vhost/rewrite/XXX_easyswoole.conf;
11      location ~ \.php(.*)$ {
12        fastcgi_pass 127.0.0.1:9000;
13        fastcgi_index index.php;
14        fastcgi_split_path_info ^((?U).+\.php)(/?.+)$;
15        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
16        fastcgi_param PATH_INFO $1;
17       #fastcgi_param PATH_INFO $fastcgi_path_info;
18       #fastcgi_param PATH_TRANSLATED $document_root$fastcgi_path_info;
19        include fastcgi_params;
20     }
21     #禁止访问的文件或目录
22     location ~ ^/(\.user.ini|\.htaccess|\.git|\.svn|\.project|LICENSE|README.md)
23     {
24         return 404;
25     }
26 
27     #一键申请SSL证书验证目录相关设置
28     location ~ \.well-known{
29         allow all;
30     }
31 
32     location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$
33     {
34         expires      30d;
35         error_log off;
36         access_log /dev/null;
37     }
38     location ~ .*\.(js|css)?$
39     {
40         expires      12h;
41         error_log off;
42         access_log /dev/null;
43     }
44 #    access_log /www/wwwlogs/XXX.log;
45 #    error_log  /www/wwwlogs/XXX.error.log;
46 
47     location ~ {
48         proxy_pass http://127.0.0.1:9501;
49     }
50 }
51 #BINDING-XXXX.php7.XXX-END

1.配置参数说明:

1) 目录

listen 监听端口  server_name 域名  root 访问目录

2) fastcgi配置

fastcgi_pass:为后端的fastcgi  server的地址 (不配置这个的话,php文件无法解析,具体原因参考文章《CGI、FastCGI、PHP-CGI与PHP-FPM的概念以及各个之间的关系》)

fastcgi_index :fastcgi默认的主页资源

3)proxy_pass 

代理转发:设置被代理server的协议和地址

 

2.执行命令  netstat   -lntp

 

posted @ 2020-09-28 19:05  欢乐豆123  阅读(164)  评论(0编辑  收藏  举报