I am using one of those cloud VPS providers that provide most of their storage on the /data disk, so my webroot is at
/data/www instead of
/var/www. And there is a symlink so that Apache works fine with default config.
I think the goal is to copy all the rules under
/var/www and create the same rules except
/var/www is changed to
/data/www. Is there a way to do it quickly?
[~]$ sudo semanage fcontext -l | grep -i /var/www /var/www(/.*)? all files system_u:object_r:httpd_sys_content_t:s0 /var/www(/.*)?/logs(/.*)? all files system_u:object_r:httpd_log_t:s0 /var/www/[^/]*/cgi-bin(/.*)? all files system_u:object_r:httpd_sys_script_exec_t:s0 /var/www/apcupsd/multimon\.cgi regular file system_u:object_r:apcupsd_cgi_script_exec_t:s0 ... many more ...
I only know how to do them one by one, by giving:
sudo semanage fcontext -a -t httpd_sys_content_t "/data/www(/.*)?" sudo restorecon -R -v /data/www
This takes care of the first rule. Is there a way to do it fast?