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
Related
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.
I am a Centos 7 machine on which I have configured PHP with Apache and Slim Framework.
The simple code to check if the file exists and copy the code into a directory is working fine on one of the machine but not working on another machine. Its really weird.
Actually I am accessing the API through Apache to trigger this function.
Functions like shell_exec alaways return 0
copy function is also not workingg
file_exists also not working.
Any help or clue why this is wrong or debug this issue.
Thanks all for the help.
Problem was file permission issue.
The reason was all of the above function I was performing was on the file. Since the files has different permission for different user.
So If I hit the URL from browser it was through "Apache" user which does not have execute permission on the folder to access the file and read permission on the file.
In short
sudo chmod +rx file
sudo chmod +x "All the directory structure"
I am using a php script from github to capture screenshot of a website. Its working fine in localhost. But not working after uploading the same code to my server (linux hosting). I tried uploading to multiple servers. None of them worked. No error codes are coming.
In the documentation, it says:
Make the bin executable chmod +x /var/www/html/screen/bin/phantomjs,
Make your folder writable
I am not sure what does that mean, so i set file permissions of whole files and folder to 777. Still not working
How did i upload to my server.
I uploaded the whole code to the server. Changed file permissions of all directories and files to 777 using FileZilla. I have attached a screenshot of
it.
I think it is still permissions issue, You need to set the proper permissions using putty.
1. Login using putty
2. Open root directory
3. Set permissions file and folder using this command
===> chmod -R 777 folder name
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
i have this problem with fopen files. Maybe someone has a solution...
When fopen creates a file via the browser, the file is owned by "nobody", if i run the same script via crontab i get permission denied.
When the file is created by crontab, its owned by my cpanel username and then i cant fopen it via the web browser.
So the problem is that each of the methods used is using a different user to own the files created. How can i go around this? I searched how to run crontab as nobody but you have to be root and it seems complicated. I didnt find anything about running my web pages as my cpanel user. My php script has chmod 777 and the folder where the files are also have 777 just be be sure.
Any ideas? Thanks.
I'm not a sysadmin guru, but if you have access to the server you can try this
Create a new group called "webwriters" and add nobody and yourself to that group
"chmod g+s webwriters" on the directory you write files
"chmod 660" each file so that the owner and the group have write privileges
If you don't have access to the server it's trickier, but solvable. Instead of running the script directly by cron, run the script on the web server itself by downloading the web page using "wget" or alternatively a php script calling "file_get_contents" on an URL. This assumes that the server is not locked down too tight...