chown on mapped CIFS share not working [closed] - php

Closed. This question is off-topic. It is not currently accepting answers.
Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed 9 years ago.
Improve this question
I have mapped to a Windows share using cifs/samba on CentOS. Using this command:
sudo mount -t cifs -o username=Username //path/to/share /var/share
My PHP application now needs the ability to create directories and upload files to /var/share (which is now the mapped cifs share). All of the files there all belong to root:root. When I attempt to do a chown to change the files to apache:apache, there are no errors thrown by Linux, but when I do an ls -l, it still shows the owners to be root:root.
Is there a way to get around this so my app can write to the share?

The username in your mount command is the "Windows" username, with the authentication being managed by Samba. By default, the exported volume has everything owned by root. What you need to do is to specify the *NIX user and group names in your mount command. Here's what I do to mount my Mac on my Ubuntu box, using Apple's CIFS implementation:
sudo mount -t cifs //192.168.1.3/Shared /media/Shared -o username=mike,password=XXXX,uid=1000,gid=1000,nounix,sec=ntlmssp
You can use textual names instead of numbers for the uid and gid. the "nounix,sec=ntlmssp" is needed for compatibility with recent versions of the Mac OS X CIFS server.

Related

Is it safe to give ownership of files to "daemon"? [duplicate]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 2 years ago.
Improve this question
I am running apache2 in Ubuntu 14.04. I have been having trouble with permissions with FTP clients and CMS that use backend FTP. I never seem to be able to get the permissions right. Should www-data be the owner of /var/www/html and root as a user assigned to that group?
Some CMSes and Wordpress is especially bad about that because it's actually in the code to use the web user.
BTW you should never need to use root for ftp. www-data the default apache user on ubuntu should own your web files/directory to work properly with many cmses.
So this is what has worked before and what we did for clients with the same issue. chown the whole web root as www-data for both user and group.
So if your document root is /var/www/html, cd or change directory to /var/www and run this to change ownership on all files and directories.
chown -R www-data: html/
while still in the /var/www directory add write permissions to the group for files and directories by running this command.
find html -type f -exec chmod 664 {} + -o -type d -exec chmod 775 {} +
Finally add your FTP user to the www-data group.
usermod -a -G www-data username
Replace usename with your FTP client username
Now this setup should allow you to use manage files and still allow the CMS ftp backend to still function and write to the direc. Let me know how that works for you.
This command worked for me:
sudo chown $(whoami) your_folder_name

You don't have permission to access /folder/index.php on this server. Apache/2.2.22 (Ubuntu) Server at localhost Port 80 [closed]

Closed. This question is off-topic. It is not currently accepting answers.
Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed 9 years ago.
Improve this question
I am using ubuntu 12.04
When I am running my index file like"localhost/index.php" its working fine.
at the same time when I am running my script like "localhost/mypage/index.php" then it return a error called
You don't have permission to access /mypage/index.php on this server.
Apache/2.2.22 (Ubuntu) Server at localhost Port 80
Please help me to overcome the problem ../thanks
Assuming you have your files in /var/www and have installed the default stack that Ubuntu provides, the proper way is to add your user to the www-data group and then chown that folder. Open a terminal and type:
sudo useradd -g www-data myuser
sudo chown -R www-data /var/www/
Perhaps the web user doesn't have permission to access sub-directories? You can CHMOD/OWN to the user apache run's as?
Find out the user read this article: https://stackoverflow.com/questions/2509334/finding-out-what-user-apache-is-running-as
Using CHMOD:
sudo chmod -R /folder/path/
sudo chown -R _www_user:_www_group /folder/path

NFS drupal implementation [closed]

