creating new files causes 500 error

Started by jonathan1, August 12, 2017, 10:12:02 PM

Previous topic - Next topic

jonathan1

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?

darkness

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

studio4host

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.

jonathan1

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?

studio4host

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.

jonathan1

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

studio4host

the best would be that you upload some file and then show stat from it, shell command:
stat FILENAME

and some output from the error_log file after opening the file in the browser
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.

jonathan1

#7
[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

jonathan1

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

studio4host

this is an umask issue causing the files to have group writeable permissions, edit file "/etc/ssh/sshd_config"

find this line:
Subsystem       sftp    /usr/libexec/openssh/sftp-server
Changed it to
Subsystem       sftp    /usr/libexec/openssh/sftp-server -u 022

now restart ssh and try to login and upload files again
service sshd restart

to fix permissions for already uploaded files use this command
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.

jonathan1

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?

studio4host

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.

jonathan1

yes, is there a typo in the spacing? I copied exactly from your response.

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

studio4host

this is how it needs to look
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.

jonathan1

That did it! I can create new files now.

thank you!!!