On Thu, Oct 24, 2024 at 1:42 PM Bill Wiest <bill.wi...@maglin.com> wrote:
> Hi Frank > > > > Thanks for responding. > > > > I can use any of > > > > http://localhost > > http://localhost/ > > http://localhost/index.html > > > > Each of these results in the web page (index,html in this case) being > deposited in Downloads. The index.html here is just: > > > > <html><body><h1>It works!</h1></body></html> > > > > I have a php file in the main server root (=localhost virtual host) called > 1.php. I runs phpinfo() with no issues > > > > http://localhost/1.php > > > > I have a few other PHP files there which all run fine. One, called 7.php > has a PHP block at the top which echoes the word “Hi” followed by a web > page. So, I assume there is no issue with my PHP setup, which I did not > alter from using versipn 2.4.12 of Apache – I just copied the PHP config > info from the .12 httpd.conf to the .62 httpd.conf, which includes the > addition of these AddTypes: > > > > AddType application/x-httpd-php .php .html .phtml .php3 .inc .conf > > AddType application/x-httpd-php-source .phps > > > > Do these need to be added into each virtual host definition file now? > > > > Thanks! > > > > > > *From:* Frank Gingras <thu...@apache.org> > *Sent:* October 24, 2024 12:26 PM > *To:* users@httpd.apache.org > *Subject:* Re: [users@httpd] Apache 2.4.62 placing web pages for virtual > hosts in Downloads folder > > > > *CAUTION:* This email originated from outside of the organization. Do not > click links or open attachments unless you recognize the sender and know > the content is safe. > > > > > > On Thu, Oct 24, 2024 at 12:09 PM Bill Wiest <bill.wi...@maglin.com> wrote: > > Hi there > > > > We currently use Apache 2.4.12 (Win32) with PHP 5.6.10 and need to > upgrade. I am working on getting Apache 2.4.62 running but have a problem > with the named virtual hosts which work fine under 2.4.12. The web pages > for these hosts are being placed into my Downloads folder instead of being > displayed. > > > > Troubleshooting: > > > > I had to make adjustments in my vhosts.conf file, removing some directives > in the <Directory> blocks which are no longer valid. > > It appears to be the case that the top Server root has to defined as > follows > > > > Define SRVROOT "c:/Apache24" > > > > ServerRoot "${SRVROOT}" > > > > This made me wonder if I needed to replace “c:/Apache” in DocumentRoot > specifications with “${SRVROOT}”, but this made no difference and the > Apache docs don’t indicate this is required. The web pages still get placed > in my Downloads folder. > > > > In 2.4.13 you have to use the NameVirtualHost directive in httpd.conf but > this has no effect in 2.4.62, as an error message reported, so I commented > it out. > > > > I tried extensive searching of Google, but the only thing I found that was > pertinent was this post > > > > > https://stackoverflow.com/questions/35057325/virtual-host-in-apache-downloads-the-file-instead-of-displaying-it > > > > which went unanswered. > > > > > > I have not found anything in the virtual host setup documentation, such as > > > > https://httpd.apache.org/docs/2.4/vhosts/examples.html > > > > which gives me any clues as to why the web pages are being downloaded > instead of displayed. > > > > > > I have sent an email to users-...@httpd.apache.org to find if there is > a FAQ that might reference this issue. The response was: > > > > “Hi! This is the ezmlm program. I'm managing the users@httpd.apache.org > mailing list. > > > > FAQ - Frequently asked questions of the users@httpd.apache.org list. > > > > None available yet.” > > > > I searched in Google's usenet for virtual host and apache 2.4.62 but > nothing related to this issue shows up. > > > > I tried to see if anything related to the subject “virtualhost” was > referenced in the archive for this list using this email and got this > response > > > > “-----Original Message----- > > From: users-h...@httpd.apache.org <users-h...@httpd.apache.org> > > Sent: October 23, 2024 2:48 PM > > To: Bill Wiest <bill.wi...@maglin.com> > > Subject: users Digest of: thread.virtualhost > > > > CAUTION: This email originated from outside of the organization. Do not > click links or open attachments unless you recognize the sender and know > the content is safe. > > > > Sorry, that message is not in the archive.” > > > > > > I even thought that perhaps the vhosts were not being set up at all, so I > tried to telnet to each on port 80. They exist! > > > > Each host is set up like the below in vhosts.conf. Some have a Serveralias > specified, otherwise identical to the below. > > > > <VirtualHost *:80> > > > > Servername localhost > > DocumentRoot "C:/Apache24/htdocs" > > > > <IfModule dir_module> > > DirectoryIndex index.phtml index.php index.html > > </IfModule> > > > > > > ErrorLog "c:/Apache24/logs/localhost_error.log" > > CustomLog "c:/Apache24/logs/localhost_access.log" combined > > > > <Directory "c:/Apache24/htdocs"> > > AllowOverride AuthConfig Options Limit > > Options None > > </Directory> > > > > </virtualHost> > > > > > > > > I’ve used Apache, on both Linux and Windows boxes for many years and have > never come across thi issue. Is it a bug in version 2.4.62? Am I just > brain-dead and missing something obvious? > > > > Any help is appreciated! > > > > Try requesting the html or php resource directly instead of ending the URI > with /, so you can narrow down which resource is being served with the > wrong content type in the response. > > > > If the culprit is the .php file, then your php interpreter isn't set up > properly. > > > > If the culprit is the .html file, then you need to use the AddType > directive to set the appropriate response. > You do NOT want to use the following directives for php, that's been outdated advice for over 20 years: AddType application/x-httpd-php .php .html .phtml .php3 .inc .conf AddType application/x-httpd-php-source .phps AddType is for *static* content, such as .html files, or .css files. Further, setting application/x-httpd-php for .html files is COMPLETELY wrong. Your html files should be fully static, and your php content should only reside in .php files. For php, use: https://httpd.apache.org/docs/2.4/mod/mod_mime.html#addhandler As for your static content, you should be using the mimes.type file first, and load it as such: TypesConfig /path/to/mimes.types.file You can add static entries, as such, if not part of the mimes.type file: AddType text/html .html I have a strong suspicion that you followed some very outdated or misleading tutorial. Don't do that.