We are using Drupal8.7.5 headless, continuously we are getting such warning.
So my Question was do we need twig cache enabled.
How to solve the warning appearing in logs.
Those kind of messages are a folder permission problem at the most of time. And may be it's the case of your Drupal installation.
So I invite to verify the owner of "files" directory:
chown -R :www-data files
Then setting the proper permission on the Files directory:
chmod g+ws files
Fixing the permissions of pre-existing files in the Files directory:
cd files && find . -type d -exec chmod g+ws {} \ && find . -type f -exec chmod 664 {} \;
As recommended by Chris Toler.
And be careful because may be you are using a Dockerfile that force Nginx to use another user then www-data or may be you are using a shared volume for "files" directory as a cloud webapp. In that case you need to verify permissions on volumes at the host machine or using the Cloud UI to find the right permissions for your volumes. For further reading you can take a look at this Drupal topic.
I want to install WordPress. Sounds easy, but unexpected errors occurs.
The install page loaded with only html content (no style ). when you click next, a
"Forbidden You don't have permission to access this resource."
All requested file permissions and .htaccess are verified.
The server have let's encrypt SSL and HTTP/2 enabled.
Any Idea
I never had any problems installing Wordpress on a http2 server.
If you are on a linux server with shell-access: navigate in your wordpress directory and try this in the SSH console to set the permissions right:
chown USER:GROUP -R *
chown all files & directories (recursive) to the Webservers USER & GROUP. Replace USER & GROUP with the CORRECT (!) values depending on your hosting. Something like www-data:www-data for example).
You can find the right USER & GROUP if you check another directory or file that is automatically created by the hosting (error docs or the httpdocs folder - depends on your hosting)
Then:
find . -type d -exec chmod 755 {} \;
(set all subdirectories to 755)
find . -type f -exec chmod 644 {} \;
(set all files to to 644)
Regards Tom
I moved several WordPress install from a server that is running Plesk to one that is running WHM/cPanel. After the move I am unable to access the site. I get:
Forbidden
You don't have permission to access / on this server.
I also get:
403 Forbidden error was encountered while trying to use an ErrorDocument to handle the request.
I have checked all the permissions and owners but everything seems to be fine but still nothing is working. I am not sure what to do now.
My process for transferring the site was to tar httpdocs using ssh to connect to the Plesk server then I replaced the public_html directory with the contents of the httpdocs.tar.gz on the cPanel server.
What did I do wrong?
The group needed to be changed on the public_html file to "nobody". The group was still set as the set group in Plesk.
chown owner:group folder
The files might have too much rights or too less or they are owned by the wrong user. Please check which user is supposed to own them and run the following comments:
sudo find /var/www/ -type f -exec chmod 644 {} \;
sudo find /var/www/ -type d -exec chmod 755 {} \;
sudo chown webuser:webuser -R /var/www/
Replace webuser with the right user and /var/www/ with the right directory.
How can you copy a folder to /var/www without sudo?
My folder codes has the following permissions at /var/www
4 drwxr-xr-x 8 root root 4096 2009-08-09 03:01 codes
I can only sudo cp -r ~/Dropbox/codes/ /var/www to copy the files.
I cannot copy them without sudo.
Owning /var/www yourself might conflict with other options on your system. On my Debian system I would do this
sudo addgroup www
sudo adduser nr www # add myself to the www group
sudo chgrp -R www /var/www # make files in the group
find /var/www -type f -exec chmod g+w '{}' ';' # make each file group writable
find /var/www -type d -exec chmod g+ws '{}' ';' # make each directory group writable and sticky
If the directory is group writable and sticky, all files created in /var/www will be writable by anyone in the www group, no matter who or what creates them there. (Caveat: they have to be created by "normal" means; cp -a can circumvent the group sticky bit.)
Because Unix is insanely stupid about group membership, for your membership to be honored you will have to log in again, e.g., ssh localhost or log out and log back in. A nuisance.
What about adding the cron job to the root user. It's not a great idea, but it will get around the problem?
I also find it interesting that your www directory would have only root permissions and be owned by root. Usually they are owned by an apache user or have other permissions such that apache can access them.
Edit You probably don't want to edit the crontab file directy. But something similar to the following command should work:
sudo crontab -e -u root
You may not need the -u root but it's good so sudo doesn't confuse crontab.
Edit 2 You can change permissions with the chmod and chown commands:
sudo chmod 755 /path
sudo chown user:user /path
Be very very careful when using this. You can completely screw up the OS by changing permissions on the wrong files or folders. You'll probably want to add the -R option which will apply the permissions or owner recursively, but again, be very careful.
sudo chown yourusername /var/www
And you'll become the new owner of /var/www.
I am a newbie in php, mysql. I have written a hello.php script, which I am trying to copy into /var/www directory (and will later want to open it through web browser). The problem with the same is that I am not allowed to save/write any files in /var/www despite me being the root. I tried implementing steps in this question, but I get the following error when I process the third line
find /var/www/ -type f -exec chmod g+w '{}' ';'
chmod: changing permissions of `/var/www/index.html': Operation not permitted
I know symlink is also an option. I would want to be able to write/copy files directly to /var/www/ directory.
Any suggestions on what is going wrong?
it'matter of *unix permissions, gain root acces, for example by typing
sudo su
[then type your password]
and try to do what you have to do
Do you have a file in /var/www called hello.php already that has permissions on it? Maybe the system can't replace the file?
Although, root access should supersede any user on the system.
Have you tried applying permissions to the www folder?
If you can do this, try the following:
sudo chmod -R 777 /var/www
then do:
sudo cp hello.php /var/www
I only recommend doing this if you know 100% that it is ok to set permissions on the whole www folder. By the sounds of it, you are running on your own production server as most live/shared hosting servers are setup so that the www folder is not in the /var folder (instead it is in the home folder of the user).
Be VERY careful when doing anything with the sudo prefix though, you can seriously damage your system if you do it wrong.
Are you in a development environment ? If Yes, You can do
chown -R user:group /var/www
so you will be able to write with your user.
Execute the following command
sudo setfacl -R -m u:<user_name>:rwx /var/www
It will change the permissions of html directory so that you can upload, download and delete the files or directories
Encountered a similar problem today. Did not see my fix listed here, so I thought I'd share.
Root could not erase a file.
I did my research. Turns out there's something called an immutable bit.
# lsattr /path/file
----i-------- /path/file
#
This bit being configured prevents even root from modifying/removing it.
To remove this I did:
# chattr -i /path/file
After that I could rm the file.
In reverse, it's a neat trick to know if you have something you want to keep from being gone.
:)
sudo chown -R $USER:$USER /var/www
First off, this has nothing to do with php. This is a unix permission issue. You need to login as a superuser ( sudo/su ) and type your password, then try that command.
$ su
(type password )
\# your command
$ sudo command
$ (type password)
It might also help if you actually specified the operating system you use.
sudo cp hello.php /var/www/
What output do you get?
If none of the above works, you might be dealing with a vfat filesystem. Use "df" to check.
See http://www.charlesmerriam.com/blog/2009/12/operation-not-permitted-and-the-fat-32-system/ for more details.
First of all, you need to login as root and than go to /etc directory and execute some commands which are given below.
[root#localhost~]# cd /etc
[root#localhost /etc]# vi sudoers
and enter this line at the end
kundan ALL=NOPASSWD: ALL
where kundan is the username and than save it. and then try to transfer the file and add sudo as a prefix to the command you want to execute:
sudo cp hello.txt /home/rahul/program/
where rahul is the second user in the same server.
You just have to write sudo instead of su.
Then just copy the PHP file to the var/www/ directory.
Then go to the browser, and write local host/test.php or whatever the .php filename is.
Enter the following command in the directory you want to modify the right:
for example the directory: /var/www/html
sudo setfacl -m g:username:rwx . #-> for file
sudo setfacl -d -m g:username: rwx . #-> for directory
This will solve the problem.
Replace username with your username.
The problem is a privilege issue navigate to the var/www/
right-click in it and select open as admin
then continue your work