Apache reload skipping vhost on error - apache

I have several vhost configured with there own conf file under conf.d. This works fine, but ever so often i have to make changes to one of the files and the reload apache. Is there a way where apache would skip that file if there is an error so that the other sites still goes up on a reload?
This is a prod site (and yes i should test all first, but that is not always practical).
It would be nice if I could change the file for domain1.conf do a service httpd restart and then if there is an error in the file that today would cause apache not to start at all it would simply skip that conf file and load start with all the others.
Hope this would work
Regards
Tore

This did the trick
apachectl configtest
https://serverfault.com/questions/774719/make-apache-reload-skipping-vhost-on-error

Related

Rsyslog - Monitor a custom log file

I am using ubuntu 14.04 and I have managed to use rsyslog to push my Apache error logs to Papertrail. I then moved onto monitor another log file and after a restart and commenting out the apache config lines, I still get apache logs being monitored!
Does rsyslog cache config files somewhere? I have restated rsyslog via sudo service rsyslog restart and /etc/init.d/rsyslog restart.
Here is my current config file that seems to be monitoring my apache error.log file even though it is commented out.
$ModLoad imfile
$InputFilePollInterval 10
# Apache Error file:
#$InputFileName /var/log/apache2/error.log
#$InputFileTag apache-error:
#$InputFileStateFile stat-apache-error
#$InputFileSeverity error
#$InputRunFileMonitor
# App Error files:
$InputFileName /var/www/html/application/logs/log.php
$InputFileTag apache-error:
$InputFileStateFile stat-apache-error
$InputFileSeverity error
$InputRunFileMonitor
When I comment out this whole file, the apache errors stop being monitored. I am very confused, any help appreciated.
I can't explain the symptom you described, but did notice another problem which may be related. The InputFileStateFile configuration flag is a filename where rsyslog keeps its current position in the target file (InputFileName). The state file (stat-apache-error) is not deleted when rsyslog stops, so rsyslog knows where to start sending.
Using the same state file for 2 different underlying files will probably make rsyslog start at the wrong place, since the offset from /var/log/apache2/error.log won't be correct for /var/www/html/application/logs/log.php. Either use a different state file or remove the stat-apache-error file when you enable the second config.

Is it possible to check a .htaccess file using the -t option of the apache2 command?

I've got a .htaccess file that I copied from one Apache HTTPD server and deployed onto another. Unfortunately, I foolishly didn't check the version of the destination server and just put the file in place; the site stopped working because it's Apache 2.4 and the file has 2.2 syntax. So I quickly reverted it to the previous version and hoped that nobody noticed!
Now, of course, I'm paranoid.
I tried copying the broken-on-2.4 version elsewhere and using apache2 -t .htaccess to find out what's wrong, but I get this error:
apache2: Could not open configuration file /etc/apache2/.htaccess: No such file or directory
If I supply the full path (i.e. apache2 -t /path/to/it/.htaccess) I get:
AH00534: apache2: Configuration error: No MPM loaded.
This error appears to be unrelated but I get the same error message and exit code (1) regardless of whether or not there's an error in the .htaccess file.
So my question is: can I use apache2 -t [...] to test a .htaccess file, and if not, what can I use instead (aside from the manual)? There is this site but it doesn't seem to allow me to say what version of Apache to check against.
I haven't found out how to do what I asked, but I have come up with a workaround.
I created a new directory on the server and put the incompatible .htaccess file in there. I then accessed the directory via my browser whilst tail -fing the error log (/var/log/apache2/error.log) to see what the problem was.

How do I find my httpd.conf file?

*Edit: Anyone who's using MAMP PRO on a Mac running Mac OS X Lion may find it helpful to know that I finally tracked down my httpd.conf file in my personal library at Application Support > appsolute > MAMP PRO > httpd.conf. The reason I couldn't find it with a normal search is that it's a hidden directory. To access it, open Finder, Choose Go > Go To Folder, then type in ~/Library After tracking it down, you may then discover that it's almost impossible to edit your httpd.conf file. ); *
This is a weird one. I'm using MAMP on a Mac and want to modify my httpd.conf file so it defaults my URL's to lower case. So I navigated to Applications > MAMP > conf > apache > httpd.conf and added this line of code:
RewriteMap tolower int:tolower
I then modified one of my .htaccess files accordingly, but nothing happened. (Yes, I restarted my servers.)
I then reopened my httpd.conf file and added this code, which I understand is supposed to display "verbose" messages in my log file:
LogLevel trace8
I then opened my log file # Application > MAMP > logs > apache_error.log. There's code associated with the web pages I most recently visited, but they're just generic messages - not "verbose" messages.
Someone who understands Apache far better than me told me this indicates that the httpd.conf file I modified isn't being used by my server or sites. In other words, there must be another httpd.conf file out there somewhere.
Sure enough, I typed httpd.conf into Apple's finder and found half a dozens files with that name. I don't know where they came from; I recently tried to install Drupal and Aqquia, so that might be where some of them originated.
Anyway, I added the code (including LogLevel trace8) to EVERY httpd.conf file, restarted my servers, and I STILL don't see any changes on my websites, and I still just see generic code in my log file.
I'm completely snowed. It looks like the httpd.conf file in my MAMP folder is out of the loop, yet the Apache log file in the same folder is being used...or can errors be written to more than one Apache log file at the same time?
If I rename the httpd.conf file in my MAMP folder and restart my servers, my sites display fine, further suggesting that this httpd.conf is outside the flow. Yet if I rename a file that sits beside it named mime.types, my web pages don't display.
Anyway, does anyone have any idea how I can figure out what's going on?
If not, then can you advise me on Plan B? If I can't find my httpd.conf file, then I'll have to abandon ship and just do it online. I've found the path to my online httpd.conf file. I don't know how to open online files, but I assume I can copy it to my computer with an ftp program, open it and modify it, then publish it online.
So here are my questions: Am I correct in understanding that I can safely add the code RewriteMap tolower int:tolower to my online httpd.conf file without affecting any of my websites UNTIL I also modify a .htaccess file(s)? And if I modify my online config file, do i have to restart the server, just as I do on my computer?
Thanks.
First, use the ps command to find the full path to the running Apache process:
$ ps ax | grep httpd
28 ?? Ss 3:01.99 /usr/sbin/httpd -D FOREGROUND
On this system, Apache is /usr/sbin/httpd.
Second, run that binary with the -V option to show its configuration. This should include the path to the config file.
$ /usr/sbin/httpd -V
...
Server compiled with....
..
-D SERVER_CONFIG_FILE="/private/etc/apache2/httpd.conf"
On this system, the running copy of Apache reads its config from /private/etc/apache2/httpd.conf.

Apache is running but not working

I am running a huge php-application on an ubuntu server, using apache2, php5, mysql.
Sometimes (approx. once a month) the page ist not reachable from the internet ("it's down").
The weird thing is, that service apache2 status says that apache is running.
The solution is always to restart apache using service apache2 restart and everything works fine again.
The server load is at a minimum and can't be part of the problem (I guess).
I know, this description is not as detailed as it should be, but I do not have more information.
Any suggestions about what could cause this problem are appreciated!
Disable Firewall or Antivirus and try again.
Change /etc/apache2/apache2.conf => change all AllowOverride all,
and make sure that /etc/apache2/sites-available/000.default.conf => verify the path of the Directory that you access.
assign the necessary permissions of the webroot directory for the domain.
chmod -R 755 /var/www/html/

Will this config error stop apache from restarting

I have a production website running apache on linux. There are all sorts of rules set up which I don't want to mess with.
I need to restart apache so I decided to do a configtest first to check that everything was ok.
My question is, will apache restart given this error?
>$ service httpd configtest
Syntax error on line 129 of /etc/httpd/conf.d/ssl.conf:
SSLCertificateFile: file '/etc/httpd/conf/ssl.crt/server.crt' does not exist or is empty
I didn't change the ssl.conf, I don't know who did, I don't know how to fix it. Apache is running fine now. Can I safely restart apache and expect it to come up? If there were more errors than this one would they show - or does configtest stop after the first error?
I think that Apache hangs on any error, specially syntax errors.