I recently moved a Joomla! Web site that I built on a Slackware Linux system to a CentOS 7 box.

The move was accomplished in three easy steps:

  1. The site was archived as a tgz file and unpacked at the destination location;
  2. The MySQL database was dumped and reloaded on the destination host;
  3. The configuration.php file of the site was edited to correct a couple of path names.

Everything seemed to be working just fine until I tried to upload an image to the new site. Then all hell broke lose. An innocent Joomla message ("failed to move file") led me to an odyssey of sorts, learning about XFS access control lists and ultimately, SELinux.

The root cause was that the new host has SELinux (Security Enhanced Linux) enabled. By itself, it is a Good Thing, of course. The problem was that with SELinux, despite the fact that all files and folders seemed to have correct ownership and permission settings, the Apache server was unable to write them as they were marked by SELinux as read-only content.

Once I fully understood the problem, the solution was very simple. In the folder hosting the Joomla site, I issued the command

chcon -Rv -t httpd_sys_rw_content_t .

This informed SELinux that this folder is writable by the Web server. It enabled not just file uploads but, in the future, it will also enable Joomla updates through the site's administrator interface.

And the best part is that I did not have to turn off or weaken SELinux security, which (quite sadly) was the solution advocated by many Web sites that I encountered while I was searching for answers.