logo
Apache Lounge
Webmasters

 

About Forum Index Downloads Search Register Log in RSS X


Keep Server Online

If you find the Apache Lounge, the downloads and overall help useful, please express your satisfaction with a donation.

or

Bitcoin

A donation makes a contribution towards the costs, the time and effort that's going in this site and building.

Thank You! Steffen

Your donations will help to keep this site alive and well, and continuing building binaries. Apache Lounge is not sponsored.
Post new topic   Forum Index -> Apache View previous topic :: View next topic
Reply to topic   Topic: I don't understand ServerName
Author
jcobban



Joined: 10 May 2015
Posts: 17
Location: canada, ottawa

PostPosted: Tue 04 Aug '15 1:21    Post subject: I don't understand ServerName Reply with quote

Please excuse my ignorance. I am not paid to administer a web site, I am paid to write web application code, but I need a sandbox in which to test that web code before I deploy it to the production site.

The production site has a DNS name, which is referenced in the ServerName parameter of the <VirtualHost> which then results in the DocumentRoot variable being set correctly. DocumentRoot is not being set correctly on my development server because I do not understand the interaction of the ServerName settings. Obviously my development system does not have the same domain name as the production system but I just do not understand any of the discussions of this issue that I have come across. I have finally got my development site to come up with the following VirtualHost definition. But DocumentRoot is not being set.

Code:
<VirtualHost *:80>
DocumentRoot /var/www/html/zipdandy.com
ServerName zipdandy.com
ServerAlias www.zipdandy.com zdmigrate.clevertech.biz
ErrorLog logs/zipdandy.com-error_log
CustomLog logs/zipdandy.com-access_log combined
        <Directory "/var/www/html/zipdandy.com">
                Options MultiViews SymLinksIfOwnerMatch
                AllowOverride Options FileInfo Limit Indexes
                Require all granted
        </Directory>
</VirtualHost>

When I use a phpinfo script on the production site the DocumentRoot is set to the value above, but when I use phpinfo on my development site it is set to /var/www/html. Unfortunately the authors of the PHP code I am trying to fix set every include to reference DocumentRoot so all of the includes fail. Apache tells me that it cannot determine the ServerName but not what to do about it.

There are hundreds of posts about this issue so obviously I am not the only person who finds the whole issue of setting the ServerName obscure and arcane. Why does it have to be so confusing? Why could not someone on the Apache team have come up with a straightforward way of doing this that is understandable to someone who is NOT a system administrator never mind an Apache software developer? For one thing if the code is so brain-dead that it cannot determine the server name then why doesn't it take a default and tell the user what that default is?

I have been trying to set up this sandbox for three weeks now and frankly I am becoming disenchanted with the brain trust that is responsible for Apache 2.4 and their demonstrable lack of sympathy for the innocents who actually have to run their product. Could they not generate even ONE error message that actually explains what has gone wrong in the product? Every problem in a configuration file is a "Syntax Error"! Even obsolete file names are "Syntax Errors"! These messages don't even identify which token on the rejected line is what is causing Apache to get upset. The innocent user is forced to try and fix things by trial and error with no guidance at all from the developers! The response to each issue is a requirement to read the hundreds of pages of documentation written by typical high-tech illiterates! In implementing each rejection the developer could have had the consideration to include a pointer to the relevant documentation from the error message. But nobody on the team apparently has that minimum of consideration for users.
Back to top
jcobban



Joined: 10 May 2015
Posts: 17
Location: canada, ottawa

PostPosted: Tue 04 Aug '15 3:31    Post subject: Re: I don't understand ServerName Reply with quote

jcobban wrote:
Please excuse my ignorance. I am not paid to administer a web site, I am paid to write web application code, but I need a sandbox in which to test that web code before I deploy it to the production site.

I am desperate. I have been trying to get this server up for three weeks now.

I have finally got my copy of the customer's web-site installed, but I cannot get the VirtualHost matching to work.

I put an entry in /etc/hosts for the IP address of the VirtualBox instance, labelling it centos7.
I put ServerName centos7 in httpd.conf
I put ServerName centos7 in the <VirtualHost>

The server starts up fine:

# systemctl -l status httpd.service
httpd.service - The Apache HTTP Server
Loaded: loaded (/usr/lib/systemd/system/httpd.service; enabled)
Active: active (running) since Sun 2015-08-02 04:46:01 EDT; 1h 30min ago
Process: 21975 ExecStop=/bin/kill -WINCH ${MAINPID} (code=exited, status=0/SUCCESS)
Process: 21823 ExecReload=/usr/sbin/httpd $OPTIONS -k graceful (code=exited, status=0/SUCCESS)
Main PID: 21979 (httpd)
Status: "Total requests: 6; Current requests/sec: 0; Current traffic: 0 B/sec"
CGroup: /system.slice/httpd.service
├─21979 /usr/sbin/httpd -DFOREGROUND
├─21981 /usr/sbin/httpd -DFOREGROUND
├─21982 /usr/sbin/httpd -DFOREGROUND
├─21983 /usr/sbin/httpd -DFOREGROUND
├─21984 /usr/sbin/httpd -DFOREGROUND
├─21985 /usr/sbin/httpd -DFOREGROUND
├─21986 /usr/sbin/httpd -DFOREGROUND
├─21987 /usr/sbin/httpd -DFOREGROUND
├─21988 /usr/sbin/httpd -DFOREGROUND
├─21989 /usr/sbin/httpd -DFOREGROUND
└─21990 /usr/sbin/httpd -DFOREGROUND

Aug 02 04:46:01 centos7server systemd[1]: Started The Apache HTTP Server.

And the host definition is:

<VirtualHost *:80>
DocumentRoot /var/www/html/zipdandy.com
ServerName centos7
ErrorLog logs/zipdandy.com-error_log
CustomLog logs/zipdandy.com-access_log combined
<Directory "/var/www/html/zipdandy.com">
Options MultiViews SymLinksIfOwnerMatch
AllowOverride Options FileInfo Limit Indexes
Require all granted
</Directory>
</VirtualHost>

<VirtualHost *:443>
DocumentRoot /var/www/html/zipdandy.com
ServerName centos7
ErrorLog logs/zipdandy.com-error_log
CustomLog logs/zipdandy.com-ssl-access_log combined
<Directory "/var/www/html/zipdandy.com">
Options MultiViews SymLinksIfOwnerMatch
AllowOverride Options FileInfo Limit Indexes
Require all granted
</Directory>
SSLEngine on
SSLCertificateFile /etc/pki/tls/certs/localhost.crt
SSLCertificateKeyFile /etc/pki/tls/private/localhost.key
</VirtualHost>

The phpinfo script confirms that the servername is centos7 but the DocumentRoot is set to /var/www/html , and the code for this website all depends upon DocumentRoot being /var/www/html/zipdandy.com. And it is /var/www/html that is displayed to the browser, not /var/www/html/zipdandy.com. I google the issue and all I find are hundreds of posts from other people who cannot for the life of them make sense of what exactly Apache wants them to do, which is a clear indicator to me that the documentation if not the implementation of Apache is a piece of garbage!

I hate the inconsiderate attitude of the development team for Apache 2.4.

They violated one of the cardinal rules of UNIX: "do not break working code", by failing to include backward compatibility with valid running 2.2 configuration files.

There is only ONE error message issued for any error in a configuration file "Syntax error on line x". They do not identify the token causing the problem. They do not identify the character position within the line. They do not describe the rule that is being broken. Even if the statement is an instance of LoadModule and the problem is that the named, but still syntactically valid, file no longer exists because the developers decided to rename it or merge it with some other file the error message that is issued is "Syntax error on line x"!

