Need to reset the file permission in plesk - php

I use the plesk panel to upload and download the files from the server , currently the httpdocs folder permission is being set to rwx r-x --- and when i try to access the folder then it does not allows me to access the folder from the FTP as well as from the plesk.
From the plesk though i get an error following error:
Unable to change directory to /httpdocs: filemng: opendir failed: Permission denied
System error 13: Permission denied
i need to change the folder permission for the httpdocs so that i can access the files in it.
i have tried to refer the KB parallel http://kb.sp.parallels.com/en/1528
but was confused in the sense that how could i change the permission. i am using windows PC , please guide me on this , thanks a lot.

I had the same problem, after i tried to install Magento from the Plesk application manager. I searched and got this link http://kb.odin.com/en/124519and did it exactly as the article instructed. domain.tld - it means the particular domain name with its extension, such as .com, .org, .net. Everything worked, in ftp and file manager i was able to access the files and folders.
Resolution
Run the commands below with superuser privileges to download the archived shell script.
Unzip it and execute, providing the needed domain name as an argument:
~# wget http://kb.sp.parallels.com/Attachments/23464/Attachments/recover_plesk_directories.zip
~# unzip recover_plesk_directories.zip
~# sh recover_plesk_directories.sh domain.tld
domain.tld = yourdomainname.com/org/net... whatever, i hope i had been more clear....
For each domain you shall run the command 'sh recover_plesk_directories.sh domain.tld' separately.

Login on server as root via ssh connection and restore default permissions for virtual host directories with help of following command:
/usr/local/psa/bin/repair --restore-vhosts-permissions

Related

PHP can't create file, permission denied

I am trying to run some PHP applications on CentOS powered server with apache and MySQL. My apps have to create files on server, but it always says that permission is denied to create a file.
Files are located in /var/www/html. I even tried setting 777 permission to html folder and html/*. I changed apache user and group to myuser, that exists, and restarted apache. I changed the ownership of html folder and all files inside to myuser. I even tried changing document root to /home/myuser/public_html
I tried this code to test write permission. File location is /var/www/html/index.php and /home/myuser/public_html/index.php
$handle = fopen("a.txt", "w");
fwrite($handle, "test");
fclose($handle);
I am just more than amazed by this problem. The same configuration works on my another Ubuntu server.
Some geniuses must be here, help me.
You need to allow you server user to do write operation on your directory, User the below command, If it is a multilevel directory use -R flag.
sudo chown www-data my-dir
Instead of manually giving permission you can try chmod($handle, 0777) within your code.

Curlftpfs mount can't reach files via apache webserver

I have mounted a directory via curlftpfs. I am trying to access the files from within this mount via a webserver.
The path to the mounted directory is
'/home/domain.nl/domains/cms.domain.nl/public_html/project/1/syslink/'
The strange thing is that PHP can read and write from/to that directory. But when i try to access the folder from my apache webserver, then i get the error:
403 Forbidden
You don't have permission to access /project/1/syslink/file.jpg on
this server.
The output when I run exec('whoami') in php is:
urre
That is also the user that created the curlftpfs mount, so the rights are not the issue.
When I log in to the linux CLI with this user, I can access the mounted directory...
Apache Webserver requires the user "www-data" to be able to read and write to a folder / document.
You must change, either your FTP mount user to "www-data" or change your Apache running user.
In /etc/fstab
curlftpfs#user:pass#domain/directory fuse auto,user,uid=www-data,allow_other,_netdev 0 0
If you would like to set the group as well, you can add "gid=www-data" to fstab
This should allow Apache to read and write to your mounted FTP directory.

Permission Denied cPanel or PHP file upload

I am trying to upload a file through cpanel or wordpress admin panel, but cpanel shows permission denied and wordpress requires ftp access (probably for the same reason). What may be the cause of this?
The public_html directory contains files that were copied from public folder of another server via rsync to /home/somename and then I ran cp command to move these files to public_html. And now, all this is happening. Before cp, there was previous version of website that was working fine.
I'm using Centos 6.3 with Apache
Likely ownership issues.
For Centos 6 the default group for Apache is apache
Go to your webroot, and set the permissions to chown -R apache:apache *
Then make sure to set the permissions 0755
You may be better served by creating a new group and adding both yourself and apache to it. Then assigning the permissions to apache:<your new group>

How to enable writing to sshfs directory in PHP

I have in my home directory a SSHFS directory mounted to a remote directory on other server. I currently run PHP under my username (not root). The problem is, I cannot verify if a folder exists on the remote machine or even write a file.
When I try this over console it works, I mounted the directory with the same user and chowned by the same user. When I try to copy a file from script or check if a directory exists it does not work.
When I'm trying it over putty and logged in as the same user, nginx and php runs it works?
solved it
i had to add -o allow_other to the mount point in case someone is facing the same problem

Configuration issue with apache over ftp

I have two folders where I can store my website (CentOS VPS):
/var/www/html/index.html
/home/admin/public_html/index.html
I can either store my web application in the first path, but I don't have FTP access to this folder. I can't see it at all when accessing my FTP with the admin account that I received from my service provider.
Or I can use the /home/admin/public_html. For this, I tried to:
change the Root directory in the httpd.conf file;
restart apache;
But this totally does not work!!
It continues to redirect me to the Apache is functioning normally message (from the /var/www/html/ path. why is this happening ?
Even if there is no direct solution, please help me into a direction to get this issue solved so I can continue with my actual work.
At work, I'm using Putty to connect through SSH, at home I use the Mac OSX terminal to access the VPS.
EDIT:
I called my service provider and he mentioned that it's better to leave the default folder (which is var/www/html).
In order to access the file from the client :
I created a link to /var/www from the public_html folder;
Gave permission rights to the www folder recursively;
Connected through SFTP instead of FTP to get access to the folder (normal FTP won't display the folder).
This appears to work rather well.
I suspect Apache doesn't have permission to access /home/admin/public_html. You would need at a minimum to give group read access to /home/admin and /home/admin/public_html to whatever group apache processes run as. Usually it's apache, httpd, or www group--check your /etc/passwd file).
If it's say, the 'apache' group:
chown :apache /home/admin/admin;
chmod g-w /home/admin/admin;
chown -R :apache /home/admin/public_html
If apache must write this directory
chown -R g+w /home/admin/public_html
Then set the group sticky bit (SGID bit) so on any directory from /home/admin/public_html on down (only directories). This will ensure any file created in them will have the same group ownership as the directory. Here's how you do that
find /home/admin/public_html -type d -print | while read i; do SAVEIFS=$IFS; IFS=$(echo -en "\n\b");chmod g+s $i; IFS=$SAVEIFS; done
In case someone else has this issue, have a look at /etc/apache2/sites-enabled
This is where Apache keeps all virtual hosts (This is used to host more than one website on a single ip address.) If you see a 000-default file here, this is usually mapped as the default entry or the site you get when you type in the servers ip address and usually points to /var/www.
PS
Have a look at http://www.virtualmin.com/ It's a opensource cpanel alternative that will provide you with a easy to use web based GUI for common web server related tasks including security, mail, databases and antivirus.
could be selinux related? Look for permission denied in your apache log and have a look in the selinux logs -- /var/log/secure on centos by my memory

Categories