最近更换了网站空间,用的是cPanel后台控制面板,更换后访问网站显示500 Internal Server Error,经过搜索得知是目录和文件权限设置问题,是因为手贱在cPanel后台的“文件夹管理”里把网站目录的读写权限改了导致,按网上的方法很快把问题解决了。原文来自:http://blog.is36.com/cPanel_500_Internal_Server_Error/
Internal Server Error
The server encountered an internal error or misconfiguration and was unable to complete your request.
Please contact the server administrator, webmaster@pengzao.com and inform them of the time the error occurred, and anything you might have done that may have caused the error.
More information about this error may be available in the server error log.
Additionally, a 404 Not Found error was encountered while trying to use an ErrorDocument to handle the request.
Apache/2.2.24 (Unix) mod_ssl/2.2.24 OpenSSL/1.0.0-fips mod_auth_passthrough/2.1 mod_bwlimited/1.4 FrontPage/5.0.2.2635 mod_perl/2.0.6 Perl/v5.10.1 Server at pengzao.com Port 80
解决方法很简单,打开cPanel面板“错误日志”页,一般会有2种错误:
第一种即“文件夹”给了太高权限,可被“组写入”:install is writeable by group
第二种即“文件”给了太高权限,可被“组写入”:index.php is writeable by group
只需要把“文件夹”和“文件”的“组写入”权限取消掉即可:
对“文件夹”去掉“组写入”权限,也就是从默认775改成755即可
对“文件”去掉“组写入”权限,也就是从默认664改成644即可
以install目录和index.php文件为例:
以上2个修改均可以通过ftp修改或者chmod命令完成
chmod 755 install
chmod 644 index.php
而如果有比较多的文件与文件夹需要更改权限,使用chmod分别设置子目录和文件不同权限:
先将当前目录中的所有“文件”包括文件夹设置为644:chmod 644 -R *
再将当前目录中的所有“子目录”的权限设置为755:chmod 755 `find -type d`
也可以用find命令实现:
find ./ -type f -exec chmod 644 {} \;
find ./ -type d -exec chmod 755 {} \;
发表评论