Forum Moderators: phranque

Message Too Old, No Replies

Virtual hosting

localhost subdomains

         

Jesdisciple

4:52 pm on Jun 3, 2009 (gmt 0)

10+ Year Member



I have 3 different sites which I'm building on my PC, and to make them compatible with their deployment servers I must use a PHP script which reads the site root from the first '.root' file found while ascending the directory tree. I would much rather let Apache handle this, but it's not cooperating.

I'm following this guide [help.ubuntu.com]; the mentioned Network Configuration Applet has a bug which forces me to directly edit /etc/hosts which begins like so:


127.0.0.1localhost
127.0.0.1 crosspoint.localhost
127.0.1.1Jesdisciple-laptop

That part works, but only makes the subdomain a synonym of localhost. The part that doesn't work is /etc/apache2/sites-enabled/crosspoint:


<VirtualHost *>
DocumentRoot /home/coder/www/projects/crosspoint/
ServerName crosspoint.localhost

<Directory /home/chris/crosspoint/>
Options Indexes FollowSymLinks MultiViews +Includes
AllowOverride All Limit
Order allow,deny
allow from all
</Directory>
</VirtualHost>

Any help would be most appreciated.

[edited by: encyclo at 1:42 am (utc) on June 4, 2009]
[edit reason] fixed link [/edit]

encyclo

1:52 am on Jun 4, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I'm unsure what you're attempting to achieve with regards to your VirtualHost shown above as the path in the Directory section is outside the document root. Could you clarify?

If I understand the problem correctly, you need to run a PHP file before serving the requested page? If so, have you looked at php_value auto_prepend_file?:

php_value auto_prepend_file "/path/to/file.php"

Jesdisciple

4:05 am on Jun 4, 2009 (gmt 0)

10+ Year Member



Oops, I'm not sure where I got that idea... I was thinking Apache would automatically make a symlink. That was pretty dumb, so thanks for showing me. Unfortunately, it didn't change anything after a restart of Apache.

That directive would help with remembering to include the code, but it's not what I was asking; I still have to depend on the $ROOT variable to know where to find all my files. The current arrangement is just the alternative to a virtual host, adopted as a work-around.

<edit>Oh, here's something important. When I restart Apache, I get this error:


NameVirtualHost *:80 has no VirtualHosts

</edit>

<edit>I found a bunch of questions about that on Google, but I have a different situation. Some said the 000-default file apparently has a NameVirtualHost directive but no VirtualHosts tag could be found. Actually, ports.conf has the directive and 000-default has the tag.

Commenting the NameVirtualHost line as described here [v2kblog.blogspot.com] got rid of the warning but didn't fix anything.</edit>

Thanks!

[edited by: Jesdisciple at 4:39 am (utc) on June 4, 2009]

Jesdisciple

5:38 am on Jun 4, 2009 (gmt 0)

10+ Year Member



Alright, I got rid of the errors by adding a NameVirtualHost * line to 000-default, changing all my VirtualHosts to * instead of the default *:80, then commenting the directive in ports.conf. The vhost still doesn't work...

*jumps and shouts* I cleared my cache (suggested on another forum) and the problem disappeared.

[edited by: Jesdisciple at 6:07 am (utc) on June 4, 2009]