1

I'm trying to create a subdomain for a project i'm working on, projectx.cairocubicles.com, this url points to another server than the one hosting www.cairocubicles.com. The server the subdomain is pointing to has apache installed with the following virtual host:

    <VirtualHost *:80>
  # Admin email, Server Name (domain name) and any aliases
  ServerAdmin [email protected]
  ServerName  www.project1.cairocubicles.com


  # Index file and Document Root (where the public files are located)
  DirectoryIndex index.html index.php
  DocumentRoot /home/project1/web/public
    <Directory /home/project1/web/public>
        Options Indexes FollowSymLinks
        AllowOverride All
        AcceptPathInfo On
        Order allow,deny
        Allow from all
    </Directory>


  # Custom log file locations
  LogLevel warn
  ErrorLog  /home/project1/web/log/error.log
  CustomLog /home/project1/web/log/access.log combined

</VirtualHost>

But now when browsing to project1.cairocubicles.com i get a different website (another website in the virtual host lists). I also tried changing ServerName www.project1.cairocubicles.com to ServerName project1.cairocubicles.com but then i got a 403 Forbidden error. Any clues?

Thanks.

5 Answers 5

1

Just a quick shot in the dark, but this may be a SELinux issue. When you go to the site you have configured as the ServerName, does anything show in the site specific logs? Does anything show up in /var/log/http/error.log?

1
  • just [Thu May 17 01:38:30 2012] [error] [client 41.178.148.24] (13)Permission denied: access to /LICENSE.txt denied May 17, 2012 at 1:27
1

-Make sure you perform a restart or reload with apache2/httpd after ANY changes in config

-Make sure /home/project1/web/public exists and the permission is 664 (perform this recursively with -R)

-Make sure the owner and group of the files is apache2 / httpd (depending on distro), generally user id 33

-Make sure the IP address project1.cairocubicles.com is pointing to is correct

-I generally avoid the www. subdomain with an existing subdomain (not for technical reasons, it just looks messy)

-For testing, make a file called phpinfo.php, and have it only contain the following

 <?php
     phpinfo();
 ?>

and load that only (so http://project1.cairocubicles.com/phpinfo.php)

-You need to make sure you have modified the ownership and group information on the folders. Try the following command (expanding on point 3 above):

sudo chown apache2 /home/project1/public -R 

and

sudo chgrp apache2 /home/project1/public -R 

if the commands say that the user apache2 doesn't exist, replace it with httpd. If the apache2 process (started as the user apache2) cannot read/execute the files then errors may occur (ie, 403 forbidden).

Another way around this is to add your user to the apache2 group. This is a little bit more complex to setup correctly though

5
  • wow did all that and still getting a 403 error May 17, 2012 at 15:59
  • okay i think have a better idea now of where the problems is coming from, i tried pointing the document root of the virtual host to /var/www/vhosts/project1.com/text.test and it works, so the problem is now ehenver i point the document root to the folder in the home directory i get the permission denied problem, iam giving public in /home/proect1/public a 777 permissions, so i am not sure what it's still not working May 17, 2012 at 18:49
  • so it worked now when i gave the home directory in /home/userx a o+x permission, is this safe, why does it need the execute permission for everyone May 17, 2012 at 18:58
  • You need to make sure you have modified the ownership and group information on the folders. Try the following command: chown apache2 /home/project1/public -R and chgrp apache2 /home/project1/public -R if the commands say that the user apache2 doesn't exist, replace it with httpd. This is the reason why its not working in your home directory (owned by your user) and working in the /var/www directory (owned by apache2). I would recommend creating a symbolic link in /var/www/ pointing to your home directory. It is the standard thing to do. (easier for others to see whats going on)
    – Mattisdada
    May 19, 2012 at 1:21
  • great can you add this as an answer to accept it and close the post, but still why was the execution permission specifically that was holding things off, why does apache need it? May 19, 2012 at 11:01
0

Try:

ServerName project1.cairocubicles.com
ServerAlias www.project1.cariocubicles.com

Makes sure the user that apache is running as has read access to the /home/project1/web/public directory

1
  • just did but with no luck, public directory has 775, I'm trying with a file called LICENSE.html (project1.cairocubicles.com/LICENSE.html) and it has a read permssion for all users 664 May 17, 2012 at 1:21
0

If a domain isn't listed as ServerName or ServerAlias, it will load from the first defined VirtualHost. That's why in the first case you ended up seeing the wrong website.

After changing your ServerName, you were probably loading the right website, but now you have an issue with permissions or content. Check the error logs, the access logs, the filesystem permissions. Beyond that, a previous poster mentioned SELinux as a possible problem.

2
  • there is nothing much in the error/access logs, just [Thu May 17 01:38:30 2012] [error] [client 41.178.148.24] (13)Permission denied: access to /LICENSE.txt denied, and for the file permissions the public directory has 775, I'm trying with a file called LICENSE.html (project1.cairocubicles.com/LICENSE.html) and it has a read permssion for all users 664 May 17, 2012 at 1:27
  • also this might be relevant, i have the public folder set up on /home/project1/web/public May 17, 2012 at 1:32
0

so it worked now when i gave the home directory in /home/userx a o+x permission, is this safe, why does it need the execute permission for everyone

I needed to make sure I have modified the ownership and group information on the folders, with the following command: chown apache2 /home/project1/public -R and chgrp apache2 /home/project1/public -R if the commands say that the user apache2 doesn't exist, replace it with httpd. This is the reason why its not working in the home directory (owned by your user) and working in the /var/www directory (owned by apache2). I would recommend creating a symbolic link in /var/www/ pointing to your home directory. It is the standard thing to do. (easier for others to see whats going on)

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .