I have a OS X Server 10.8 [with the Server App]. I have enabled the websites service and I've added the path to /Volumes/dev1/http as the root for my Server Website.
I've edited the file in /private/etc/apache2/httpd.conf and added the following line: Include /Volumes/dev1/http/.virtual-hosts
The file at /Volumes/dev1/http/.virtual-hosts is something like:
listen 80
listen 443
servername "site"
serveradmin "mail#myemail.com"
namevirtualhost *:80
namevirtualhost *:443
directoryindex .index.php index.html index.php
options -indexes -multiviews +followsymlinks
<directory /Volumes/dev1/http>
allowoverride all
</directory>
<virtualhost *:80 *:443>
servername site.com
serveralias www.site.com
documentroot "/Volumes/dev1/http/com-site"
rewriteengine on
</virtualhost>
The Server completely ignores this file, even though if I put in some random characters and run apachectl -t it says that the syntax is not OK.
I've even tried only having directoryindex .index.php in this file and it still has no effect - it returns 403 Forbidden, even thought .index.php is present.
This exact configuration works like a charm on an older 10.6 Server.
Thanks for taking the time to think about my problem!
After some google-ing and trial and error approach the answer is: when using the Server App in OS 10.8 you need to put the include directive in /Library/Server/Web/Config/apache2/httpd_server_app.conf not in /private/etc/apache2/httpd.conf
Related
On my Windows 7 PC, I'm using XAMPP => Apache to run a testing webserver. But for a certain website I don't want the regular "C:\xampp\htdocs", but a custom path - which when I work on Ubuntu I usually setup in VirtualHost just as a DocumentRoot and it works.
On this PC the target path is similar to: "C:\Users\X\Disk External\DIRWITHDIÁCRÍCÍCS\WEBS\some path\path"
However on this PC when I do
<VirtualHost test2020.test:443>
DocumentRoot "C:\Users\X\Disk External\DIRWITHDIÁCRÍCÍCS\WEBS\some path\path"
ServerName test2020.test
ServerAlias www.test2020.test
</VirtualHost>
The DocumentRoot directive is completely ignored - it still seems to target files in the default C:\xampp\htdocs
I've also tried moving the files around the system and changing forward/backward slashes with no success:
DocumentRoot "C:/Users/X/Disk External/DIRWITHDIÁCRÍCÍCS/WEBS/some path/path"
DocumentRoot C:\xampp\htdocs\testdocumentroot
DocumentRoot "C:\Users\X\www"
Also I've tried swapping order of DocumentRoot and ServerName with no success.
I've checked C:\xampp\apache\conf\httpd.conf - the line Include conf/extra/httpd-vhosts.conf IS uncommented.
And the file C:\xampp\apache\conf\extra\httpd-vhosts.conf seems to affect apache start-up when set-up wrongly.
EDIT: also I did restart apache between each try :)
What am I missing?
So it's just my idiotism, I've tried to overdomain everything, but the directive attribute inside the VirtualHost tag is for network incoming limitation. For regular cases * is just fine there, also then I had a problem with Directory tag directive because aparently there's a new directive for Apache 2.4+
<VirtualHost test2020.test:443> => <VirtualHost *:443>
Working final code:
# (or *:80 for http:// , 443 is for https://)
<VirtualHost *:443>
DocumentRoot "C:\Users\X\Disk External\DIRWITHDIÁCRÍCÍCS\WEBS\some path\path"
ServerName test2020.test
ServerAlias www.test2020.test
<Directory "C:\Users\X\Disk External\DIRWITHDIÁCRÍCÍCS\WEBS\some path\path">
# NEW&SIMPLE FROM APACHE 2.4+ !
Require all granted
</Directory>
</VirtualHost>
I installed apache with brew and changed port 8080 to 80. when I accessed localhost this shown me a page "it works!" and that page is located in /usr/local/var/www directory with file name index.html but when I added a virtual host in /usr/local/etc/httpd/extra/httpd-vhosts.conf file.
<VirtualHost *:80>
DocumentRoot "/Users/ranaamir/projects/sample/yii2/backend/web"
ServerName yii2.example.be
ServerAlias yii2.example.be
<directory "/Users/ranaamir/projects/sample/yii2/backend/web">
Options Indexes FollowSymLinks
AllowOverride all
Order Deny,Allow
Allow from all
Require all granted
</directory>
ErrorLog "/usr/local/var/log/httpd/vjfBackenderror.log"
CustomLog "/usr/local/var/log/httpd/vjfBackendaccess.log" common
</VirtualHost>
and restart the service with sudo apachectl -k restart command and this host also added in /etc/hosts.
##
127.0.0.1 localhost
255.255.255.255 broadcasthost
::1 localhost
127.0.0.1 yii2.example.be
Then I access localhost or yii2.example.be both are showing a page where only one line mentioned Index of /.
if I remove code of block <VirtualHost *:80> from httpd-vhosts.conf then again localhost host showing correct index.html.
why my project not running on the virtual-host url instead of index of /?
Any help would be so appreciated!!
I have resolved this issue, I made little change in httpd.conf file where we have to mentioned which type of file they will be process first so I just added index.php in the code block of dir_module.
<IfModule dir_module>
DirectoryIndex index.php index.html
</IfModule>
I hope this will save your time and minimize your stress. :)
I am trying to create a virtual host for a Zend Framework project, but it is not working.
I added the string "127.0.0.1 mysite.local" to the hosts file (/private/etc/hosts), and this is what I put in httpd.conf:
<VirtualHost *:80>
ServerName mysite.local
DocumentRoot "/Applications/MAMP/htdocs/mysite/public"
SetEnv APPLICATION_ENV "development"
<Directory "/Applications/MAMP/htdocs/mysite/public">
DirectoryIndex index.php
AllowOverride All
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
I restarted server, and then I try to access it in browser like: http://mysite.local:8888/, but it takes me to "htdocs" root, not to the Zend Project.
Am I missing something? Did I type something wrong? I'm using MacOSX, I tried putting port 8888 instead of 80 in the VirtualHost definition but it didn't work too.
Thanks
I'm trying to get my wordpress site as well as my reviewboard site working under the same domain name.
Ex:
www.mysite.com (this is where i host my wordpress site)
www.mysite.com/reviewboard (this is where I want to host my reviewboard site)
I can get one or the other to work depending on my httpd-vhosts.conf file. However, I cannot get both to work(this is where I need your help!).
This is how I host my wordpress site:
<VirtualHost *:80>
ServerAdmin myemail#gmail.com
DocumentRoot "/opt/local/apache2/htdocs/mysite"
ServerName www.mysite.com
ErrorLog "/opt/local/apache2/logs/mysite.com-error_log"
CustomLog "/opt/local/apache2/logs/mysite.com-access_log" common
</VirtualHost>
This is how I host my reviewboard site(which then breaks my wordpress site):
<VirtualHost *:80>
ServerName www.mysite.com
DocumentRoot "/opt/local/apache2/htdocs/mysite/reviewboard/htdocs"
# Error handlers
ErrorDocument 500 /errordocs/500.html
WSGIPassAuthorization On
WSGIScriptAlias "/reviewboard" "/opt/local/apache2/htdocs/mysite/reviewboard/htdocs/reviewboard.wsgi/reviewboard"
<Directory "/opt/local/apache2/htdocs/mysite/reviewboard/htdocs">
AllowOverride All
Options -Indexes +FollowSymLinks
Allow from all
</Directory>
# Alias static media requests to filesystem
Alias /reviewboard/media "/opt/local/apache2/htdocs/mysite/reviewboard/htdocs/media"
Alias /reviewboard/static "/opt/local/apache2/htdocs/mysite/reviewboard/htdocs/static"
Alias /reviewboard/errordocs "/opt/local/apache2/htdocs/mysite/reviewboard/htdocs/errordocs"
Alias /reviewboard/favicon.ico "/opt/local/apache2/htdocs/mysite/reviewboard/htdocs/static/rb/images/favicon.png"
</VirtualHost>
So, now I want to be able to figure out how to combine these somehow so I can have reviewboard hosted at the path specified above without breaking my wordpress site. I tried using the Alias command as mentioned here: http://stackoverflow.com/questions/1553165/multiple-django-sites-with-apache-mod-wsgi
and here
https://code.google.com/p/modwsgi/wiki/ConfigurationGuidelines
However I can't get it to work. Here's my WIP. If you can be very specific as what I need to do in order to change this so it works that would be great since I'm new to this kind of stuff. Thanks!
<VirtualHost *:80>
ServerName www.mysite.com
DocumentRoot "/opt/local/apache2/htdocs/mysite"
# Error handlers
#hmm not sure where to put this since my document root is different??????
#ErrorDocument 500 /errordocs/500.html
WSGIPassAuthorization On
Alias /reviewboard/ /opt/local/apache2/htdocs/mysite/reviewboard/htdocs/
<Directory "/opt/local/apache2/htdocs/mysite/reviewboard/htdocs">
Options ExecCGI
SetHandler wsgi-script
AllowOverride All
Options -Indexes +FollowSymLinks
Allow from all
</Directory>
# Alias static media requests to filesystem
# Since I added the alias command above these are complaining about
#overlapping an earlier alias when I restart my apache server????
Alias /reviewboard/media "/opt/local/apache2/htdocs/mysite/reviewboard/htdocs/media"
Alias /reviewboard/static "/opt/local/apache2/htdocs/mysite/reviewboard/htdocs/static"
Alias /reviewboard/errordocs "/opt/local/apache2/htdocs/mysite/reviewboard/htdocs/errordocs"
Alias /reviewboard/favicon.ico "/opt/local/apache2/htdocs/mysite/reviewboard/htdocs/static/rb/images/favicon.png"
</VirtualHost>
If you're using the same domain for both, you can't use different VirtualHost sections for both. So first off, you have to merge both configurations into a single VirtualHost section. I'd start with the WordPress config, then add a few bits for ReviewBoard:
<VirtualHost *:80>
ServerAdmin myemail#gmail.com
DocumentRoot "/opt/local/apache2/htdocs/mysite"
ServerName www.mysite.com
ErrorLog "/opt/local/apache2/logs/mysite.com-error_log"
CustomLog "/opt/local/apache2/logs/mysite.com-access_log" common
WSGIPassAuthorization On
WSGIScriptAlias /reviewboard /opt/local/apache2/htdocs/mysite/reviewboard/rb.wsgi
<Directory /opt/local/apache2/htdocs/mysite/reviewboard>
Order deny,allow
Allow from all
</Directory>
Alias /reviewboard/media "/opt/local/apache2/htdocs/mysite/reviewboard/htdocs/media"
Alias /reviewboard/static "/opt/local/apache2/htdocs/mysite/reviewboard/htdocs/static"
Alias /reviewboard/errordocs "/opt/local/apache2/htdocs/mysite/reviewboard/htdocs/errordocs"
Alias /reviewboard/favicon.ico "/opt/local/apache2/htdocs/mysite/reviewboard/htdocs/static/rb/images/favicon.png"
</VirtualHost>
You need to create a WSGI script (but you should already have that). You might want to put it in a different path than what I put in the config here, so your permissions are more secure.
Using a combination of what djc wrote and some of my tinkering here's the working version so that:
www.mysite.com (wordpress site loads correctly)(mod_php)
www.mysite.com/reviewboard (reviewboard site loads correctly)(mod_wsgi)
Important make sure you clear your browser cache every time you restart your apache server as I kept falling into the trap of it showing incorrect data since I forgot to do that.
Important2 Make sure the "/reviewboard" follows the "reviewboard.wsgi" to become "reviewboard.wsgi/reviewboard" otherwise it will not work and gives a 404 error!
Here's the working version:
<VirtualHost *:80>
ServerAdmin myemail#gmail.com
ServerName www.mysite.com
DocumentRoot "/opt/local/apache2/htdocs/mysite"
ErrorLog "/opt/local/apache2/logs/mysite-error_log"
CustomLog "/opt/local/apache2/logs/mysite-access_log" common
WSGIPassAuthorization On
WSGIScriptAlias /reviewboard /opt/local/apache2/htdocs/mysite/reviewboard/htdocs/reviewboard.wsgi/reviewboard
<Directory /opt/local/apache2/htdocs/mysite/reviewboard>
Allow from all
Options -Indexes +FollowSymLinks
AllowOverride All
</Directory>
# Alias static media requests to filesystem
Alias /reviewboard/media "/opt/local/apache2/htdocs/mysite/reviewboard/htdocs/media"
Alias /reviewboard/static "/opt/local/apache2/htdocs/mysite/reviewboard/htdocs/static"
Alias /reviewboard/errordocs "/opt/local/apache2/htdocs/mysite/reviewboard/htdocs/errordocs"
Alias /reviewboard/favicon.ico "/opt/local/apache2/htdocs/mysite/reviewboard/htdocs/static/rb/images/favicon.png"
</VirtualHost>
I have Windows 7 + Zend server
In httpd.conf file i have:
NameVirtualHost *:80
<VirtualHost *:80>
ServerAdmin keyne#localhost
ServerName local-izbori.bg
ServerAlias *.local-izbori.bg
DocumentRoot "C:\Program Files\Zend\Apache2\htdocs\izbori-www"
<Directory 'C:\Program Files\Zend\Apache2\htdocs\izbori-www'>
DirectoryIndex index.php
AllowOverride All
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
in windows host file:
127.0.0.1 local-izbori.bg
And in my .htaccess file:
Options +FollowSymLinks
RewriteEngine on
RewriteRule !\.(js|ico|gif|jpg|png|css|php|doc|docx|pdf|swf|htm|php|htc)$ index.php
url rewrite work find, ex: local-izbori.bg/members/register/
but dynamic subdomain, like http://ruse.local-izbori.bg/ruse return: Server not found
is there any way to do all subdomain to go to index.php ?
Look into wildcard subdomains. In order for them to work you need to add that subdomain to your DNS.
I asume you are on windows. Unfortunately windows does not support wildcard definition so you will have to add a line for each subdomain to your hosts file.