freefcw / hustoj

the online judge system for acm/icpc

Home Page:http://www.hustoj.org

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

why don't i get any page after open main page?

shinelinxx opened this issue · comments

我没有使用apache,直接用了php5+nginx1.4,打不开页面,数据库用旧oj改了下。因为没学过php,就照着jsp去看了,但是href让我不能理解,不应该跳转到php吗,还是我文件部署的问题。
http://115.28.54.193/OJ/
下面是我nginx的配置
nginx.txt
期待并谢谢你的解答。

 location / {
     try_files $uri $uri/ @kohana;
 }
 location @kohana {
     rewrite ^/(.+)$ /index.php$request_uri last;
 }

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

Regards,
Jason Lau

谢谢你的回复,但是在实际的配置中我确实还是存在问题。所以我想再次确认一下。
首先、我的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
直接访问是可以的。

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

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后台的变量名不一致导致的吧,看来只能尝试读源码了。。。。

谢谢了。

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

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的日志无关。

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

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

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