Closed. This question is off-topic. It is not currently accepting answers.
Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed 9 years ago.
Improve this question
I found out NFS is the best way for Multi Server setup in Drupal File sharing
Can someone tell me how this works.
I have two Servers with Drupal Files connected to a common db in third Server
I have one more Server for files how shall I link this too both Drupal Servers using NFS and how NFS works?
when a user uploads the file from first drupal server does it make a copy in Shared Server or makes a
symbolic(soft) link in both drupal servers and adds the file in shared server?
Can someone please tell me and pass me a link to implement NFS for my MultiServer Drupal Setup.
Let us assume Server-A (ip: a.a.a.a) is the server where you are going to save the files, Server-B(ip: b.b.b.b) and Server-C (ip: c.c.c.c) will have drupal. In Server-A you may be storing the files in /store folder. This is to be mounted to folder /mnt/store in Server-B and Server-c.
For this you need to install nfs-kernal-server in Server-A and nfs-common and portmap on all three servers. NFS relies upon Remote Procedure Call(RPC) and portmap service is required to map RPC requests to the correct services.
In Server-A do these configurations:
sudo apt-get install nfs-kernel-server portmap nfs-common
sudo mkdir -p /mnt/nfstest
sudo chmod 777 /mnt/nfstest
sudo mount --bind /store /mnt/nfstest
sudo vi /etc/default/nfs-kernel-server in this file set NEED_SVCGSSD=no
sudo vi /etc/default/nfs-common in this file set: NEED_IDMAPD=yes and NEED_GSSD=no
sudo vi /etc/idmapd.conf in this file under [Mapping] set Nobody-User = nobody and Nobody-Group = nogroup
sudo vi /etc/hosts.deny add this: portmap mountd nfsd statd lockd rquotad : ALL
sudo vi /etc/hosts.allow add this: portmap mountd nfsd statd lockd rquotad : b.b.b.b, c.c.c.c {ipaddresses}
sudo vi /etc/exports add this: /mnt/nfstest b.b.b.b(rw,sync,no_subtree_check,fsid=0) and /mnt/nfstest c.c.c.c(rw,sync,no_subtree_check,fsid=0)
sudo exportfs -ra
sudo /etc/init.d/portmap restart
sudo /etc/init.d/nfs-kernel-server restart
In Server-B and Server-C do this
sudo apt-get install portmap nfs-common
sudo vi /etc/hosts.deny SET: `portmap : ALL`
sudo vi /etc/hosts.allow SET: portmap : a.a.a.a {Server-A's ipaddress}
sudo vi /etc/default/nfs-common SET: NEED_IDMAPD=yes and NEED_GSSD=no
sudo vi /etc/idmapd.conf under [Mapping] add Nobody-User = nobody and Nobody-Group = nogroup
modprobe nfs
mkdir /mnt/store
sudo mount -t nfs4 a.a.a.a:/ /mnt/store

Trying to run php file using "heroku run" and I get "bash permission denied" [closed]

Closed. This question is off-topic. It is not currently accepting answers.
Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed 10 years ago.
Improve this question
I'm trying to run a file with heroku run path/to/file.php and I get a reponse:
bash: path/to/file.php: Permission denied
I've tried chmod 755 on the file and directory, but it seems that heroku changes it back to 600... After running chmod 755 it shows 755, but then when I exit bash and then come back the permissions are reset to 600.
What am I missing?
Also some people have suggested
heroku run php path/to/file.php
but I get an error saying
bash: php: command not found
There are a couple of things you need to do.
When creating the Heroku application, you have to make sure that the PHP buildpack is used. This is what will inject the PHP runtime into your application slug. Either add a index.php file (which is how PHP is detected) or hard-code it like this: heroku config:add BUILDPACK_URL=https://github.com/heroku/heroku-buildpack-php.git
Set the library path as detailed in this question: heroku config:add LD_LIBRARY_PATH=/app/php/ext:/app/apache/lib
Run your stuff: heroku run ./php/bin/php --version
To sum up:
heroku config:add BUILDPACK_URL=https://github.com/heroku/heroku-buildpack-php.git
heroku config:add LD_LIBRARY_PATH=/app/php/ext:/app/apache/lib
heroku run ./php/bin/php --version
A useful way to debug this is to bash into the running Heroku dyno: heroku run bash. That will let you poke around, see where things are at and experiment.
Have you tried running the command with sudo privileges:
sudo heroku run path/to/file.php
If your shell can't use the php command (i.e. its alias), you will need to provide the absolute path:
sudo /usr/bin/php path/to/file.php
That's where it's usually located. To find your PHP bin location, try:
whereis php

Mac OSX Apache Write Privileges [closed]

Closed. This question is off-topic. It is not currently accepting answers.
Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed 11 years ago.
Improve this question
So here is my problem. Its started when I discovered that I couldn't install plugins or themes in WordPress from the admin panel, it just kept asking for my connection info ( http://cl.ly/DLdH/o ).
I found a blog post which suggested changing the ownership of the wordpress folder to the Apache user, i.e. _www like so
sudo chown -R _www ./
That did, partially, fix the problem as I was able to install plugins and themes as well as writing to the directory through PHP which was all good but then I couldn't add/delete/edit any of the files in my text editor or even in Finder. It just keeps asking for my user password in order to process the action.
Changing the ownership back fixes the password issue but then I cant do any writing to the directory though PHP anymore.
Is there a way to allow me do both things at the same time?
EDIT:
I came across this cmd
sudo dscl . -append /Groups/_www GroupMembership [myUsername]
which added me i.e. my username to the group _www, then I executed
sudo chown -R _www .
sudo chgrp -R _www .
then it worked!
Have the user own the files. Change the group to _www. Give write permission to group.
chown -R <username> .
chgrp -R _www .
chmod -R g+w .

Categories