Dedicated Server HTTPD Error - linux

Recently I edited some files on my dedicated server (CentOS 6 64 bit) and when I decided to restart httpd I received the following error:
Starting httpd: httpd: Could not reliably determine the server's fully qualified domain name, using localhost.localdomain for ServerName
Does anybody know how I can resolve this issue?

Look in /etc/httpd/conf/httpd.conf for ServerName. Change that:
ServerName www.yourwebserver.com:80
Restart httpd.

Check to make sure the hostname you are using is reverse mapped. Or that it's defined in DNS.

You need to change the /etc/hosts file.
It should be like :
127.0.0.1 yourservername.yourdomain yourservername
Please be sure that this line appears once.

Related

Apache http server fails to restart

We do frequent deployments using udeploy and there is a last step there to automatically restart apace http server using sudo ./apachectl -k restart.
But sometimes the server fails to restart with below error:-
(98)Address already in use: make_sock: could not bind to address [::]:80
(98)Address already in use: make_sock: could not bind to address 0.0.0.0:80
no listening sockets available, shutting down
Unable to open logs
Please note not all the times only sometimes. I verified everything with no duplicate Listen directives for port 80 in httpd conf files, no password prompt issues in ssl key files. I don't have root access to server so can't actually verify if there are any other processes that bind port 80 before main apache server starts. But is there anything else that could be causing the issue.
Any help or suggestions here would be greatly appreciated.
Cheers,
Ashley
Not sure of the timing, but perhaps add a second attempt to start when there is a failure and that might allow for enough time to free any resources which might be in use.

How to change phpldapadmin default port?

I am installing phpldapadmin in CentOS 6.5,the login address is:
http://localhost/phpldapadmin
The problem is the 80 port have been used by another program.So I need to modify the port,but how to? I have aready search Google,but get nothing. The result maybe:
http://localhost:81/phpldapadmin
Thank you!
you can just put config in /etc/httpd/conf.d/phpldapadmin.conf between tags:
<VirtualHost 127.0.0.1:81>
...
</VirtualHost>
This will cause this config will be available only on http://localhost:81

CHECK_NRPE: Error - Could not complete SSL handshake

I have NRPE daemon process running under xinetd on amazon ec2 instance and nagios server on my local machine.
The check_nrpe -H [amazon public IP] gives this error:
CHECK_NRPE: Error - Could not complete SSL handshake.
Both Nrpe are same versions. Both are compiled with this option:
./configure --with-ssl=/usr/bin/openssl --with-ssl-lib=/usr/lib/i386-linux-gnu/
"allowed host" entry contains my local IP address.
What could be the possible reason of this error now??
If you are running nrpe as a service, make sure you have this line in your nrpe.cfg on the client side:
# example 192. IP, yours will probably differ
allowed_hosts=127.0.0.1,192.168.1.100
You say that is done, however, if you are running nrpe under xinetd, make sure to edit the only_from directive in the file /etc/xinetd.d/nrpe.
Don't forget to restart the xinetd service:
service xinetd restart
To check if you have access to it at all attempt a simple telnet on the address:port, a ping or traceroute to see where it is blocking.
telnet IP port
ping IP
traceroute -p $port IP
Also check on the target server that the nrpe daemon is working properly.
netstat -at | grep nrpe
You also need to check the versions of OpenSSL installed on both servers, as I have seen this break checks on occasion with the SSL handshake!
check your /var/sys/system.log . In my case, it turned out my monitored IP was set to something else than the one I set in nrpe.cfg file. I don't know the cause of this change, though.
#jgritty was right.
you should edit nrpe.cfg and nrpe config files to allow your master nagios server's access:
vim /usr/local/nagios/etc/nrpe.cf
allowed_hosts=127.0.0.1,172.16.16.150
and
vim /etc/xinetd.d/nrpe
only_from= 127.0.0.1 172.16.16.150
That's somewhat of a catch-all error message for NRPE. Check your firewall rules and make sure that port is open. Also try disabling SELinux and seeing if that lets the connection through. It's likely not an SSL issue, but just an issue with the connection being refused.
It looks like you are running your Nagios server in a virtual machine on a host-only network. If this is so, this would stop any external access. Ensure that you have a NAT or Bridged Network available.
So many answers, none of them hit the reason why I ran into this issue.
It turns out that nagios has terrible cross-version support and this was caused by me having a version 2 "client" (machine being monitored) and a version 3 "server" (monitoring machine).
Once I upgraded the client to version 3, the problem went away and I could do a check_nrpe -H [client IP] without issues.
Note that I am not sure if client/server are the right terms with nagios, as in the case of an NRPE call, the server is really the machine being called, but I digress.
Make sure that you have restarted the Nagios Client Plugin as well.
I'm running nrpe using the xinetd service.
Make sure also (in addition to the above basic steps) that your nagios user is authenticating properly. In my case:
Jun 6 15:05:52 gse2 xinetd[33237]: **Unknown user: nagios**<br>[file=/etc/xinetd.d/nrpe] [line=9]
Jun 6 15:05:52 gse2 xinetd[33237]: Error parsing attribute user - DISABLING
SERVICE [file=/etc/xinetd.d/nrpe] [line=9]
Jun 6 15:05:52 gse2 xinetd[33237]: **Unknown group: nagios**<br>[file=/etc/xinetd.d/nrpe] [line=10]
Jun 6 15:05:52 gse2 xinetd[33237]: Error parsing attribute group - DISABLING
SERVICE [file=/etc/xinetd.d/nrpe] [line=10]
Jun 6 15:05:52 gse2 xinetd[33237]: Service nrpe missing attribute user - DISABLING
Was showing in the /var/log messages.
It escaped me at first, but then I did a check on ypbind service and found it was not started.
After starting ypbind, nagios user and group was authenticating properly, the error went away.
some edge cases restarting nagios-nrpe-server doesn't help, due to the fact that process was not killed or it was not properly restarted.
just kill it manually then, and start.
SSL handshake error msg.Beside the allow_host you should assign.
your nagios server is in a local lan with C type ip address such as 192.168.xxxx
when the target monitored server feedback the ssl msg to your local nagios server,the message should first comes to your public IP of your line,the message cannot across the public IP into your nagios server which ip is an internal one.
you need NAT to guide the SSL message from target server to inner nagios server.
Or you better use "GET" method which just get monitor message from the nagios client side,such as SNMP to fulfill the remote monitor of local resource of linux servers.
SSL need feedback in double direction.
Best Regards
For me setting the following in /etc/nagios/nrpe.cfg on Client worked:
dont_blame_nrpe=1
It's and ubuntu 16.04 machine.
For other possible problems, I recommend looking at nrpe logs. Here is good article for configuring logs.
If you are running Debian 9 then there is a known issue regarding this problem, caused by OpenSSL dropping support for the method NRPE uses to initiate anonymous SSL connections.
The issue seems to be fixed but the fix hasn't made it into the official packages, yet.
Currently there seems to be no secure work-around.
check configuration in /etc/xinetd.d/nrpe and verify the server IP. If it is showing only_from = 127.0.0.1 change it with Server IP .

