To elaborate on jap1968 , CentOS 7 comes with a SELinux pain at the butt level set to enforcing . This causes all kinds of confusion when the completely normal configuration of a service is disabled (Apache).
To disable SELinux, you need to:
0) [optional] Crack open a shell and become root ... or enjoy a brilliant new, super fun setting up sudo so you can make the project "root stuffs". Maybe.
su -l
1) Get the current status of SELinux. Run sestatus :
sestatus
2) If SELinux causes hair loss and premature aging, you will get something like this:
SELinux status: enabled SELinuxfs mount: /sys/fs/selinux SELinux root directory: /etc/selinux Loaded policy name: targeted Current mode: enforcing Mode from config file: enforcing Policy MLS status: enabled Policy deny_unknown status: allowed Max kernel policy version: 28
3) Edit the file /etc/selinux/config . Change SELINUX=enforcing to SELINUX=permissive . This will bring you endless joy the next time you reboot. You will get something like this:
4) Disable SELinux. You can reboot at this point, but itβs easier to say that SELinux will not waste time tormenting. Run setenforce to reset the SELinux provisioning level to match the /etc/selinux/config file:
setenforce 0
5) Check sestatus :
sestatus
If everything goes as expected, sestatus will return something like this:
SELinux status: enabled SELinuxfs mount: /sys/fs/selinux SELinux root directory: /etc/selinux Loaded policy name: targeted Current mode: permissive Mode from config file: permissive Policy MLS status: enabled Policy deny_unknown status: allowed Max kernel policy version: 28
6) Restart Apache. If your vhost domain name allows the server you are running on, you will see your new new virtual host:
# Restart apache: systemctl restart httpd.service
6.5) Stop reading here. Or not. I'm a message board, not your mom.
Everything below is beyond the scope of the original question and is included only because you really have to work with SELinux enabled .
7) Work on re-enabling selinux. Start by looking at selinux magazines to see some amazing alphabet soup:
tail -f /var/log/audit/audit.log
8) Marvel at the depths of the devil, the crazy amount of poorly named utilities and the ugly UX mess that SELinux makes up. You should probably put on your big boy trousers and drink a whole coffee pot before you dive. Here are some details: