Showing posts with label apache. Show all posts
Showing posts with label apache. Show all posts

Tuesday, March 08, 2011

Use mod_dumpio, mod_logio in Apache server

Mod_dumpio and mod_logio enables the logging for http request/response and the size of the request/resposne.
However, they'll not be configured by default installation procedures.

Here are steps to use them:

1. download the apache source files, and upload it to linux server.
2. go to existing apache bin directory, run the following commands:
sudo ./apxs -c /tmp/apache/httpd-2.0.64/modules/loggers/mod_logio.c

sudo ./apxs -i -a -n mod_logio /tmp/apache/httpd-2.0.64/modules/loggers/mod_logio.la

3. change the httpd.conf file and make sure the module is loaded and the logging format is changed.

Thursday, April 12, 2007

Reload httpd.conf in Apache http server

Before reloading the httpd.conf file, you'd better use "apachectl configtest" to check if the conf file is valid.
According to "man apachectl":
apachectl restart - Restarts the Apache daemon by sending it a SIGHUP. If the daemon is not running, it is started. This command automatically checks the configuration files via configtest before initiating the restart to make sure Apache doesn't die.
apachectl graceful - Gracefully restarts the Apache daemon by sending it a SIGUSR1. If the daemon is not running, it is started. This differs from a normal restart in that currently open connections are not aborted. A side effect is that old log files will not be closed immediately. This means that if used in a log rotation script, a substantial delay may be necessary to ensure that the old log files are closed before processing them. This command automatically checks the configuration files via configtest before initiating the restart to make sure Apache doesn't die.
The 'graceful' would only be required if you are updating an active in-service machine and you do not want to interupt active connections.

Thursday, February 01, 2007

PHP Apache tips

(1) How to log errors in PHP instead of displaying them on the page?
Use the following lines in php.ini:
; Print out errors (as a part of the output).
information.display_errors = off
; Even when display_errors is on, errors that occur during PHP's startup; debugging.display_startup_errors = Off
; Log errors into a log file (server-specific log, stderr, or error_log (below));
sites.log_errors = On
; Set maximum length of log_errors.
log_errors_max_len = 1024
; Do not log repeated messages.
ignore_repeated_errors = Off
; Ignore source of message when ignoring repeated messages.
ignore_repeated_source = Off
; Log errors to specified file.
error_log = "logs/errors.log"
(2) How to find backend SQL errors?
Set the following line in php.ini:
; Trace mode. When trace_mode is active (=On), warnings for table/index scans and SQL-Errors will be displayed.
mysql.trace_mode = On

(3) How to avoid exposing index structures for a folder?
Set the following lines in httpd.conf:
## DirectoryIndex: sets the file that Apache will serve if a directory is requested.

DirectoryIndex index.php

In such a way, request for a directory will be redirected to the file "index.php".
(4) How to use logging in Apache server?
Use the following 2 settings:
## ErrorLog: The location of the error log file.
ErrorLog logs/error.log
## LogLevel: Possible values include: debug, info, notice, warn, error, crit, alert, emerg.

LogLevel warn
(5) How to do directory-level access configuration for Apache Http Server?
Here's an example:

Options Indexes FollowSymLinks
AllowOverride None
Order allow,deny
Allow from all

Details can be found in http://httpd.apache.org/docs/2.2/mod/core.html#options .