access denied for image file server in nginix - nginx

I am using prestashop on nginx provided by plesk . two image on inner folders have the same permission but one of them is available from browse the other is not !!
I've already gave them both 777 permission and their parent folder have the same permission either.
How I can access them from Browser?
Edit:
the physical address of Images Are like that : /var/www/vhosts/site.com/httpdocs/modules/slider/img/view/slides/1.jpg
and the URI that i'm using is site.com/modules/slider/img/view/slides/1.jpg
and the error_log is Permission denied: access to /modules/slider/views/img/slides/1.jpg denied

Most servers will not work with permissions on 777 because too many permissions are very risky, most servers work perfectly with permissions in...
Folders: 0755
Files: 0644
We have a publication about how to configure the correct permissions: https://www.rolige.com/en/blog/how-to-assign-the-correct-permissions-to-my-prestashop-files-and-folders-n7

Related

Nginx can't serve static content and return 403(Forbidden) error page

I am new to nginx and trying to serve static contents with nginx and getting 403 error.I have server config like this:
server {
listen 8000;
server_name localhost;
root /Users/ismayilmalik/Documents/github/nginx-express;
location / {
index index.html;
}
I have executed commands below:
chmod -R 755 /nginx-express
chmod -R 644 /nginx-express/*.*
And the folder has drwxr-xr-x rigt.What's wrong here?
Please go to your nginx error logs to get details.
Run this command to show last errors:
tail -20 /var/log/nginx/error.log
It's good to go through error logs located /var/log/nginx/***.error. I had problems similar to this once. The solution was the user nginx was running as.
If nginx is running as www then www will not have access to ismayilmalik folders unless you also grant access to /Users/ismayilmalik home folder, but that is not secure. The best solution would be to allow nginx to run as ismayilmalik if you want to access your home folder through nginx.
I solved it finally.Actually nginx had all permission to serve static content from:
/Users/ismayilmalik/Documents/github/nginx-express;
The reason was when started nginx could not create error.log file in it'sroot directory. After manually creating the file it worked fine. I am using macOs and to find logs folder executed the command below to find all enironment variables for nginx:
nginx -V
BTW before this I had changed nginx user to from nobody to admin in main config file like below.
user [username] [usergroup]
By default nginx master process runs under root and child process under nobody.

SSHFS , nginx and root permission issue

I have 2 servers
Server A and Server B
Server A compress image, and put into Server B(Running Nginx)
The file put into Server B is through SSHFS(mounted) in a folder, when I go to Server B , I see the permission of the file is "root:root"
When I try to read it via web, it give a 403 forbidden.
So I did chown -R nginx:nginx on the folder itself. However new file, are still generated as "root:root"
Server A run Apache2 , while Server B run Nginx.
How do I make sure that my file in Server B is readable by Nginx, I cannot keep on go in and do the ownership change.
Is there a way I can change my nginx.conf to be able read the "root" file in this folder at /disk1/img
OR what else can I do to resolve this.
Thanks!
I believe you're wanting to set the User and Group for SSHFS to www-data:www-data so that nginx owns it after the transfer.
Try this:
https://serverfault.com/questions/389161/how-to-set-up-sshfs-to-use-www-data

Access denied for 'root'#'localhost' but I'm not root

I developed a little management application with Symfony. It works a lot on local. I put it all on my webserver (called Planethoster), and I've got the following message when I try to login in my application using app.php:
SQLSTATE[HY000] [1045] Access denied for user 'root'#'localhost' (using password: NO)
But in my parameters.yml file, I have not put the root user, it's another standard user that can only SIUD. I believe that app.php does not load my parameters.yml or config.yml file.
The last but not the least, I can log in using app_dev.php. It works but not with app.php.
Verify your Database settings in app/config_prod.yml for production use.
clear your cache by php app/console cache:clear --env=prod

Wampserver root privileges error

By accident I deleted all root users in msql/wampsever and then i can't acces phpmyadmin !
I tried to launch mysql console and connect to root .. It works so i don't know what i should do !
phpMyadmin : "You don't have permission to access /phpmyadmin/ on this server."
Thanks
Possible duplicate: WAMP error: Forbidden You don't have permission to access /phpmyadmin/ on this server
Can you show us your /alias/phpmyadmin.conf file? It should have something along the lines of:
<Directory "c:/wamp/apps/phpmyadmin3.4.5/">
Options Indexes FollowSymLinks MultiViews
AllowOverride all
Order Deny,Allow
Deny from all
Allow from 127.0.0.1
</Directory>
See this post.
You can get your wamp back by following two steps:
Step 1: Set privileges to mysql
i. Open command prompt and navigate to mysql bin folder which is usually present in
"C:\wamp\bin\mysql\mysql5.1.36\bin"
Execute the below set of mysql commands with appropriate changes to set the new password
MYSQL -U root -P
UPDATE mysql.user SET Password=PASSWORD('YourNewPassword') WHERE User='root';
Step 2: Configure the above set privileges to phpadmin/wamp
i. Locate "config.inc" file in the wamp folder, typically it is present in
"C:\wamp\apps\phpmyadmin3.2.0.1"
ii. Open it up using standard text editor such as notepad etc.
iii. Edit the values of user/password to what you have setup in the previous step.
iv. Save the config.inc file and do not forget to restart all the services by rightclick wamp on the

Nginx - 502 bad gateway from changing user in nginx.conf

If I change the user parameter in nginx.conf from:
user www-data
to
user www www
www is a user and www is also a group (existing already)
it says 502 bad gateway
How would I successfully be able to run nginx as the www user.
Cheers
You will need to use the command
chown -R www:www "Document Root"
This will ensure that all of your web files are owned by that user and group meaning nginx can access them.
If yopu have any .php files in your document root you will also have to go to your php fpm config file and change the lines
listen.owner = www
listen.group = www
If you are running centos go to:
/etc/php.fpm.d
where you will find the www.conf file to find those settings.
Hope that helps.
You should also change user in /etc/php/7.0/fpm/pool.d/www.conf(Ubuntu 16.10) file
listen.owner = www
listen.group = www
This error appears when you change nginx process user without changing this params in php-fpm.
After that restart php-fpm process:
service php7.0-fpm restart (for php 7.0)
The error may be caused if your are passing the request to fastcgi(php), to do this nginx has to access the file /run/php/php7.4-fpm.sock (for php7.4), I checked the logs and found out that it was denied the permission to access this file.
I ran this command:
> sudo chown ubuntu /run/php/php7.4-fpm.sock
and then it worked correctly.

Resources