简体   繁体   中英

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. 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?

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?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM