vhosts not working on windows 7 using wamp - windows-7

i'm having trouble setting up vhosts on windows 7. i'm running wamp.
my host file includes:
127.0.0.1 local.tribune.com
i've included httpd-vhosts.conf from within my httpd.conf.
my httpd-vhosts.conf includes:
<VirtualHost *:80>
DocumentRoot "c:/wamp/www/"
ServerName localhost
</VirtualHost>
<VirtualHost *:80>
DocumentRoot "c:/Users/Name/My Documents/the tribune/website/local.tribune.com/"
ServerName local.tribune.com
</VirtualHost>
here's the weird thing..if i remove the 'My ' from the DocumentRoot, then going to localhost in a browser works and i can see phpmyadmin, but i can't see the contents of the directory because the path is incorrect. but soon as i put that 'My ' in the path, the wamp icon never goes white (it stays yellow), and i can't reach localhost or local.tribune.com.
soon as i remove the 'My ' again, localhost will work again.
i've seen multiple posts around this issue on wampserver.com and elsewhere, but none of them answered or resolved. most that are resolved are basic issues like not including or having deleted httpd-vhosts.conf, missing characters, etc.

Its never a good idea to have a space in your directory path. URL Encoding interprets it as: "%20%". I would suggest placing your website files on D:/websites/local.tribune.com
you can read more about URL Encoding here
Hope that helps

solved it. was close before, but just missed it.
in windows 7, the path is NOT:
c:/Users/Name/My Documents/the tribune/website/local.tribune.com
but is actually:
c:/Users/Name/Documents/the tribune/website/local.tribune.com
to prove this, click at the end of a path in a windows explorer window, and the full path is displayed in plain text.
also, just because i've seen some disagreement online, in my experience:
the drive letter is case insensitive
the slashes can go either way
trailing slashes have no effect
path names CAN have a space in them

Related

custom url instead of having localhost

I have a folder called example inside htdocs in XAMPP , so I access my url with localhost/example/ . How can I have just example/ instead of localhost/example/ when I type my url ? Thanks in advance!
I've tried editing DocumentRoom in apache htdocs and it didn't work...
I'm not sure if that helps you, but you have to set the html root into your example folder to be able to use localhost/ only. Maybe you can move all contents of the example folder to the parent directory and try again.
If you want to use a real URL like example.com/ instead of localhost/ you can edit your hosts file
sudo nano /etc/hosts
and add the following lines to the end:
127.0.0.1 www.example.com
127.0.0.1 example.com

Is it possible to get `www.mydomain.com/app` to point to `www.myapp.heroku.com`?

I have www.myapp.heroku.com and domain name www.mydomain.com.
Is it possible to have www.mydomain.com/app point to www.myapp.heroku.com?
Googling seems to only yield how to get www.mydomain.com to point to www.myapp.heroku.com. I can't find anything about forward slashes.
Try it with HTACCESS (If unknown create a blank file in your base directory and rename it to: .htaccess
Now add:
RewriteEngine on
Redirect /app http://www.app.yourdomain.com
Just tested it, will work (if your provider supports htaccess url forwarding)
Good Luck

Using wildcard * on include of apache not working on OSX

Couldn't find any info about this.
tl;dr
Can't manage to include all conf files of a directory with * wildcard as Include /path/to/directory/*.conf
Extended explanation
I have the contents
$ cd /private/etc/apache2
$ tree vhosts
. vhosts
`-- test.conf
$ cat vhosts/test.conf
<VirtualHost *:80>
DocumentRoot "/Users/ml/web/"
ServerName localhost
</VirtualHost>
$
So if I append into /private/etc/apache2/httpd.conf:
Include /private/etc/apache2/vhosts/test.conf
It works as expected, but if I use *.confinstead like:
Include /private/etc/apache2/vhosts/test.conf
It wont work.
This exists in an example (in httpd.conf), shouldn't this work? Or might be something I'm doing it wrong?
On Apache 2.4 use IncludeOptional instead of Include when using wildcards. More here: https://www.digitalocean.com/community/tutorials/migrating-your-apache-configuration-from-2-2-to-2-4-syntax

Writing common file with replacements in bash

I am writing a script to setup new projects on my computer,
One part I am wanting to do is have it automatically setup the virtual hosts for me.
The file itself is quite simple
the file should be called <project>.testfox.dev.conf and should contain
<VirtualHost *:80>
DocumentRoot "/var/www/work/<project>"
ServerName <project>.testfox.dev
<Directory "/var/www/work/<project>">
allow from all
Options +Indexes
</Directory>
ErrorLog /var/log/apache2/<project>.error.log
LogLevel error
TransferLog /var/log/apache2/<project>.access.log
</VirtualHost>
What I wonder is, should I have that code in my script and write it out line by line to the file, or should I have a dummy file in the sites-available folder that I copy and then search a replace a placeholder?
The most flexible way would be to have it as a template (either as a separate file, or a HEREDOC), writing it line-by-line would make it very hard to modify in future.
The HEREDOC approach would be easier to implement, as you can use variable interpolation:
cat >$PROJECT.testfox.dev.conf <<EOF
<VirtualHost *:80>
DocumentRoot "/var/www/work/$PROJECT"
ServerName $PROJECT.testfox.dev
<Directory "/var/www/work/$PROJECT">
allow from all
Options +Indexes
</Directory>
ErrorLog /var/log/apache2/$PROJECT.error.log
LogLevel error
TransferLog /var/log/apache2/$PROJECT.access.log
</VirtualHost>
EOF
Both are viable approaches.
Using it as a template makes it easier and more readable, if you want to modify it. But keeping it in a bash script as a here document works as well.
In the end, it depends on what your preferences are.

combining mod_rewrite and vhost_dbd_module

I'm trying to give users a static files folder served from inside their chroot. The following code works under other conditions (basically without the inclusion of the DBDocRoot directive) but just doesn't do what is expected. Is mod_vhost_dbd simply not compatible with mod_rewrite? It partially works in that the request hits the correct python script which then does some other stuff and launches a wsgi app.
With this code nothing is logged in rewrite.log. If you comment out the DBDocRoot directive line stuff is logged but of course the rewrite rule doesn't work because ${ENV:username} is the empty string. The query work perfectly well when run from a mysql console.
LoadModule vhost_dbd_module /usr/lib/apache2/modules/mod_vhost_dbd.so
DBDExptime 5
<VirtualHost *:80>
ServerAlias *
RewriteEngine On
RewriteLog "/var/log/apache2/rewrite.log"
RewriteLogLevel 9
DBDriver mysql
DBDParams host=amysqlhost,user=abdbuser,pass=private,dbname=adbname
DBDocRoot "SELECT concat('/mnt/user_storage/webscripts/', username, '/user_script.py'), username from user, userdomain where user.id = userdomain.user_id and userdomain.domain_name = %s" HOSTNAME
RewriteCond /mnt/user_storage/homedirs/%{ENV:username}/var/www/static%{REQUEST_URI} -f
RewriteRule ^/(.*) /mnt/user_storage/homedirs/%{ENV:username}/var/www/static/$1 [L]
</VirtualHost>
Has anyone else successfully used this module to set an environment variable? The notes on the mod_vhost_dbd wiki say that it can be done.

Resources