Author Topic: creating new files causes 500 error  (Read 14288 times)

0 Members and 1 Guest are viewing this topic.

creating new files causes 500 error
« on: August 12, 2017, 10:12:02 PM »
Every time I create a file through WinSCP, the new file returns a 500 error. Only after running "Fix permissions" for that user, does it get fixed.

How can I make sure that I don't have to run "fix permissions" every time I create a new file?

Offline
***
Re: creating new files causes 500 error
« Reply #1 on: August 20, 2017, 04:35:31 AM »
With what user you are logging through WinSCP? If you are logging in with root and creating files in /home/john/public_html/ you will always get the 500 error and you will always need to "Fix Permissions".
UNIX is a very simple OS, but you have to be a GENIUS to understand it ...

Offline
*
Re: creating new files causes 500 error
« Reply #2 on: August 21, 2017, 01:14:02 PM »
if you want to have correct permissions than its recommended to upload files by using FTP and user credentials.
VPS & Dedicated server provider with included FREE Managed support for CWP.
http://www.studio4host.com/

*** Don't allow that your server or website is down, choose hosting provider with included expert managed support for your CWP.

Re: creating new files causes 500 error
« Reply #3 on: August 25, 2017, 02:23:38 AM »
I'm uploading over WinSCH using my SSH login. Yes I'm logging in with the user for the website.

But each time I create a file, it causes a 500 error and I have to reset the permissions.

Is there a configuration issue in apache somewhere that has to be changed?

Offline
*
Re: creating new files causes 500 error
« Reply #4 on: August 25, 2017, 09:08:03 PM »
are you using the username of the account owner for ssh connection ?

if you are using the account owner account for ssh then the only issue you still can have with the permissions is that the files have incorrect permissions.

please note that suphp requires permissions 755 for folders and 644 for files, having anything higher then this numbers will be invalid and rejected by suphp security.
VPS & Dedicated server provider with included FREE Managed support for CWP.
http://www.studio4host.com/

*** Don't allow that your server or website is down, choose hosting provider with included expert managed support for your CWP.

Re: creating new files causes 500 error
« Reply #5 on: August 25, 2017, 09:27:07 PM »
thanks for the reply

I haven't done anything to the apache config, I'm using nginx + apache setup

What would I need to change in apache to ensure it doesn't keep happening?

yes, I'm logging in through SSH/WinSCP using the user/pass for the user the website is added to

Offline
*
Re: creating new files causes 500 error
« Reply #6 on: August 25, 2017, 09:34:41 PM »
the best would be that you upload some file and then show stat from it, shell command:
Code: [Select]
stat FILENAME
and some output from the error_log file after opening the file in the browser
Code: [Select]
tail /usr/local/apache/logs/error_log
VPS & Dedicated server provider with included FREE Managed support for CWP.
http://www.studio4host.com/

*** Don't allow that your server or website is down, choose hosting provider with included expert managed support for your CWP.

Re: creating new files causes 500 error
« Reply #7 on: August 25, 2017, 09:36:54 PM »
[root@vps public_html]# stat NEWFILE.php
  File: ‘NEWFILE.php’
  Size: 1               Blocks: 8          IO Block: 4096   regular file
Device: 800h/2048d      Inode: 257910      Links: 1
Access: (0664/-rw-rw-r--)  Uid: ( 1000/jonathan1)   Gid: ( 1000/jonathan1)
Access: 2017-08-25 14:35:20.000000000 -0700
Modify: 2017-08-25 14:35:20.000000000 -0700
Change: 2017-08-25 14:35:21.639088638 -0700
 Birth: -


AND

[Fri Aug 25 14:36:17.383950 2017] [:error] [pid 19070:tid 140564649391872] [client 23.240.188.50:51922] SoftException in Application.cpp:249: File "/home/jonathan1/public_html/NEWFILE.php" is writeable by group
[Fri Aug 25 14:36:17.383998 2017] [core:error] [pid 19070:tid 140564649391872] [client 23.240.188.50:51922] End of script output before headers: NEWFILE.php
« Last Edit: August 25, 2017, 09:40:22 PM by jonathan1 »

Re: creating new files causes 500 error
« Reply #8 on: August 25, 2017, 09:44:46 PM »
I want to make sure I can fix this as an Apache level so when I create new users, this issue doesn't come up again. Thanks for all your help! I'll be subscribing to the upgrade soon, awesome work on this product

Offline
*
Re: creating new files causes 500 error
« Reply #9 on: August 25, 2017, 10:50:23 PM »
this is an umask issue causing the files to have group writeable permissions, edit file "/etc/ssh/sshd_config"

find this line:
Code: [Select]
Subsystem       sftp    /usr/libexec/openssh/sftp-serverChanged it to
Code: [Select]
Subsystem       sftp    /usr/libexec/openssh/sftp-server -u 022
now restart ssh and try to login and upload files again
Code: [Select]
service sshd restart
to fix permissions for already uploaded files use this command
Code: [Select]
chmod g-w FILENAME



 
VPS & Dedicated server provider with included FREE Managed support for CWP.
http://www.studio4host.com/

*** Don't allow that your server or website is down, choose hosting provider with included expert managed support for your CWP.

Re: creating new files causes 500 error
« Reply #10 on: August 25, 2017, 10:58:04 PM »
Thanks for the instruction

I did that, I can't login via WinSCP anymore. getting this error

Cannot initialize SFTP protocol. Is the host running an SFTP server?

Offline
*
Re: creating new files causes 500 error
« Reply #11 on: August 25, 2017, 11:00:10 PM »
have you added only " -u 022" at the end of the line ?
VPS & Dedicated server provider with included FREE Managed support for CWP.
http://www.studio4host.com/

*** Don't allow that your server or website is down, choose hosting provider with included expert managed support for your CWP.

Re: creating new files causes 500 error
« Reply #12 on: August 25, 2017, 11:00:49 PM »
yes, is there a typo in the spacing? I copied exactly from your response.

https://www.screencast.com/t/Eo9fkC3eK

Offline
*
Re: creating new files causes 500 error
« Reply #13 on: August 25, 2017, 11:02:07 PM »
this is how it needs to look
Code: [Select]
Subsystem       sftp    /usr/libexec/openssh/sftp-server -u 022
VPS & Dedicated server provider with included FREE Managed support for CWP.
http://www.studio4host.com/

*** Don't allow that your server or website is down, choose hosting provider with included expert managed support for your CWP.

Re: creating new files causes 500 error
« Reply #14 on: August 25, 2017, 11:03:19 PM »
That did it! I can create new files now.

thank you!!!