简体   繁体   English

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

[英]500 internal error when uploading new files to server

I just switched to a new server host (VPS) and I transferred all my files over. 我刚刚切换到新的服务器主机(VPS),并转移了所有文件。 I noticed that nothing was working everything was throwing a 500 internal error. 我注意到什么也没做,一切都引发了500个内部错误。

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. 无论如何,在过去一周中,无论何时我上载服务器上都没有的新脚本,都会给我同样的500错误,并且我必须再次运行该脚本。 Is there somehow I can prevent this from happening? 有什么办法可以防止这种情况发生吗?

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) 这会打印出由每个单词组成的用户列表,该单词将在文件/ etc / trueuserdomains的第二列中找到(此文件中可能只有一行,而第二个单词包含该文件应由用户输入的用户拥有)

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 | 然后for i部分执行两个chown命令,将$ i替换为从cat / etc / trueuserdomains | awk '{print $2}' command. awk'{print $ 2}'命令。

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 | 第一个chown命令将每个文件和目录的所有者和组更改为cat / etc / trueuserdomains | awk '{print $2}' command. awk'{print $ 2}'命令。

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. 第二chown命令然后设置在的public_html组是nobody ,即可能具有分配给它的主机上没有用户帐户的基团。

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. 因此,可以对您的Web服务器文件中的权限进行分类,但是,就像您所说的那样,并不能完全描述问题的根本原因。

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? 当您上传文件时,可以在运行上述命令之前给它们所有者和组权限示例吗?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 将Laravel项目上载到服务器时出错500 - Error 500 when uploading Laravel project to server Laravel 500内部服务器错误? - 500 internal server error on laravel? 将图像或文件上传到生产环境中时,带单引号的文件名出现内部500错误 - Filenames with single quotes are giving internal 500 error while uploading images or files in to production 内部服务器错误500仅在通过ftp传输的文件上,而不在本地创建的文件上运行,运行ubuntu服务器16.04 - internal server error 500 only on files transferred over ftp not on locally created files, running ubuntu server 16.04 无法解释的PHP错误(内部服务器错误500) - Unexplained PHP error (Internal Server Error 500) 500内部服务器错误-register_globals - 500 Internal Server Error - register_globals VHost和htaccess-500内部服务器错误 - VHost & htaccess - 500 Internal Server error 我在 GITLAB 中推送时出错(RPC 失败;HTTP 500 curl 22 请求的 URL 返回错误:500 内部服务器错误) - Error when i push in GITLAB (RPC failed; HTTP 500 curl 22 The requested URL returned error: 500 Internal Server Error) 在LAMP CentOS VPS上克隆Git存储库时出现500内部服务器错误 - 500 Internal Server Error When Cloning Git Repo On LAMP CentOS VPS 错误:虚拟主机 ubuntu 16.04 中的“500 内部服务器错误” - Error: "500 internal server error" in virtualhost ubuntu 16.04
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM