Apache restart history - apache

Can someone please assist me.
I am trying to find a log on an Ubuntu server that will show me a history of dates and times when Apache was restarted.
Ubuntu version: Ubuntu 10.04.3 LTS
Apache version: 2.2.14 (Ubuntu)
Thanks - Mike

apache usually logs to /var/log/apache2 - depending on what log rotation/cleaning you have going on there should at least be an access_log and an error_log (names may change depending on apache config). In each you should be able to see restart messages.

You could search for configured keyword in apache error logs:
### for centos/redhat:
egrep -irn 'configured' '/var/log/httpd/error_log'
### for ubunto:
egrep -irn 'configured' '/var/log/apache2/error_log'

When we start or restart the apache, we get the logs in /var/log/apache2/error_logs with the word caught SIGTERM, shutting down
So we can find the error_logs with word SIGTERM, will get if apache service start|restart

Related

How do I find out what version of Apache or nginx web server is used in ElasticBeanStalk?

Following is what I see in Elastic BeanStalk
https://i.stack.imgur.com/2hzlB.png
I'm going through Apache documentation to write Rewrite rules. But I'm confused which version I should read.
http://httpd.apache.org/docs/
Log in via SSH and run:
$ httpd -v
Server version: Apache/2.4.16 (Unix)
See also: eb ssh
If running Nginx, use:
$ nginx -v
Another way -- check out your logs and search for Apache. I'm using Django and I see Apache/2.4.37 (Amazon) mod_wsgi/3.5 Python/3.6.7. It appears a few times.
On SSH or Putty try first
httpd -v
if any result appears
Server version: Apache/***
that means you in Apache server.
Nginx -v
if any result similar to
Nginx version: nginx/1.14.0 (Ubuntu)
then you can decide Nginx* or Apache*
because those commands only run apache and Nginx as follows,
in my scenario I'm using nginx 1.14.0 it shows me an error
httpd -v
Command 'httpd' not found, did you mean:
command 'http' from snap http (1.0.0-1) command 'xttpd' from deb
xtide command 'http' from deb httpie
See 'snap info ' for additional versions.
and also try
sudo systemctl status nginx

How to switch between two Apache installations?

Some time ago I installed Apache 2.2.29 with this manual:
https://echo.co/blog/os-x-1010-yosemite-local-development-environment-apache-php-and-mysql-homebrew
into this directory:
/usr/local/Cellar/httpd22/2.2.29/bin/httpd
Yesterday I installed Apache 2.4.17 with this manual:
https://www.youtube.com/watch?v=hV52Vs4E1xs
into this directory:
/usr/local/apache2/bin/httpd
Terminal command
which httpd
shows me this:
Server version: Apache/2.2.29 (Unix)
is there any way to switch to 2.4.17?
(I'm on OS X 10.10.5)
Yes of course. Just specify the absolute path.
For example to stop Apache 2.2.9 use the following command:
/usr/local/Cellar/httpd22/2.2.29/bin/apachectl -k stop
Give it a few seconds or use 'ps' to check its finished shutting down and then use the following to start up the 2.4.17 instance:
/usr/local/apache2/bin/apachectl -k start
Note when you machine restarts it my revert to the old version depending what's in its start up scripts.
Also any config will be specific to each installation so you might find they don't point to the same DocumentRoot so don't display the same website.
You cannot run both under port 80 at the same time. However you could run one under port 80 and one under another port of you wanted both running at exactly the same time.

Unable to start httpd on OS X Mavericks

I upgraded to OS X Mavericks and I am trying to start the apache web server
I am using the command
sudo apachectl start
to start the server but I get the following error
(13)Permission denied: make_sock: could not bind to address [::]:80
(13)Permission denied: make_sock: could not bind to address 0.0.0.0:80
no listening sockets available, shutting down
Unable to open logs
With AMPPS or any other app, you can run it through Terminal:
Start
$ sudo /Applications/AMPPS/apache/bin/apachectl start
Stop
$ sudo /Applications/AMPPS/apache/bin/apachectl stop
had the same thing this morning, out of the blue..
I found that running :
sudo /Applications/AMPPS/apache/bin/apachectl start
at least gave me some info :
AH00544: httpd: bad group name administration
so I typed (in terminal)
groups
to see which groups were available and found that there is no administration group but there is admin group
so I went into httpd.conf and found the user/groups config section and changed accordingly
and -surprise!- apache started!
Here is what u can do.
Make sure the server is turned on with sudo ( root ) but I assume this is going just fine since u are using sudo in your start post.
The other way to solve this is to check in your
/etc/apache2/httpd.conf
And change the listen port from 80 into 8080 or anything greater than 1024
Official Bug Fix is here, so you can manage it from UI.
Also sudo apachectl start/stop is for apache bundled with Mac OS X.
Type the whole path as suggested by Daniel above.
Have a read of this blog post
It sounds like you're not seeing the same "silent terminating" thing, but maybe you have a similar problem, that with Maveriks superfluous "Listen 80" line in another config file will now trip up apache. So check if you have a config file under /etc/apache2/users , and also check VirtualHosts which maybe configured in /etc/apache2/extra/httpd-vhosts.conf (or try temporarily disabling these)
Another service is running on the port 80.
Check the service by execute this command:
sudo lsof -i :80
Stop the service before you run start the apachectl.

Can't connect to Apache server on RHEL6

The issue
Now, I am a complete n00b on Apache, and I could certainly use some help with my current issue. I have installed the httpd rpm's on 3 different systems (all Advantech computers, 1 Box PC, 1 Advanced TCA blade, 1 Compact PCI blade, and all have RHEL6 installed). I have configured Apache with files used earlier, on other installations. When I issue the command
# service httpd restart
All goes well and I get this output:
Stopping httpd: [ OK ]
Starting httpd: httpd: apr_sockaddr_info_get() failed for <PC_Name>
httpd: Could not reliably determine the server's fully qualified domain name, using 127.0.0.1 for ServerName
[ OK ]
Now, when I try to connect to the machine via Apache, I get the log-in screen asking for the username and password, as you would expect. However, it fails to log-in. When I look at the error_log in /var/log/httpd/, it shows this error message:
[Thu Sep 15 14:24:40 2011] [error] [client 192.168.10.175] (13)Permission denied: Could not open password file: /etc/shadow
[Thu Sep 15 14:24:40 2011] [error] [client 192.168.10.175] PAM: user 'root' - not authenticated: System error
It seems to me that this is either a configuration error, or it has something to do with permissions. Yet I can't seem to find out which. Another interesting fact is, that this only applies to the last two installations(Advanced TCA & Compact PCI), and not the first (Box PC), while all 3 installations are exactly the same.
Additional Info
The way I installed it was install httpd from yum,
# yum install httpd
Next install mod_auth_pam, which is needed by the configuration,
# yum install mod_auth_pam
Then I configured Apache with the files I got from previous installations (which basically is just replacing the configuration files from the standard Apache install), and after that I restarted the Apache service.
For this error "apr_sockaddr_info_get() failed"
You need to properly set your hostname.
hostname actual-non-expired-domain-name.com
Don't forget to set the name in your httpd.conf and in /etc/hosts as well.
I have been able to solve this by setting SELinux to allow Apache requests. This is done by issuing the following command:
semanage permissive -a http_t
Semanage is a utility from the policycoreutils-python package. This should come with the installation medium.

Monit on CentOS causes httpd.pid not to be created

The solution was to replace this line:
check process apache with pidfile /var/run/httpd.pid
With this line:
check process httpd with pidfile /var/run/httpd/httpd.pid
And I also removed the 'group apache'.
Original post:
After installing Monit on CentOS, and setting an alert for the Apache (httpd) service, the service no longer creates the /var/run/httpd.pid file.
The httpd service IS running properly.
On top of it, as if that's not enough, Monit reports the status of the service as: Execution failed
Naturally, the only way to restart such a service is by killing it, since the 'restart' script doesn't see any running process.
These are the contents of the /etc/monit.d/monitrc file:
set daemon 10
set logfile syslog facility log_daemon
set mailserver localhost
set mail-format { from: me#server.com }
set alert bugs#server.com
set httpd port 2812 and
# SSL ENABLE
# PEMFILE /var/certs/monit.pem
allow user:password
check process apache with pidfile /var/run/httpd.pid
group apache
start program = "/etc/init.d/httpd start"
stop program = "/etc/init.d/httpd stop"
if cpu is greater than 180% for 1 cycles then alert
if totalmem > 1200 MB for 2 cycles then restart
if children > 250 then restart
check process sshd with pidfile /var/run/sshd.pid
start program "/etc/init.d/sshd start"
stop program "/etc/init.d/sshd stop"
if failed port 22 protocol ssh for 5 cycles then restart
if 5 restarts within 25 cycles then timeout
Output of "service httpd restart":
Stopping httpd: [FAILED]
Starting httpd: (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
[FAILED]
Any help will be greatly appreciated.
Try to replace stop program with /usr/sbin/httpd -k stop. It work for me.
I had the same problem but /usr/sbin/httpd -k stop didn't seem to help since this still tries to look up the process id from the pid file.
I opted for stop program = "/usr/bin/killall httpd". I don't think this is very elegant (probably kills open requests) but it was the only way I could find to restart apache and have the pid file recreated by monit.
I think that monit is doing a restart as 'stop; start' and is not waiting for 'stop' to finish before starting a new process, and thus is deleting the pid file at an inappropriate time. At least, that's my conclusion after tinkering with all this.
I found a reference to someone who fixed this issue by making monit sleep after the 'stop' statement.
Personally, I found that replacing 'restart' with 'start' when the http server is down worked just fine.