将新文件上传到服务器时出现 500 内部错误

发布于 2024-10-21 17:21:30 字数 372 浏览 4 评论 0原文

我刚刚切换到新的服务器主机(VPS)并将所有文件转移过来。我注意到没有任何效果,一切都抛出 500 内部错误。

然后我通过命令行运行它,它工作得很好,

 for i in `cat /etc/trueuserdomains | awk '{print $2}'`; do chown $i.$i /home/$i/public_html -R; chown $i.nobody /home/$i/public_html; done

我不太确定它的作用,但我认为它改变了脚本的所有者。无论如何,我注意到在过去的一周里,每当我上传服务器上尚未存在的新脚本时,它都会给我同样的 500 错误,并且我必须再次运行该脚本。有什么办法可以阻止这种情况发生吗?

I just switched to a new server host (VPS) and I transferred all my files over. I noticed that nothing was working everything was throwing a 500 internal error.

I then ran this via command line and it worked fine

 for i in `cat /etc/trueuserdomains | awk '{print $2}'`; do chown $i.$i /home/$i/public_html -R; chown $i.nobody /home/$i/public_html; done

I'm not really sure what it does, but I think it changes the owner of the script. Anyways I've noticed over the past week anytime I upload a new script that wasn't already on the server it gives me the same 500 error and I have to run that script again. Is there somehow I can prevent this from happening?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

你不是我要的菜∠ 2024-10-28 17:21:30
for i in `cat /etc/trueuserdomains | awk '{print $2}'`; 
do 
  chown $i.$i /home/$i/public_html -R; 
  chown $i.nobody /home/$i/public_html; 
done

通过分解上述代码进行描述

cat /etc/trueuserdomains | awk '{print $2}'

这将打印出由文件 /etc/trueuserdomains 的第二列中的每个单词组成的用户列表(该文件中可能只有一行,其中第二个单词包含文件所属的用户)

如果您想确切地查看该列表的内容,请从命令行运行以下命令。

cat /etc/trueuserdomains | awk '{print $2}'

然后,for i 部分执行两个 chown 命令,将 $i 替换为从 cat /etc/trueuserdomains | 收集的单词。 awk '{print $2}' 命令。

第一个 chown 命令将每个文件和目录的所有者和组更改为在 cat /etc/trueuserdomains | 中找到的内容。 awk '{print $2}' 命令。

然后,第二个 chown 命令将 public_html 上的组设置为 nobody,该组可能在主机上没有分配给它的用户帐户。

因此,这对您的网络服务器文件中的权限进行了排序,但正如您所说,并不能完全描述问题的根本原因。

要解决根本问题,请告诉我们以下信息。

如何将文件上传到服务器?该工具的名称是什么?当您上传文件时,您能否提供在运行上述命令之前他们拥有的所有者和组权限的示例?

for i in `cat /etc/trueuserdomains | awk '{print $2}'`; 
do 
  chown $i.$i /home/$i/public_html -R; 
  chown $i.nobody /home/$i/public_html; 
done

Description by breaking down the above code

cat /etc/trueuserdomains | awk '{print $2}'

This prints out a list of users made up of each word to be found in the second column of the file /etc/trueuserdomains (there is likely only one line in this file and the second word of which contains the user that the files should be owned by)

If you want to see exactly what that list is then run the following from the command line.

cat /etc/trueuserdomains | awk '{print $2}'

Then the for i part executes the two chown commands replacing the $i with the word gathered from the cat /etc/trueuserdomains | awk '{print $2}' command.

The first chown command changes the owner and group of every file and directory to be that which is found in the cat /etc/trueuserdomains | awk '{print $2}' command.

The second chown command then sets group on the public_html to be nobody, a group that likely has no user account assigned to it on the host machine.

So that sorts out the permissions in your web server files but, like you say, does not quite describe the root cause of your problem.

To fix the underlying problem let us know the following.

How do you upload files to the server? What is the name of the tool? When you upload the files can you give a sample of the owner and group permissions that they have prior to running the above command?

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文