1

I'm setting up a windows server 2019 with apache 2.4 and PHP 5.6.

I was able to load the phpinfo in the browser with localhost.

I am trying to get the sites to open up in an htdocs folder on another drive (D:) using an alias that, according to our networking team is quoting, "DNS is set up correctly pointing to newprod.company.name.com", with "newprod" being the acutal alias.

In my httpd.conf file, I have the following settings:

Define SRVROOT "c:/Apache24"

ServerRoot "${SRVROOT}"

Listen 80

The above is pointing at the C: drive where Apache24 is located.

LoadModule rewrite_module modules/mod_rewrite.so

I have the above module uncommented. There are several other modules that have been uncommented, but the one above seems to be one of the main modules that, according to various Apache setup tutorials, is the main module.

ServerAdmin my.company@company.com

ServerName newprod.company.name.com:80
ServerName Localhost:80

According to various tutorials, the above seems to be accurate. I have compared my previous httpd.conf files, and they work using very similar configurations, including Localhost:80.

DocumentRoot "D:/htdocs"
<Directory "D:/htdocs">
  Options Indexes FollowSymLinks
  AllowOverride None
  Require all granted
</Directory>

The main part to focus on above the D:/htdocs. This is where I figured the sites should be opening from, as well as opening using the alias.

<IfModule dir_module>
  DirectoryIndex index.php index.html
</IfModule>

The above is typical for an Apache setup, per various tutorials.

<VirtualHost newprod.company.name.com:80>
  ServerName newprod.company.name.com
  Redirect / http://newprod.company.name.com/
</VirtualHost>

I use the above on another server (with a different alias) without any issues.

PHPIniDir "C:/PHP5.6"
AddHandler application/x-httpd-php .php
LoadModule php5_module "C:/PHP5.6/php5apache2_4.dll"

Then finally, the above is to ensure Apache will read PHP.

I have two other servers that are loading the sites with their own aliases with no problem. I literally went line for line trying to ensure everything matches. The only things that don't match is the PHP configurations at the bottom of the file. My other two servers are using PHP 7.4, while the problem server is using PHP 5.6.

Why aren't my sites loading using the alias I provided?

John Beasley
  • 2,577
  • 9
  • 43
  • 89
  • What happens when you try? – aynber Nov 06 '20 at 16:45
  • @anyber - I think you are referring to when I try loading the site. If so, I get a "This site can't be reached" in the browser. – John Beasley Nov 06 '20 at 16:48
  • If you open up the terminal and type `ping newprod.company.name.com`, does it point to the correct IP address? – aynber Nov 06 '20 at 16:49
  • 1
    Won't that VirtualHost create an infinite loop? You've configured it for `newprod.company.name.com` but then in the end, you have a redirect to the same hostname? – M. Eriksson Nov 06 '20 at 16:49
  • @anyber - the ping returns Packets: Sent = 4, Received = 4, Lost = 0 (0% loss) – John Beasley Nov 06 '20 at 16:50
  • 1
    When you pinged the host, did you check that the IP (that the ping command writes out after it resolved the hostname) is the servers IP? – M. Eriksson Nov 06 '20 at 16:51
  • @MagnusEriksson - I'm gonna be honest, I'm not sure why that VirtualHost piece is being used. However, it's being used on the other two servers without issue. – John Beasley Nov 06 '20 at 16:51
  • Agree with @MagnusEriksson This virtual host will definitely create an infinity loop. Try to remove it – Julien Bourdic Nov 06 '20 at 16:53
  • @MagnusEriksson - I am verifying the IP now. Will revert upon confirmation. – John Beasley Nov 06 '20 at 16:53
  • @JulienBourdic - Will do. Unsure why it has never happened before. Please note, after removing the virtual host, the site still does not load. – John Beasley Nov 06 '20 at 16:54
  • My guess is that on the other servers where you have that virtualhost block and it works, it either redirects from http (port 80) to https (port 443) or from an old hostname to a new hostname. Redirecting to the same hostname on the same port doesn't make sense since after the redirect, you'll get an identical request, which will just end up being redirected again and again and again until the server/client says stop. – M. Eriksson Nov 06 '20 at 16:56
  • Probably because the domain wasn't registered in the DNS on the other servers ? Or because the block redirected to https:// (so 443 and not 80 anymore) – Julien Bourdic Nov 06 '20 at 16:57
  • @MagnusEriksson - confirmed the IP is the correct IP. Thoughts? – John Beasley Nov 06 '20 at 17:04
  • I told you my thoughts in my last comment. That virtualhost block looks wrong. – M. Eriksson Nov 06 '20 at 17:06
  • @MagnusEriksson - Apologies. I did not see that comment. The virtualhost blocks have been remove, still no luck. – John Beasley Nov 06 '20 at 17:08
  • @MagnusEriksson - correction... It was the https. I updated it to http and now the site loads. – John Beasley Nov 06 '20 at 17:11
  • 1
    Try and change `ServerName Localhost:80` to `ServerAlias localhost`. Afaik, you can't have more than one servername, but you can add multiple aliases to it. Normally, I never configure the httpd.conf file directly but rather put all site specific configs (like servername, serveralias, document root etc) in a virtualhost. But that's just how I tend to do it. – M. Eriksson Nov 06 '20 at 17:11
  • "DNS is set up correctly pointing to newprod.company.name.com" - You're running apache on MS-Windows plumbed directly into the internet? And your IT dept tell you its all set up correctly????!!!!!! – symcbean Jan 11 '21 at 22:08
  • @symcbean - It's on an intranet behind a firewall. Does that make a difference? – John Beasley Jan 11 '21 at 22:16

1 Answers1

0

If you're using

ServerName newprod.company.name.com:80
ServerName Localhost:80

in main httpd.conf (or main apache config file), get rid of

ServerName Localhost:80

The vhost configuration

<VirtualHost newprod.company.name.com:80>
  ServerName newprod.company.name.com
  Redirect / http://newprod.company.name.com/
</VirtualHost>

is probably going to create a redirect loop: if that's all the configuration inside the virtualhost, get rid of it: it's useless.

Is port 80 on your apache server reachable from another pc? Are you able to telnet from a pc in the same lan on po 80 of apache server? Have you checked if the firewall is dropping the first syn packet?

Inc0
  • 789
  • 1
  • 4
  • 12