Install on RHEL 9 I've got drwxrwx---. 2 apache apache  with chown -R and chmod -R. I've tried 770,775,777 but the install always says it's not writeable.

sudo chmod -R 770 files sudo chown -R apache:apache files

I've confirmed 'apache' is my apache user and group

egrep -iw --color=auto '^user|^group' /etc/httpd/conf/httpd.conf

User apache Group apache

What am I missing?

Thanks for the time.

 

Comments

I'm not an expert by any means... but perhaps PHP is running as a different user? I've seen PHP using user "web-data". 

Try running <?php echo exec('whoami'); ?> or install Devel and do dpm(exec('whoami')); in admin/devel/php to find out the PHP user. 

One more thing - Installer uses the "temporary" directory (see admin/config/media/file-system where this is set with an absolute path). Are you sure *that* particular directory is writable?

Thanks for the quick replies, I forgot to mention I did the <?php echo exec('whoami'); ?> and it shows apache also.

I'm not following what or where you mean by the 'temporary' directory?

A temporary directory is a special directory in your server where php stores temporary files (for example, zipped files of modules). If you don't have access privileges to that temporary directory, then Installer won't be able to put that zip file and therefore won't work. In your site, if you visit admin/config/media/file-system you will see where that directory is for your site. It's possible you may need to (1) CREATE that folder, (2) set the correct path in admin/config/media/file-system

You say "in your site" my site isn't built, I can't get passed the installation because the "/files" isn't writeable according to the install page.

 

Oh, I get it. I thought you were referring to the Project Installer module, which is used to install new modules into an existing site. So, basically, you are getting this error when you run example.com/install.php?   

Yep. exactly. I can't get past the install script.

Are you getting a line number with the error? Can you post the full error here?

Its just in the install.php UI but I've checked, rechecked, restarted, rebooted, everything I can think of.  

File system

less

The directory ./files is not writable. To proceed with installation, you must modify the permissions of this directory to make it writable by the web server. If you are unsure how to do this, see the Installation Instructions page.

Have you specifically tried what the Installation Instructions page suggests? Pasting:

 

  • Set the permissions/ownership on the files directory

    The files directory in the Backdrop root must be writable by the webserver.

    If the user who logs into the server (either by ftp or ssh) is myuser and the webserver user is www-data then sensible ownership and permissions for the files directory could be:

    drwxrwx--- 13 myuser www-data 442B Nov 5 18:38 files

    You can achieve this configuration either in your FTP client or on the command line with commands like this:

    chown -R myuser:www-data files &amp;&amp; chmod -R 770 files

    Note: you may need sudo depending on the access of the user who owns the directory.

Specifically giving writing permission to www-data

I'm going to also ask for help in the Zulip channel, as there may be others with more experience than me.

indigoxela's picture

Can't help with RHEL, but got Backdrop working without flaws on AlmaLinux, which is really close.

