Linux - ServerThis forum is for the discussion of Linux Software used in a server related context.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
I am running CentOS and using it to host a website with Apache httpd server. I was about to create other pages with virtualhosting. The default site that is stored in "/var/www/html" is working fine. But I added the vhost.conf file in the "/etc/httpd/conf.d/" directory and added the following lines.
I restarted the service and I get the 403 forbidden page and says that the / directory isn't accessible by apache. I have no knowledge of making that my document root directory so what is going on here. I have enabled name based virtual hosting and the address is already in my DNS zone file. I want to know why this is happening. Coincidentally when I try to access the default page I get the same error. When I remove the virtualhost or comment it out in the vhost.conf file everything starts working again. I don't understand why and I have been creating virtualhosts like this for years (but up to now just on debian based distros)
Copy the <Directory>- tag of the existing configuration (with a specified directory = document root) to your virtual host config and replace the directory path.
By default all directories are not visible for the web user.
I just tried the lines of code that I specified above in my vhost.conf file and apache came back with an error, can you give me an example of what you mean.
Last edited by baronobeefdip; 06-08-2013 at 04:21 PM.
Then I restarted, the server restarted fine as far as it knew there weren't any syntax errors. Then tried to go to the site. The default host worked fine but the drupal one (There was a DNS record of it already) would give me the forbidden error for the / directory. I am really confused when it comes to redhat. The method that I started this thread with using has always worked in my lab environment. But in those instances I was using Fedora 14. In this case I am usign CentOS 6. I didn't see any significant differences but this is starting to become very frustrating since all the sites for centos say the same thing. simply add virtualhost but obviously that isn't working. What is the problem here?
I think the directory tag should reside within the virtualHost tag but I don't know whether that's the reason. Maybe drupal needs some options like AllowOverride if it is working with htaccess files...
<VirtualHost *:80>
ServerName drupal.baronobeefdip.josh
DocumentRoot /var/drupal/html
<Directory /var/drupal/html>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
allow from all
</Directory>
</VirtualHost>
Still didn't work I want the default host to still be accessible when you simply type in the IP address but I get the / directory again. Plus it's still forbidden. I have been trying to access both the default and the local hosts and none of them are working. Here's my vhost.conf file again
Code:
<IfModule mod_ssl.c>
<VirtualHost *:443>
ServerName joomla.baronobeefdip.josh
DocumentRoot /var/www/html
SSLEngine on
SSLCertificateFile /etc/httpd/ssl/localhost.crt
SSLCertificateKeyFile /etc/httpd/ssl/localhost.key
</VirtualHost>
</IfModule>
<VirtualHost *:80>
ServerName drupal.baronobeefdip.josh
DocumentRoot /var/drupal/html
<Directory /var/drupal/html>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
allow from all
</Directory>
</VirtualHost>
Sounds like SELinux is preventing access. Notice the security context type for /var/www/html is "httpd_sys_content_t" whereas for /var it's just "var_t".
By creating that "wordpress" directory under /var that directory is also given the security context type "var_t" instead of "httpd_sys_content_t" and therefore httpd is not permitted to access the contents of that directory.
I am just disabling SELINUX, I just remembers that in the lab environment that I am in all the time we would disable selinux on all the machines that were running redhat. I just needed a memory refresher. I'll get back to you and tell you what happens.
Alongside what else has been said, you haven't told us how you turned off SELinux (I recommend keeping it on by the way except for debugging purposes).
If you used:
Code:
setenforce 0
That's not going to survive a reboot.
Also, there's no need to reboot the entire machine if all you're going to do is restart a service or just change the permissions of a directory.
For future reference, use
Code:
sestatus
To see if SELinux is set to enforcing/permissive/disabled.
set SE to "permissive" for testing
this will tell "SElinuxTroubleShooter" about problems that will stop something from running IF it were in "enforcing" mode
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.