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.
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?
-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
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):
and
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
Try:
Makes sure the user that apache is running as has read access to the /home/project1/web/public directory
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.
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)