Virtual hosts and PHP "downloads": php5 and apache22 on FreeBSD
john.destefano at gmail.com
Tue Jun 6 19:45:48 UTC 2006
I upgraded my system from 5.4-RELEASE to 6.1-STABLE last week, and my
web server immediately stopped serving PHP pages, where I had no
problem doing so before. Instead of processing the PHP code on the
server and displaying the result in a browser, browsing to any page
containing PHP code resulted in a prompt to download the PHP page as a
/usr/ports/UPGRADING mentions that PHP has been streamlined and must
be recompiled to work with Apache and other packages. After
deinstalling, configuring (where applicable), and reinstalling PHP5,
php5-extensions, and apache2 to the latest versions, not only were PHP
files not being served, but my web server was toast:
"Forbidden You don't have permission to access / on this server."
I edited the new apache config file (now located in
/usr/local/etc/apache22/httpd.conf) with my system information,
including a DocumentRoot path. But when I started apache, I got some
very peculiar errors:
"Warning: DocumentRoot [/www/docs/dummy-host.example.com] does not exist
Warning: DocumentRoot [/www/docs/dummy-host2.example.com] does not exist"
Not only did I confirm beforehand that I had set the DocumentRoot
path, and that apache was using the correct config file... but these
"dummy" paths didn't exist in the config file! I learned eventually
that a new apache directive splits out virtual host directives to a
new include file (/usr/local/etc/apache22/extra/httpd-vhosts.conf).
Then I learned after getting a server warning ("NameVirtualHost *:80
has no VirtualHosts") that the syntax has been slightly modified, so
that the IP/port value of each VirtualHost specification must match
that of the NameVirtualHost directive (i.e., "NameVirtualHost *:80"
and "<VirtualHost *:80>").
Still having trouble though: my "main" site loads properly, but the
other virtual hosts aren't. Browsing to any virtual host address other
than the default results in either the wrong content or an error.
Here's what my httpd-vhosts.conf looks like:
ServerAlias SiteA.com *.SiteA.com
CustomLog /var/log/httpd-SiteA-access.log combined
ServerAlias SiteB.com *.SiteB.com
CustomLog /var/log/httpd-SiteB-access.log combined
So, what's happening is that SiteA works as expected, but browsing to
SiteB brings you to SiteA, or doesn't load at all ("403" error).
In addition, I'm back to my original problem, where PHP files are not
loading, and browsing to a PHP page prompts the user to download the
page as a file.
Any help on either the virtual hosts or the PHP download issue would
be greatly appreciated.
More information about the freebsd-questions