且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

Nginx配置

更新时间:2022-09-27 20:11:19

Nginx环境搭建成功后需要修改的配置文件:

在配置Nginx时遇到的问题, 防止以后遇到又不知所措:

php.ini中session.save_path的路径给的是/tmp, 后台登录一直提示验证码错误, 登录成功后也无法正确跳转, 以为是代码的问题, 又调试了半天的代码, 都没有问题, 才想到是session的问题, 这种问题是session没有设置成功, 后来改为这个/var/lib/php/session,  然后给这个文件夹权限就好了 !

nginx.conf:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
server {
    listen       80;
    server_name  www.ipower001.com ipoweroo1.com;
    root         /webmanage/gongdian/;
    charset utf-8;
 
    access_log logs/gongdian.access.log;
    #index index.html index.htm index.php;
 
    # Load configuration files for the default server block.
    #include /webmanage/gongdian/.htaccess;
 
    location / {
        index index.php index.html index.html;
 
        if (!-e $request_filename){
            rewrite ^(.*)$ /index.php?s=$1 last;
            break;
        }
    }
 
    location ~ \.php$ {
        fastcgi_pass   127.0.0.1:9000;
        fastcgi_index  index.php;
        fastcgi_param  SCRIPT_FILENAME  /scripts$fastcgi_script_name;
        fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
        include        fastcgi_params;
    }
}
 
 
然后需要修改php.ini文件中的配置:
session的存放路径:
session.save_path = "/var/lib/php/session"   需要给这个文件夹权限,否则session无效
 
完毕!





      本文转自噼里啪啦啦 51CTO博客,原文链接:http://blog.51cto.com/pilipala/1907676,如需转载请自行联系原作者