nginx+php无法读取session的值
nginx+php无法读取session的值
在php.ini设置了默认的session.save_path的路径为/tmp,保存的时候,可以保存成sess_*文件的,但读取的时候,就是读取不出来内容,将文件夹及文件设置设置为777也不行.手动指定了文件夹也是同样的问题lnmp安装教程:http://blog.haohtml.com/index.php/archives/6051
phpinfo:http://72.46.130.155/phpinfo.php
nginx.conf的配置
- /usr/local/nginx/conf/nginx.conf
- user www www;
- worker_processes 1;
- #error_log logs/error.log;
- #error_log logs/error.log notice;
- #error_log logs/error.log info;
- #pid logs/nginx.pid;
- events {
- worker_connections 1024;
- }
- http {
- include mime.types;
- default_type application/octet-stream;
- #log_format main '$remote_addr - $remote_user [$time_local] "$request" '
- # '$status $body_bytes_sent "$http_referer" '
- # '"$http_user_agent" "$http_x_forwarded_for"';
- #access_log logs/access.log main;
- sendfile on;
- #tcp_nopush on;
- #keepalive_timeout 0;
- keepalive_timeout 65;
- #gzip on;
- server {
- listen 80;
- server_name localhost;
- #charset koi8-r;
- #access_log logs/host.access.log main;
- location / {
- root html;
- index index.html index.htm;
- }
- #error_page 404 /404.html;
- # redirect server error pages to the static page /50x.html
- #
- error_page 500 502 503 504 /50x.html;
- location = /50x.html {
- root html;
- }
- # proxy the PHP scripts to Apache listening on 127.0.0.1:80
- #
- #location ~ \.php$ {
- # proxy_pass http://127.0.0.1;
- #}
- # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
- #
- location ~ \.php$ {
- root html;
- fastcgi_pass 127.0.0.1:9000;
- fastcgi_index index.php;
- fastcgi_param SCRIPT_FILENAME /usr/local/nginx/html$fastcgi_script_name;
- include fastcgi_params;
- }
- # deny access to .htaccess files, if Apache's document root
- # concurs with nginx's one
- #
- #location ~ /\.ht {
- # deny all;
- #}
- }
- # another virtual host using mix of IP-, name-, and port-based configuration
- #
- #server {
- # listen 8000;
- # listen somename:8080;
- # server_name somename alias another.alias;
- # location / {
- # root html;
- # index index.html index.htm;
- # }
- #}
- # HTTPS server
- #
- #server {
- # listen 443;
- # server_name localhost;
- # ssl on;
- # ssl_certificate cert.pem;
- # ssl_certificate_key cert.key;
- # ssl_session_timeout 5m;
- # ssl_protocols SSLv2 SSLv3 TLSv1;
- # ssl_ciphers ALL:!ADH:!EXPORT56:RC4+RSA:+HIGH:+MEDIUM:+LOW:+SSLv2:+EXP;
- # ssl_prefer_server_ciphers on;
- # location / {
- # root html;
- # index index.html index.htm;
- # }
- #}
- include /usr/local/nginx/conf/vhost/*.conf;
- 测试的sess.php内容,在本地apache没有问题
- <?php
- session_start();
- //session_save_path('./img');
- //echo session_save_path() . "<br>";
- $act = $_GET['act'];
- if ($act == 'show') {
- echo session_save_path()."<br>";
- print_r($_SESSION);
- } else {
- $_SESSION['test'] = 'abc';
- echo 'Welcome to page #1';
- $_SESSION['favcolor'] = 'greendd';
- $_SESSION['animal'] = 'caddt';
- $_SESSION['time'] = time();
- // Works if session cookie was accepted
- echo '<br /><a href="?act=show">page 2</a>';
- echo session_save_path()."<br>";
- print_r($_SESSION);
- }
- ?>
复制代码
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
已经解决了.是session.cookie_path引起的,我把他改成/tmp了,应该用/就可以了
{:2_166:}好贴,把解决问题得详细过程贴出来,方便后来者呀
php.ini session path配置的问题~