GithubHelp home page GithubHelp logo

Comments (9)

dotkrnl avatar dotkrnl commented on August 20, 2024
 location / {
     try_files $uri $uri/ @kohana;
 }
 location @kohana {
     rewrite ^/(.+)$ /index.php$request_uri last;
 }

在你的场景中,因为您安装到了非根,需要将上面的 /index.php 改成对应位置,并且可能需要修改一下 OJ 配置中的 base。

Regards,
Jason Lau

from hustoj.

shinelinxx avatar shinelinxx commented on August 20, 2024

谢谢你的回复,但是在实际的配置中我确实还是存在问题。所以我想再次确认一下。
首先、我的web目录是/var/www/html

OJ所在目录为/var/www/html/OJ

我的'base_url' => '/OJ/', // should ends with /, for example '/oj/'
//设置为其他就我不能访问OJ主页了。

nginx.conf
location / {
try_files $uri $uri/ @kohana;
}
location @kohana {
rewrite ^/(.+)$ /index.php$request_uri last;
}
location ~ .php$ {
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
include fastcgi_params;
fastcgi_split_path_info ^(.+.php)(/?.*)$;
fastcgi_param PATH_INFO $fastcgi_path_info;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
}
那么我的base_url还要修改么?
/index.php呢,修改为/var/www/html/OJ/index.php等尝试都进入不了。
http://115.28.54.193/OJ/index.php/status
直接访问是可以的。

from hustoj.

dotkrnl avatar dotkrnl commented on August 20, 2024

不清楚 nginx 非根如何配置的,HUSTOJ 这里的配置没有问题。
你需要将 http://115.28.54.193/OJ/status/ 配置为导向 http://115.28.54.193/OJ/index.php/status/
如果是在根下,只需要按照我提供的 nginx 配置文件。

from hustoj.

shinelinxx avatar shinelinxx commented on August 20, 2024

Thank you helping me solve the problem above.

I change the rewrite in location @kohana to
rewrite ^(/\w+)/(.+)$ $1/index.php/$2$query_string last;

Now I can access every page but another problem arises. I can't login.

I use $query_string and $args, but nothing happens.

I access to the rewrite_log and can't Find any $args in it.

I press F12 when login and I find the post information.

If you can provide any other Information or the configure about php in nginx or the URI to login, it would be better.

eg. http://115.28.54.193/OJ/user/login?userName=xxx&pw=xxx
or http://115.28.54.193/OJ/user/login/name/pw
or http://115.28.54.193/OJ/user/login/pw/name

或者我想应该是post后台的变量名不一致导致的吧,看来只能尝试读源码了。。。。

谢谢了。

from hustoj.

dotkrnl avatar dotkrnl commented on August 20, 2024

Login 是 POST 的不是 GET 的。
请描述一下情况,发一下 PHP 日志?

from hustoj.

shinelinxx avatar shinelinxx commented on August 20, 2024

nginx的log如下:
error.log:
2015/12/26 18:30:58 [notice] 13855#0: *16871 "^(/\w+)/(.+)$" matches "/OJ/user/login", client: 218.205.20.61, server: localhost, request: "POST /OJ/user/login HTTP/1.1", host: "115.28.54.193", referrer: "http://115.28.54.193/OJ/user/login"
2015/12/26 18:30:58 [notice] 13855#0: *16871 rewritten data: "/OJ/index.php/user/login", args: "", client: 218.205.20.61, server: localhost, request: "POST /OJ/user/login HTTP/1.1", host: "115.28.54.193", referrer: "http://115.28.54.193/OJ/user/login"

access.log:
218.205.20.61 - - [26/Dec/2015:18:30:58 +0800] "POST /OJ/user/login HTTP/1.1" 302 5 username=test&pwd=test "http://115.28.54.193/OJ/user/login" "Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/43.0.2357.65 Safari/537.36" -
218.205.20.61 - - [26/Dec/2015:18:30:58 +0800] "GET /OJ/ HTTP/1.1" 200 4899 - "http://115.28.54.193/OJ/user/login" "Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/43.0.2357.65 Safari/537.36" -

如上,access日志格式为
$remote_addr - $remote_user [$time_local] "$request" $status $body_bytes_sent $request_body "$http_referer" "$http_user_agent" $http_x_forwarded_for

可以看到post参数。

PHP中没有错误日志,PHP-FPM的日志无关。

from hustoj.

dotkrnl avatar dotkrnl commented on August 20, 2024

表现为无错误,但没有登录成功?
你可以检查并尝试清空 Cookie。

from hustoj.

shinelinxx avatar shinelinxx commented on August 20, 2024

最终还是没能解决,表现为无错误。如果密码正确会跳转到首页,但是表现为无登录状态,如果密码错误依然会留在登录页。难道是登录后的信息没有存在session里?不懂php,如果找不到解决方案,只能放假回去边学边看了。

from hustoj.

dotkrnl avatar dotkrnl commented on August 20, 2024

我之前遇到过这个问题,是因为 session 和 cookie 没有配置清楚。但是具体原因我已经忘记了,抱歉。
你可以检查一遍配置完整,Cookie 正确写入,并且浏览器清空了原有的带有 Session 信息的 Cookie。
如果仍需要帮助,请再 open 这一 issue。

from hustoj.

Related Issues (18)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.