linux centos 6.3 hostname (dhcppc4) assigned automatically

Linux terminal showing hostname dhcppc4 that i never configured. As per configuration files hostname must be localhost :
[root#dhcppc4 ~]# cat /etc/sysconfig/network
NETWORKING=yes
HOSTNAME=localhost.localdomain
[root#dhcppc4 ~]# cat /etc/hosts
127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4
::1 localhost localhost.localdomain localhost6 localhost6.localdomain6
Note : I attached a new monitor to my laptop.
Don't know how but sometimes terminal shows localhost as hostname.
what is dhcppc4? How to resolve the issue?
This question is not suitable for stackoverflow (this should be on serverfault i guess)
Anyway, DHCP server could even assign an hostname to your machine
Look here: RFC 1553 - DHCP
Maybe this is your case?
You are most assuredly allowed to edit the HOSTNAME line of that config' file you refer to in your question just fine.
It will not show up until you logout & back in again. You will also want to run /etc/init.d/rsyslogd restart (or whatever syslog daemon you are using) to make that name take effect in the log files.
You may or may not need to run a vi /etc/hosts to adjust the lines in there as you need for your specific applications. Most will be fine, but some are very very picky, like the otherwise very awesome software, Zimbra, for one example, wont work if those lines are not perfect. Asterisk could be another one that might require that file to be perfect match with your configuration.
You can or can not work with your DHCP server to set this, but most people dont, most edit the HOSTNAME and move on.
It is actually important, though, and do in fact resolve this, dont just leave it, as we sysadmins do not want to be typing mission critical commands at the BASH prompt on the wrong machine when all 6 of your servers all say "localhost".

httpd: Could not reliably determine the server's fully qualified domain name, using 127.0.0.1 for ServerName

I tried to restart my Apache server on CentOS 5.0 and got this message:
httpd: Could not reliably determine the server's fully qualified domain name, using 127.0.0.1 for ServerName
Here is the /etc/hosts file:
127.0.0.1 server4-245 server4-245.com localhost.localdomain localhost
::1 localhost6.localdomain6 localhost6
Here is the /etc/sysconfig/network file:
NETWORKING=yes
NETWORKING_IPV6=no
HOSTNAME=server4-245
I also have this in the Apache httpd.conf file:
ServerName localhost
However, I still get the first error message when I restart Apache.
If you don't have httpd.conf in folder /etc/apache2, you should have apache2.conf - simply add:
ServerName localhost
Then restart the apache2 service.
Your hosts file does not include a valid FQDN, nor is localhost an FQDN. An FQDN must include a hostname part, as well as a domain name part. For example, the following is a valid FQDN:
host.server4-245.com
Choose an FQDN and include it both in your /etc/hosts file on both the IPv4 and IPv6 addresses you are using (in your case, localhost or 127.0.0.1), and change your ServerName in your httpd configuration to match.
/etc/hosts:
127.0.0.1 localhost.localdomain localhost host.server4-245.com
::1 localhost.localdomain localhost host.server4-245.com
httpd.conf:
ServerName host.server4-245.com
After the initial install of Apache server, I got the following error while restarting the Apache service on Ubuntu 12.04 (Precise Pangolin)
The solution is really simple. Just add the ServerName directive to /etc/apache2/httpd.conf:
sudo nano /etc/apache2/httpd.conf
Add: ServerName localhost
Finally restart the Apache server:
sudo /etc/init.d/apache2 restart
Make sure you're editing the right httpd.conf file, then the error about unreliable server's domain name should be gone (this is the most common mistake).
To locate your httpd.conf Apache configuration file, run:
apachectl -t -D DUMP_INCLUDES
Then edit the file and uncomment or change ServerName line into:
ServerName localhost
Then restart your apache by: sudo apachectl restart
So while this is answered and accepted it still came up as a top search result and the answers though laid out (after lots of research) left me scratching my head and digging a lot further. So here's a quick layout of how I resolved the issue.
Assuming my server is myserver.myhome.com and my static IP address is 192.168.1.150:
Edit the hosts file
$ sudo nano -w /etc/hosts
127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4
127.0.0.1 myserver.myhome.com myserver
192.168.1.150 myserver.myhome.com myserver
::1 localhost localhost.localdomain localhost6 localhost6.localdomain6
::1 myserver.myhome.com myserver
Edit httpd.conf
$ sudo nano -w /etc/apache2/httpd.conf
ServerName myserver.myhome.com
Edit network
$ sudo nano -w /etc/sysconfig/network HOSTNAME=myserver.myhome.com
Verify
$ hostname
(output) myserver.myhome.com
$ hostname -f
(output) myserver.myhome.com
Restart Apache
$ sudo /etc/init.d/apache2 restart
It appeared the difference was including myserver.myhome.com to both the 127.0.0.1 as well as the static IP address 192.168.1.150 in the hosts file. The same on Ubuntu Server and CentOS.
In httpd.conf, search for "ServerName". It's usually commented out by default on Mac. Just uncomment it and fill it in. Make sure you also have the name/ip combo set in /etc/hosts.
In the Apache httpd.conf file:
ServerName: 127.0.0.1
There are two ways to resolve this error:
Include /etc/apache2/httpd.conf
Add the above line in file /etc/apache2/apache2.conf
Add this line at the end of the file /etc/apache2/apache2.conf:
ServerName localhost
I've resolved the fully qualified domain name message on different occasions by adding my server hostname to the /etc/apache2/httpd.conf file and to the /etc/apache2/apache2.conf file.
Type hostname -f in your terminal. This query will return your hostname.
Then edit the /etc/apache2/httpd.conf file (or create it if it does not exist for some reason) and add ServerName <your_hostname>.
Alternatively, I have also been able to eliminate the message by adding ServerName <your_hostname> to the /etc/apache2/apache2.conf file.
If all goes well, when you restart Apache, the message will be gone.
Most answers suggest to just add ServerName localhost to /etc/apache2/apache2.conf.
But quoting Apache documentation :
The presence of this error message also indicates that Apache httpd was unable to obtain a fully-qualified hostname by doing a reverse lookup on your server's IP address. While the above instructions will get rid of the warning in any case, it is also a good idea to fix your name resolution so that this reverse mapping works.
Therefore adding such a line to /etc/hosts is probably a more robust solution :
192.0.2.0 foobar.example.com foobar
where 192.0.2.0 is the static IP address of the server named foobar within the example.com domain.
One can check the FQDN e.g. with
hostname -A
(shortcut for hostname --all-fqdn).
Turns out that I had this problem and it was because I used "tabs" to indent lines instead of spaces. Just posting, in case it helps anyone.
If you've edited /etc/apache2/httpd.conf with the ServerName localhost you may be editing the wrong file. All answers I found were pointing towards that standard httpd.conf. After some foraging, I found a good answer here.
To locate the right httpd.conf file use
apachectl -t -D DUMP_INCLUDES
I found mine was actually /usr/local/etc/httpd/httpd.conf.
Use your preferred editor to comment out the line (i.e. remove the # before) starting with ServerName, and replace the domain name for the appropriate one – local environments should work with
ServerName localhost
I hope this helps more people who may be stuck.

Resources