Apache Common Problems and Solutions
Question: Why won’t Apache compile with my system’s cc?
Answer: If the server won’t compile on your system, it is probably due to one of the following causes:
The Configure script doesn’t recognize your system environment.
This might be either because it’s completely unknown or because the specific environment (include files, OS version, et cetera) isn’t explicitly handled. If this happens, you may need to port the server to your OS yourself.
Your system’s C compiler is garbage.
Some operating systems include a default C compiler that is either not ANSI C-compliant or suffers from other deficiencies. The usual recommendation in cases like this is to acquire, install, and use gcc.
Your include files may be confused.
In some cases, we have found that a compiler installation or system upgrade has left the C header files in an inconsistent state. Make sure that your include directory tree is in sync with the compiler and the operating system.
Your operating system or compiler may be out of revision.
Software vendors (including those that develop operating systems) issue new releases for a reason; sometimes to add functionality, but more often to fix bugs that have been discovered. Try upgrading your compiler and/or your operating system.
Question: Why do I get complaints about redefinition of “struct iovec” when compiling under Linux?
Answer: This is a conflict between your C library includes and your kernel includes. You need to make sure that the versions of both are matched properly. There are two workarounds, either one will solve the problem:
Remove the definition of struct iovec from your C library includes. It is located in /usr/include/sys/uio.h. Or,
Add -DNO_WRITEV to the EXTRA_CFLAGS line in your Configuration and reconfigure/rebuild. This hurts performance and should only be used as a last resort.
Question: I’m using gcc and I get some compilation errors, what is wrong?
Answer: GCC parses your system header files and produces a modified subset which it uses for compiling. This behaviour ties GCC tightly to the version of your operating system. So, for example, if you were running IRIX 5.3 when you built GCC and then upgrade to IRIX 6.2 later, you will have to rebuild GCC. Similarly for Solaris 2.4, 2.5, or 2.5.1 when you upgrade to 2.6. Sometimes you can type “gcc -v” and it will tell you the version of the operating system it was built against.
If you fail to do this, then it is very likely that Apache will fail to build. One of the most common errors is with readv, writev, or uio.h. This is not a bug with Apache. You will need to re-install GCC.
Question: Why do I get “setgid: Invalid argument” at startup?
Answer: Your Group directive (probably in conf/httpd.conf) needs to name a group that actually exists in the /etc/group file (or your system’s equivalent). This problem is also frequently seen when a negative number is used in the Group directive (e.g., “Group #-1”). Using a group name — not group number — found in your system’s group database should solve this problem in all cases.
Question: Why am I getting “httpd: could not set socket option TCP_NODELAY” in my error log?
Answer: This message almost always indicates that the client disconnected before Apache reached the point of calling setsockopt() for the connection. It shouldn’t occur for more than about 1% of the requests your server handles, and it’s advisory only in any case.
Question: Why am I getting “connection reset by peer” in my error log?
Answer: This is a normal message and nothing about which to be alarmed. It simply means that the client canceled the connection before it had been completely set up – such as by the end-user pressing the “Stop” button. People’s patience being what it is, sites with response-time problems or slow network links may experiences this more than high-capacity ones or those with large pipes to the network.
Question: The errorlog says Apache dumped core, but where’s the dump file?
Answer: In Apache version 1.2, the error log message about dumped core includes the directory where the dump file should be located. However, many Unixes do not allow a process that has called setuid() to dump core for security reasons; the typical Apache setup has the server started as root to bind to port 80, after which it changes UIDs to a non-privileged user to serve requests.
Dealing with this is extremely operating system-specific, and may require rebuilding your system kernel. Consult your operating system documentation or vendor for more information about whether your system does this and how to bypass it. If there is a documented way of bypassing it, it is recommended that you bypass it only for the httpd server process if possible.
The canonical location for Apache’s core-dump files is the ServerRoot directory. As of Apache version 1.3, the location can be set via the CoreDumpDirectory directive to a different directory. Make sure that this directory is writable by the user the server runs as (as opposed to the user the server is started as).
Question: When I run it under Linux I get “shmget: function not found”, what should I do?
Answer: Your kernel has been built without SysV IPC support. You will have to rebuild the kernel with that support enabled (it’s under the “General Setup” submenu)
Question: Server hangs, or fails to start, and/or error log fills with “fcntl: F_SETLKW: No record locks available” or similar messages
Answer: These are symptoms of a fine locking problem, which usually means that the server is trying to use a synchronization file on an NFS filesystem.
Because of its parallel-operation model, the Apache Web server needs to provide some form of synchronization when accessing certain resources. One of these synchronization methods involves taking out locks on a file, which means that the filesystem whereon the lockfile resides must support locking. In many cases this means it can’t be kept on an NFS-mounted filesystem.
To cause the Web server to work around the NFS locking limitations, include a line such as the following in your server configuration files:
The directory should not be generally writable (e.g., don’t use /var/tmp).
How do I prevent Web access to a newly created domain, not yet resolving in the nameservers, from showing a listing of the directories of all domains on my server?
Place an index file in the DocumentRoot, /www/htdocs, of your server.
Does Apache on my server support Server Side Includes?
Yes. If you are having difficulty getting Server Side Includes (SSI’s) to work, add the following directives to /www/htdocs/.htaccess, creating that file if it does not exist:
Options +Indexes +Includes +ExecCGI
AddType application/x-httpd-cgi .cgi .pl