Join the community today
Become a Member

PHP-FPM prestashop files created without apropiate permissions

Discussion in 'Install & Upgrades or Pre-Install Questions' started by dandumit, Feb 5, 2021.

  1. dandumit

    dandumit New Member

    19
    1
    3
    Jan 9, 2021
    Ratings:
    +1
    Local Time:
    12:54 AM
    hello all,
    I have managed to install cenmin and prestashop on top . Most of configuration was from :
    Does PrestaShop 1.7 work with Nginx?


    Now I have a problem, it's mostly of prestashop application but I am asking here as well because it's about file permissions :
    file that it's complaining that's missing is there but as absolutely no permission on it.
    I wonder how this could it be possible.
    if application runs under nginx user wouldn't should have been created with permissions for that user ?

    DAniel
     
  2. dandumit

    dandumit New Member

    19
    1
    3
    Jan 9, 2021
    Ratings:
    +1
    Local Time:
    12:54 AM
    Error is :
    Code:
    Warning: require_once(/home/nginx/domains/asd.ro/public/var/cache/dev/appParameters.php): failed to open stream: Permission denied in /home/nginx/domains/asd.ro/public/config/bootstrap.php on line 87
    
    Fatal error: require_once(): Failed opening required '/home/nginx/domains/asd.ro/public/var/cache/dev/appParameters.php' (include_path='/home/nginx/domains/asd.ro/public/vendor/pear/pear_exception:/home/nginx/domains/asd.ro/public/vendor/pear/console_getopt:/home/nginx/domains/asd.ro/public/vendor/pear/pear-core-minimal/src:/home/nginx/domains/asd.ro/public/vendor/pear/archive_tar:.:/usr/local/lib/php') in /home/nginx/domains/asd.ro/public/config/bootstrap.php on line 87
    
    
    file appParameters.php it's there but has no permission. I don't know how to investigate this ...



    I have tried

    chown nginx:nginx /home/nginx/domains/yourdomain.com/public/ chown -R nginx:nginx /home/nginx/domains/yourdomain.com/public/

    but after some time happened again. I guess that it's being rewritten that file. wuestion is why that process of cache that rewritten this does not gives appropiate permissions to that file ?
     
  3. eva2000

    eva2000 Administrator Staff Member

    53,229
    12,116
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +18,654
    Local Time:
    7:54 AM
    Nginx 1.27.x
    MariaDB 10.x/11.4+
    I'd double check the prestashop documentation as to permissions for directory
    /var/cache/ at /home/nginx/domains/asd.ro/public/var/cache

    probably needs to be writable i.e. chmod with 0666 or 0777 permissions
     
  4. dandumit

    dandumit New Member

    19
    1
    3
    Jan 9, 2021
    Ratings:
    +1
    Local Time:
    12:54 AM
    Thank you @eva2000 ! fact it's that those files on /cache folder are rewritten by application.

    Please tell me how could I check that php-fpm user is the same as Nginx?
    That file that it's complaining that not exists, it's there on disk but has no permission.

    How could I set / check umask settings for php-fpm - nginx user ?

    Thank you,
    DAniel
     
  5. eva2000

    eva2000 Administrator Staff Member

    53,229
    12,116
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +18,654
    Local Time:
    7:54 AM
    Nginx 1.27.x
    MariaDB 10.x/11.4+
    php-fpm runs as nginx user/group by default. It it wasn't you wouldn't be able to use php-fpm on Centmin Mod at all and all PHP scripts won't work.

    just list the file and it's permissions to check using list command (ls)
    Code (Text):
    ls -lah /home/nginx/domains/asd.ro/public/var/cache/dev/appParameters.php
    


    default is using 755/750 for directories and 644/640 for files and then you need to adjust them according to your web apps requirements

    use list command to for your files

    example wp-config.php file has 644 permissions owned by nginx user/group
    Code (Text):
    ls -lah /home/nginx/domains/wp5.domain.com/public/wp-config.php
    -rw-r--r-- 1 nginx nginx 2.7K Dec  2  2018 /home/nginx/domains/wp5.domain.com/public/wp-config.php
    

    and public directory has 750 with setuid/setguid (s) for /public
    Code (Text):
    ls -lah /home/nginx/domains/wp5.domain.com/
    total 32K
    drwxr-s---   8 nginx nginx 4.0K Dec  2  2018 .
    drwxr-s---. 18 nginx nginx 4.0K Dec 19 16:40 ..
    drwxr-s---   2 nginx nginx 4.0K Dec  2  2018 backup
    drwxr-s---   2 nginx nginx 4.0K Feb  7 03:07 log
    drwxr-s---   2 nginx nginx 4.0K Dec  2  2018 private
    drwxr-s---   5 nginx nginx 4.0K Feb  3  2020 public
    

    and public/wp-admin directory has 755 permissions with setuid/setguid (s)
    Code (Text):
    ls -lah /home/nginx/domains/wp5.domain.com/public/
    
    drwxr-sr-x  9 nginx nginx 4.0K Dec  2  2018 wp-admin
    


    You don't have to worry about setuid/setguid (s) as that is set by Centmin Mod at initial install to tell php-fpm or nginx triggered file/directory creation should be for nginx group. Only manually created files by root/non-nginx user would have different nginx group permissions and need chmod'ing to nginx user/group. Which is outlined in official Centmin Mod Getting Started Guide step 2 at Getting Started Guide - CentminMod.com LEMP Nginx web stack for CentOS

    Best you read, Understanding Linux File Permissions - Linux.com and How to change directory permissions in Linux