To clarify: the Apache user in RHEL is actually "apache" (unlike Debian, where it's www-data). So that should have been right.

Question: how did you set up PHP? With mod_php (httpd runs the code) or with php-fpm (extra process runs the code)?

Did you set up a VirtualHost, or should your web be the default (only) one?

Sorry not sure on the php setup. I just followed https://www.tecmint.com/install-apache-mariadb-php-on-rhel-8/

I believe it would be httpd ("apache" user) runs the code, based on the whoamI code I put in a test index.php file and returns apache.

I didn't bother with a virtualhost, this is just a test vm and its setup only for backdrop.

 

indigoxela's picture

Next question: where did you put Backdrop (where did you unpack the zip file)?

Is it /var/www/html/? What's your current directory structure there?

And what is set as DocumentRoot in your /etc/httpd/conf/httpd.conf?

And the owner of /var/www/html/ and of directories below is?

DocumentRoot is /var/www/httml

Backdrop was moved to /var/www/html/backdrop

drwxr-xr-x. 3 apache apache 38 Jun 16 17:14 html

drwxr-xr-x. 8 apache apache 179 Jun 16 17:15 backdrop

drwxr-xr-x. 9 apache apache  4096 Jun 16 17:15 core drwxrwx---. 2 apache apache    40 Jun 16 17:15 files -rw-r--r--. 1 apache apache   578 Jun 16 17:15 index.php drwxr-xr-x. 2 apache apache    23 Jun 16 17:15 layouts -rw-r--r--. 1 apache apache 18092 Jun 16 17:15 LICENSE.txt drwxr-xr-x. 2 apache apache    23 Jun 16 17:15 modules -rw-r--r--. 1 apache apache  5285 Jun 16 17:15 README.md -rw-r--r--. 1 apache apache  1198 Jun 16 17:15 robots.txt -rwxrwx---. 1 apache apache 22165 Jun 16 17:15 settings.php drwxr-xr-x. 2 apache apache    40 Jun 16 17:15 sites drwxr-xr-x. 2 apache apache    23 Jun 16 17:15 themes

 

Thanks

indigoxela's picture

The permissions of the /files directory differ slightly, I see a 770, where normally it would be 755. Probably you did some experiments already, but did you try to chmod it to 755, yet?

As you reported, the install failed - did it fail immediately or in a later step? Currently the "files" directory's still empty, I guess. It's only supposed to contain a README.txt initially.

What's in the httpd logs, by the way?

Yeah tried everything even 777. Just chmod -R to 755 with no difference. Yeah the only thing in there is the readme.

"Install failed" I guess isn't accurate because the actual install never starts.  I go to the install.php page, Click Save and Continue for the default English then get to the "Verify Site Requirements" page where it's checking all the various items. Everything is fine except "/files". so I can't get past this step in the install.

httpd.logs don't show really anything. appears to be basic stuff in the error.log

These timestamps I think match with the reboot I did a shot time ago today  

[Thu Jun 22 10:55:00.945356 2023] [mpm_event:notice] [pid 1231:tid 1231] AH00492: caught SIGWINCH, shutting down gracefully

[Thu Jun 22 10:55:28.257999 2023] [core:notice] [pid 1365:tid 1365] SELinux policy enabled; httpd running as context system_u:system_r:httpd_t:s0

[Thu Jun 22 10:55:28.260644 2023] [suexec:notice] [pid 1365:tid 1365] AH01232: suEXEC mechanism enabled (wrapper: /usr/sbin/suexec)

AH00558: httpd: Could not reliably determine the server's fully qualified domain name, using 192.168.60.10. Set the 'ServerName' directive globally to suppress this message

[Thu Jun 22 10:55:28.369601 2023] [lbmethod_heartbeat:notice] [pid 1365:tid 1365] AH02282: No slotmem from mod_heartmonitor

[Thu Jun 22 10:55:28.379288 2023] [mpm_event:notice] [pid 1365:tid 1365] AH00489: Apache/2.4.53 (Red Hat Enterprise Linux) configured -- resuming normal operations

[Thu Jun 22 10:55:28.379334 2023] [core:notice] [pid 1365:tid 1365] AH00094: Command line: '/usr/sbin/httpd -D FOREGROUND'

Thanks

indigoxela's picture

suEXEC mechanism enabled...

Strange, why that?

Let's have a closer look at your PHP setup.

Temporarily put a file in the root dir of your install (backdrop):

<?php
var_dump(is_writable('./files'));
?>

And then run that from your browser via http://localhost/backdrop/test.php (Assuming it is localhost, put in the domain/IP otherwise.)

It returns "false", right?

Let's have a closer look.

Put that code in instead:

<?php
phpinfo();
?>

Let's check the "Server API".

And when we're at it, let's also check httpd modules via command line:

apachectl -M

Correct that came back false

server API shows FPM/FastCGI 

$apachectl -M

apachectl: The "-M" option is not supported.

Thanks

indigoxela's picture

apachectl: The "-M" option is not supported.

Strange, try apachectl -t -D DUMP_MODULES instead.

So you have php-fpm and don't need suexec at all (wonder, why it's installed).

But back to permissions: check /etc/php-fpm.d/www.conf (if it exists). Search for user, group. Verify it's also "apache".

If that doesn't solve it, let's go to the juicy part:

SELinux - it's probably enabled. As you already stated, the setup is just for testing - turn it off. Probably in /etc/selinux/config and probably you have to reboot.

Getting this message:

Passing arguments to httpd using apachectl is no longer supported.

You can only start/stop/restart httpd using this script.

To pass extra arguments to httpd, see the httpd.service(8)

man page.

 

; RPM: apache user chosen to provide access to the same directories as httpd

user = apache

; RPM: Keep a group allowed to write in log dir.

group = apache

Try this, run from /var/www/html/backdrop as root/sudo:

#!/bin/bash
find . -type f -exec chmod 664 '{}' \;
find . -type d -exec chmod 775 '{}' \;
chown apache:apache .* -R
chown apache:apache * -R
chmod +x permfix.sh

I use this as a script called permfix.sh (hence the last line), which you can create with:

nano permfix.sh  

then copy the above, paste with CTRL+SHIFT+V, Ctrl+x, yes then chmod +x permfix.sh

then ./permfix.sh

 

sudo find . -type f -exec chmod 664 '{}' \; 

sudo find . -type d -exec chmod 775 '{}' \;

-no output.  Used sudo because without it I get a crap-ton of 'operation not permitted"  

Ran the 2 chown commands also with sudo Updated ls -l below. install.php still complains files isn't writeable  

drwxrwxr-x. 9 apache apache  4096 Jun 16 17:15 core

drwxrwxr-x. 2 apache apache    40 Jun 16 17:15 files

-rw-rw-r--. 1 apache apache   578 Jun 16 17:15 index.php

drwxrwxr-x. 2 apache apache    23 Jun 16 17:15 layouts

-rw-rw-r--. 1 apache apache 18092 Jun 16 17:15 LICENSE.txt

drwxrwxr-x. 2 apache apache    23 Jun 16 17:15 modules

-rw-rw-r--. 1 apache apache  5285 Jun 16 17:15 README.md

-rw-rw-r--. 1 apache apache  1198 Jun 16 17:15 robots.txt

-rw-rw-r--. 1 apache apache 22165 Jun 16 17:15 settings.php

drwxrwxr-x. 2 apache apache    40 Jun 16 17:15 sites

drwxrwxr-x. 2 apache apache    23 Jun 16 17:15 themes