OJ系统部署问题排查记录;PHP Fatal error: Uncaught PDOException: SQLSTATE[HY000] [1045]

前言

自己搭建的OJ系统移植到了另外一个服务器上,进行了重新部署配置,然后发现打不开了,页面首先提示404,打开nginx的error的日志文件,发现是文件权限不对,于是改了一通权限,重启nginx,页面又提示502,再次打开nginx日志文件排查问题所在。

nginx的日志文件的目录如下

/var/log/nginx/error.log

正文

在linux中一般的文件都可以用vim打开查看,于是看到如下记录

2020/04/09 08:00:11 [crit] 11025#11025: *2 connect() to unix:/run/php/php7.2-fpm.sock failed (2: No such file or directory) while connecting to upstream, client: 192.168.1.100, server: _, request: "GET / HTTP/1.1", upstream: "fastcgi://unix:/run/php/php7.2-fpm.sock:", host: "192.168.1.113"

看这个日志应该是nginx的配置好像有点问题,意思大概就是无法找到php7.2-fpm.sock,然后突然意识到php版本问题,应该是7.0版本,于是打开nginx目录下的默认配置文件,具体目录如下

/etc/nginx/sites-enabled/default

使用vim打开上面这个路径的这个文件即可打开配置文件,找到以下语句

fastcgi_pass unix:/run/php/php7.2-fpm.sock;

把7.2改成了7.0,原以为这样就可以,重启nginx,然后页面出现该网页无法正常工作http error 500.。。。。。

再次打开error.log,出现以下错误

2020/04/09 08:06:05 [error] 11086#11086: *1 FastCGI sent in stderr: "PHP message: PHP Fatal error:  Uncaught PDOException: SQLSTATE[HY000] [1045] Access denied for user 'debian-sys-maint'@'localhost' (using password: YES) in /home/judge/src/web/include/pdo.php:16
Stack trace:
#0 /home/judge/src/web/include/pdo.php(16): PDO->__construct('mysql:host=loca...', 'debian-sys-main...', '1HBDniSjkCEvrUA...', Array)
#1 /home/judge/src/web/include/memcache.php(43): pdo_query('select * FROM `...')
#2 /home/judge/src/web/index.php(23): mysql_query_cache('select * FROM `...')
#3 {main}
  thrown in /home/judge/src/web/include/pdo.php on line 16" while reading response header from upstream, client: 192.168.1.100, server: _, request: "GET / HTTP/1.1", upstream: "fastcgi://unix:/run/php/php7.0-fpm.sock:", host: "192.168.1.113"
PHP message: PHP Fatal error:  Uncaught PDOException: SQLSTATE[HY000] [1045] Access denied for user 'debian-sys-maint'@'localhost' (using password: YES) 

看到这句应该是连接数据库的时候出错了,具体原因应该是用户名密码错误,于是改找到几个配置文件修改了与数据库一致的密码,然后重启nginx,又又又是http 500,查看error.log文件发现以下问题

2020/04/09 09:53:17 [error] 12278#12278: *2 FastCGI sent in stderr: "PHP message: PHP Notice:  Undefined offset: 0 in /home/judge/src/web/index.php on line 60
PHP message: PHP Warning:  require(template/bs3/index.php): failed to open stream: Permission denied in /home/judge/src/web/index.php on line 68
PHP message: PHP Fatal error:  require(): Failed opening required 'template/bs3/index.php' (include_path='.:/usr/share/php') in /home/judge/src/web/index.php on line 68" while reading response header from upstream, client: 192.168.1.100, server: _, request: "GET / HTTP/1.1", upstream: "fastcgi://unix:/run/php/php7.0-fpm.sock:", host: "192.168.1.113"

主要看这句

PHP message: PHP Fatal error:  require(): Failed opening required 'template/bs3/index.php' (include_path='.:/usr/share/php') in /home/judge/src/web/index.php on line 68" while reading response header from upstream, client: 192.168.1.100, server: _, request: "GET / HTTP/1.1", upstream: "fastcgi://unix:/run/php/php7.0-fpm.sock:", host: "192.168.1.113"

意思就是打开该路径下的index.php文件失败,应该又是文件权限问题,于是从文件夹template开始逐层检查文件和文件夹权限,发现路径中的bs3文件夹权限不对,后修改了权限,终于成功打开了首页,至此OJ系统部署问题排查完成。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值