Nginx 403 permission denied, chown/chmod don't seem to work - nginx

I can't get my nginx working, I am getting permission denied.
Tried:
sudo chmod o+x /home
sudo chmod o+x /home/path-to-www
sudo chown -R nginx:nginx /home/path-to-www/www
sudo chmod -R 755 /home/path-to-www/www/
service nginx restart
The above did not work.
So I tried:
sudo chown -R path-to-www:path-to-www /home/path-to-www/www
plus:
setting the nginx user to path-to-www and retarting again.
This didn't work as well.
I am out of ideas. Anyone?

Solved: It was Selinux. I disabled it and rebooted and it worked.

Related

Cannot update plugin for WordPress on localhost on Mac

I'm running WordPress 5.8.1 on localhost, on my Mac. I am unable to update plugins. I get this error:
Update failed: Could not create directory.
I've tried changing the permission on the wp-content folder as suggested here like this:
sudo chmod -R 755 wp-content
but it didn't work. I still get the error message.
I also tried this
sudo chown -R _www wp-dir
sudo chmod -R g+w wp-dir
still no luck.
Ok, Managed to find the issue. Apache uses a different username so this command was ok:
sudo chown -R _www wp-dir
But my username wasn't _www (hence my error)
you can find the apache username in the etc/httpd.conf file

Laravel: mkdir(): Permission denied - Nginx

Trying to upload a file with opening new folder.
But laravel returns error like below.
$destinationPath = public_path() . $folderName;
if(!is_dir(public_path().'/uploads')) {
mkdir(public_path().'/uploads', 0755, true);
}
$mkdir = mkdir(public_path().'/uploads/'.$unique, 0755, true);
$success = file_put_contents(public_path().'/uploads/'.$unique."/".$filename, $file);
I used;
sudo chown -R nginx:nginx public/uploads
sudo chown -R root:root public/uploads
sudo chown -R $USER:$USER public/uploads
But nothing changed.
What's wrong?
Is laravel's nginx user different? How can I learn?
you should check the Nginx user inside your Nginx config file.it can be found at /etc/nginx/nginx.conf and likely set to user www-data;
Try running the command
sudo chown -R www-data:www-data public/uploads
This command should work. If now let me know.

Giving a default permission for cache folder

The problem is when I clear caches in my Symfony project on production environment, I should type this command for giving right permissions to cache folder:
cd app/cache
sudo chmod -R a+w *
But is there any way to not typing these commands each time?
try this
sudo setfacl -dR -m u::rwX app/cache

How to overcome "server refused our key"?

I am trying to setup putty for autologin using public key authentication (used puttygen). I have pasetd my private key in authorized_keys ,I have done all the required setups still I am getting "server refused our key".What could be the reason behind it and how to overcome this issue ?
Run these commands:
chmod 700 .ssh
chmod 600 .ssh/authorized_keys
chown $USER:$USER .ssh -R
cd /.ssh
If it doesnt exist create it in your home directory
mkdir .ssh
add your key with this command
echo "your_key" >> authorized_keys
run these commands where can't even get in
chmod 700 .ssh
chmod 600 .ssh/authorized_keys
chown $USER:$USER .ssh -R
$ sudo chown root:root /home
$ sudo chmod 755 /home
$ sudo chown ec2-user:ec2-user /home/ec2-user -R
$ sudo chmod 700 /home/ec2-user /home/ec2-user/.ssh
$ sudo chmod 600 /home/ec2-user/.ssh/authorized_keys

Permission problems in Symfony2 on Mac OSX using XAMPP

I am using XAMPP on Mac OSX. I followed the Symfony2 instructions to set app/cache and app/logs permission -
rm -rf app/cache/*
rm -rf app/logs/*
sudo chmod +a "_www allow delete,write,append,file_inherit,directory_inherit" app/cache app/logs
sudo chmod +a "`whoami` allow delete,write,append,file_inherit,directory_inherit"
Moreover, I also run the sudo chmod -R 777 app/cache/* and sudo chmod -R 777 app/logs/*
It worked as well. However, when I close the XAMPP and open it again. It always shows the following RuntimeException, and I have to set their permission again and again.
RuntimeException: Failed to write cache file "/Applications/XAMPP/xamppfiles/htdocs/Jobeet/app/cache/dev/classes.php".
I don't find anyone have the same problem as me.
How can I permanently set their permission?

Resources