I have cento os 7 and installing php website and by default i have to upload code to /var/www/html but i want my code to pick from /home/magento.
How to rewrite Document Root path in cento os .
Use these commands one by one:
chcon -R --reference=/var/www/html/ /home/magento chcon -R -t httpd_sys_content_t /home/magento/ semanage fcontext -a -t httpd_sys_content_t "/home/magento(/.*)?" setsebool -P httpd_enable_homedirs true chmod 755 /home/magento # important !! service httpd restart
You can change the
DocumentRoot directive in your
httpd.conf (this should be found in
The file should contain a line like:
Change it to:
If you add more directories in different locations that you want published you'll need to start making use of VirtualHost files
Also, if SELinux is set to enforcing, you'll need to set the SELinux context of the directory to match that of your /var/www directory. To find out whether or not SELinux is in operation use:
If the output is "permissive" then it's not enforcing.
If the output is "enforcing" then it's enforcing.
In order to change the context of the directory and its contents run the following:
semanage -a -t httpd_sys_content_t "/home/magento(/.*)?"
Now when you run
ls -dZ /home/magento the "httpd_sys_content_t" context should be present in the output.
You will likely also have to set an SELinux boolean to allow publishing home dirs. To do this use:
setsebool -P httpd_enable_homedirs true
Note: the apache user will also need permissions to read the directory's contents.