Dashes not allowed in virtual host entry? - apache

Strange error. Was trying to figure out why a virtual host was not working using a setup I've used a hundred times.
DocumentRoot "/var/htdocs/directory-name/"
<Directory "/var/htdocs/directory-name/">
Gave me a 403 error no matter what I tried
DocumentRoot "/var/htdocs/directoryname/"
<Directory "/var/htdocs/directoryname/">
Did not. Has anyone else ever experienced this? I didn't paste the entire virtual host entry, but this was the only difference between what worked and what gave me a 403. I'm totally bewildered.

This should work if you have a physical folder "directory-name" at "/var/htdocs". Could be some unrelated problem otherwise.

Perhaps you forgot to add an entry like
127.0.0.1 test.directory-name.com
in C:\Windows\System32\drivers\etc\hosts ? (if using a test environment on Windows)
Also, double-check any .htaccess files you have for unwanted Rewrites / redirects

Related

OSX Mavericks Apache "DocumentRoot must be a directory"

I wanted to change the default document root for some local development on my new machine.
I edited httpd.conf and changed the DocumentRoot declaration to "Documents/Sandbox" and made sure the Sandbox directory has the correct permissions (777).
Further down in httpd.conf I edited another line to read .
So basically I replaced all original DocumentRoot declarations and replaced them with "Documents/Sandbox".
Now whenever I try to run Apache I get the infamous "Documentroot must be a directory" error.
I tried different variations of the DocumentRoot such as with and without a trailing slash, with a home directory declaration (~), adding "Users/me/", ... anyway it doesn't work.
Is what I am trying to do possible (ie having my DocumentRoot in a folder under "Documents" on my machine" and if so how do I go about correct this error?
I had the same problem. I was missing the first "/"
IE: /Users/me/Documents/Sandbox

How can I add an additional DocumentRoot to my Apache Server?

So I have my default htdocs folder, but I would like to add an additional one, which is outside. My problem is that I don't have any idea, how I can do this. I'm only knowing, how I can change the directory, but that's not the way, I would like to go.
I've read something about an Virtual Host, which can be added. So I tried it, but with any result, but haven't expected, that it would be that easy... even the httpd.exe said, that the syntax was ok. But there wasn't any further explanation, how I could go on.
Does anyone know, how I can add an additional one?
Thanks in anticipation!
Just add a different DocumentRoot directive to each Virtual Host section then you have a different document root for each virtual host.

Unable to hit https for certain projects

I have a project in xampp/htdocs/project1
I needed to create another project so I decided to assign them different ports so now,
xampp/htdocs/project1 runs on 8080
and my project2 which is under
C:/release/project2 runs on 7171
I needed to make project2 https , so created ssl certificate and everything is setup in apache too.(listening to 443)
https:/xx.xx.xx.xxx:443/project1/login.php gave error
whereas https:/xx.xx.xx.xxx:443/project2/login.php could be hit.
so i did following change in httpd-ssl.conf,
DocumentRoot "C:/xampp/htdocs" to DocumentRoot "C:/release"
but now i get the error -
Access forbidden!
You don't have permission to access the requested object. It is either
read-protected or not readable by the server.
If you think this is a server error, please contact the webmaster.
Error 403
This error is given for both,
https:/xx.xx.xx.xxx:443/project1/login.php
and https:/xx.xx.xx.xxx:443/project2/login.php
I thought it was permission problems, but i can still hit these
https:/xx.xx.xx.xxx:8080/project1/login.php
and https:/xx.xx.xx.xxx:7171/project2/login.php
What could be the problem? I am new to website development so could not figure out what I am doing wrong.Is project being under htdocs compulsory for this or assigning of different ports was wrong?
You might have got it working by now,
But It seems like the permissions are not set.
It is not compulsary to have the project under htdocs.Since your project is working on 7171 everything might be fine.
you can try following,
1) for permissions, Check if you have AllowOverride All Order allow,deny Allow from all set in httpd.conf too.Restart the server.
If it still doesnt work,
2) check if http://www.youtube.com/watch?v=ZUAKLUZa-AU can help.

MAMP just ONE virtual host not working

I wanted to start a (my first) wordpress project on my mac.
I run apache with MAMP, and wanted to make another (I allready have a few) virtual host for this particular project.
I added the host to my httpd.conf and etc/hosts file as i've done many times before.
When I browse to the url i've chosen I just end up in the directory that i've specified as root folder in my MAMP settings.
Apache seems to ignore the changes made in the httpd.conf file, but if I remove (rename) the httpd.conf file (to _httpd.conf) it apache doesn't start. so it looks like changes to this file are ignored, BUT if I put something wrong in the file apache doesn't start either...
this is what I put in the httpd.conf file to add a virtual host:
<VirtualHost *>
DocumentRoot "/Users/username/Sites/site_dir/"
ServerName local.sitename.com
<Directory "/Users/username/Sites/site_dir/">
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
can this have anything to do with WP?
greets,
R.
On Windows:
Try putting it in the conf/extras/httpd-vhosts.conf instead and try
where port 80 is whatever port you have apache running on (:80 by default on windows)
and try not to use .org .com or any ending common on the web in your server name/alias use if you are developing the project on your localhost use something like sitename.local instead.
On Mac:
Not sure how it would work
On Ubuntu 11.04:
I just:
Set up a different vhost file for each site inside of /etc/apache2/sites-available
Then enable the site via a2ensite or just make a copy to the file using cp to the sites-enabled folder (all this is done via the ssh or a terminal on mac)
I then reload and restart apache and wallah!
I'm having a similar problem on one of my ubuntu servers. I'm doing something that I've done several times but all of a sudden it doesn't work. Go figure, lol! Typo? Who knows, definitely scour the web, an answer is sure to surface.

Apache2 httpd.conf help

I have a domain, for example, http://example.com. It is already configured to point to
/var/www/
Basically, i want http://example.com to point to
/var/www/4.0/
and http://example.com/foobar/ to point to
/var/www/moo/
How can I do this with the httpd.conf file for Apache2? Thanks
Assuming you are only serving one domain (example.com), you can change your DocumentRoot to /var/www/4.0/
and set an Alias for the /foobar like
Alias /foobar /var/www/moo
If you are serving more than one domain from the same Apache, then you need to use the DocumentRoot within a VirtualHost tag.
More info is here: http://httpd.apache.org/docs/2.2/vhosts/
I think you're going about this the wrong way with httpd.conf, but I'll answer your question as you asked it first and then explain about that.
There are two settings in httpd.conf relevant to this.
The DocumentRoot setting is the important one, it configures the base directory from which to serve. Change it as so:
Before:
DocumentRoot "/var/www"
After:
DocumentRoot "/var/www/4.0"
Be sure not to use any / after the 4.0, it's not needed.
A little under 30 lines below this setting is another, which should say:
As the comment above it says, change it to "/var/www/4.0" too.
This would set www.example.com to the 4.0 directory (first part) and apply the relevant settings to this directory too (second part).
But I don't think you should do that, setting apache to serve the 4.0/ directory with httpd.conf makes a mess for serving the other directories. I'd suggest you read about redirects and how to implement them with whatever language you're using. Then you can point one URL to another without it ever being noticed in the browser (unless they're really trying to).
So without changing DocumentRoot from "/var/www", you can edit /var/www/index.php (or whatever) and have it redirect to /var/www/4.0/. The same can be done in /var/www/foobar/index.php to display /var/www/moo/ instead, but here I'd really just rename the "foobar" directory on the server to "moo". If you want to get elaborate, look into mod_rewrite, but I'd advise you to try all your alternatives first and only use it if you really need to, it's quite a complex tool.