And the primary response to any question about how to do something is a suggestion to read the hundreds of pages of documentation from beginning to end! That is just barely justifiable if your only audience is professional web-site administrators, but it is not! Most of the people who have to configure a web server have something quite different as their primary job, and therefore the developers should show some consideration for making people waste time because of poorly designed and described code!
Back to top
jcobban



Joined: 10 May 2015
Posts: 17
Location: canada, ottawa

PostPosted: Tue 04 Aug '15 3:41    Post subject: Reply with quote

I do not know what any of this means, but the following is the output of "httpd -S":
Code:

VirtualHost configuration:
*:80                   is a NameVirtualHost
         default server support.zipdandy.com (/etc/httpd/vhost.d/000-support.zipdandy.com.conf:1)
         port 80 namevhost support.zipdandy.com (/etc/httpd/vhost.d/000-support.zipdandy.com.conf:1)
                 alias support1.zipdandy.com
         port 80 namevhost support.zipdandy.com (/etc/httpd/vhost.d/000-support.zipdandy.com.conf:1)
                 alias support1.zipdandy.com
         port 80 namevhost centos7 (/etc/httpd/vhost.d/001-zipdandy.com.conf:1)
         port 80 namevhost centos7 (/etc/httpd/vhost.d/001-zipdandy.com.conf:1)
*:443                  is a NameVirtualHost
         default server centos7 (/etc/httpd/conf.d/ssl.conf:56)
         port 443 namevhost centos7 (/etc/httpd/conf.d/ssl.conf:56)
         port 443 namevhost centos7 (/etc/httpd/conf.d/ssl.conf:56)
         port 443 namevhost support.zipdandy.com (/etc/httpd/vhost.d/000-support.zipdandy.com.conf:13)
                 alias support1.zipdandy.com
         port 443 namevhost support.zipdandy.com (/etc/httpd/vhost.d/000-support.zipdandy.com.conf:13)
                 alias support1.zipdandy.com
         port 443 namevhost centos7 (/etc/httpd/vhost.d/001-zipdandy.com.conf:13)
         port 443 namevhost centos7 (/etc/httpd/vhost.d/001-zipdandy.com.conf:13)
ServerRoot: "/etc/httpd"
Main DocumentRoot: "/var/www/html"
Main ErrorLog: "/etc/httpd/logs/error_log"
Back to top
James Blond
Moderator


Joined: 19 Jan 2006
Posts: 7371
Location: Germany, Next to Hamburg

PostPosted: Wed 05 Aug '15 17:56    Post subject: Reply with quote

the output from httpd -S suggests that the syntax is correct.

If you add another vhost you have to add it to /etc/hosts too.

example

127.0.0.1 support.zipdandy.com
Back to top
jcobban



Joined: 10 May 2015
Posts: 17
Location: canada, ottawa

PostPosted: Thu 06 Aug '15 21:30    Post subject: Reply with quote

Thank you, but that doesn't make any difference. DocumentRoot is still not being set correctly.

This is really urgent I am already three weeks behind in delivering on this contract because I cannot get Apache to work.
Back to top
James Blond
Moderator


Joined: 19 Jan 2006
Posts: 7371
Location: Germany, Next to Hamburg

PostPosted: Fri 07 Aug '15 10:26    Post subject: Reply with quote

The output from httpd -S shows you which config file is for which domain and which port.
You have some on port 80 for http:// and some on port 443 for https.
Back to top
jcobban



Joined: 10 May 2015
Posts: 17
Location: canada, ottawa

PostPosted: Tue 11 Aug '15 3:35    Post subject: Reply with quote

Thank you. The output from httpd -S is crucial since it identifies exactly which lines in which configuration files were being applied. I was unaware that the default configuration files created when I installed LAMP included a default *:443 definition, primarily I suppose as a template and demonstrating the use of the self-signed certificate. Because that was processed before my definition of what to do for servername centos7 on port 443 it took effect. I had to comment out that definition before my imported definition would work.
Back to top


Reply to topic   Topic: I don't understand ServerName View previous topic :: View next topic
Post new topic   Forum Index -> Apache