Apache

From Psygen Wiki
Jump to navigation Jump to search
The printable version is no longer supported and may have rendering errors. Please update your browser bookmarks and please use the default browser print function instead.

Command-line switches

httpd -V - Show compile settings (Will show the current MPM, among other things)

httpd -l - List compiled in modules

httpd -L - List available configuration directives

httpd -t -D DUMP_MODULES - Show all loaded modules

httpd -t - Run a syntax check on configuration files

httpd status - Show the current status


/scripts/rebuildhttpdconf - rebuild the httpd.conf file


EA4

apachectl status
apachectl fullstatus
apachectl restart

EA4 Config files

/etc/apache2/conf/httpd.conf

/etc/apache2/conf.d/includes/*


Profiles:

Stored in:
/etc/cpanel/ea4/profiles

Install an EA4 profile:
/usr/local/bin/ea_install_profile --install /etc/cpanel/ea4/profiles/cpanel/default.json (replace "default.json" with the name of the profile file you want to install.)

Directives

You can set the Apache directives in WHM, or here:
/usr/local/apache/conf/includes/pre_virtualhost_global.conf

Prefork Directives

ServerLimit
This directive sets the max number of child server processes the httpd parent process will fork. When using prefork with a DSO or CGI based PHP handler, this directive is important for controlling memory consumption on the server. The ServerLimit directive is common across prefork, worker and event.

MaxRequestWorkers
This directive limits the number of simultaneous request that can be served. Since each process can only serve a single request with prefork, this will usually be the same as ServerLimit. However, with prefork, ServerLimit can exceed MaxRequestWorkers but MaxRequestWorkers cannot exceed ServerLimit.

StartServers
This directive controls the number of child server processes created at start up. Generally, there is no need to adjust this directive as the MinSpareServers directive will cause child server processes to be created anyways.

MinSpareServers
This directive sets the minimum number of idle child server processes. With the pre-forking model we want to always have processes available for when a request comes in. Using MinSpareServers, we can decide how many of these spare processes we want at all times. This doesn't need much adjusting either.

MaxSpareServers
This directive sets the maximum number of idle child server processes. The parent process will kill off child processes if too many are idle. This will reduce resource usage when idle but doesn't provide any performance or optimization benefits.

MaxConnectionsPerChild
This directive limits how many request a child server process will handle before it is killed off. If this were set to 500, the child server process would serve 500 request and then be killed off regardless of the number of idle processes. The parent server would replace the child process if needed. The idea here is to reduce any memory leak problems with child server processes. Rather than bloating up like a Firefox process and never dying, this ensures that processes are regularly recycled. This setting really only needs adjustment if there are problem with the child processes using excessive amounts memory for no reason. Otherwise, it will reduce performance as it takes time for child processes to be restarted.

Worker Directives

ServerLimit
This directive sets the max number of child server processes the httpd parent process will fork. Sounds the same as prefork right? That is because it is. The difference is that each child processes is going to be made up of many threads with worker. So setting a ServerLimit of 16 won't limit Apache to 16 total connections.

ThreadsPerChild
This directive controls the number of threads created within each child server processes. Unlike child processes, threads are not dynamic. Each child process is created with however many threads you set ThreadsPerChild to. This isn't really an issue either as threads are going to consume more resources. This directive defaults to 25 and that tends to be a safe value to leave it at. Increasing it may decrease stability while decreasing it diminishes the benefits of a multi-threaded server.

MaxRequestWorkers
This directive limits the number of simultaneous request that can be served. This is no different than how MaxRequestWorkers operates with prefork. The important distinction is that MaxRequestWorkers and ServerLimit now have different effects.
ServerLimit * ThreadsPerChild = MaxRequestWorkers
MaxRequestWorks is going to equal our ServerLimit, or the total number of possible child servers, multiplied by ThreadsPerChild, or the number of threads within each of those child processes.

StartServers
This directive controls the number of child server processes created at start up. Like prefork, there is no need to adjust this directive as the MinSpareThreads directive will cause child server processes to be created anyways.

MinSpareThreads
This directive sets the minimum number of idle threads Apache will keep running to handle new request. Much like prefork, worker tries to keep threads available for connections at all times. Instead of counting child processes, worker will count the number of idle threads to determine if it needs to create new child processes. This doesn't need much adjusting either.

MaxSpareThreads
This directive sets the maximum number of idle threads Apache will keep running. If Apache finds there are too many idle threads, it will kill off child process. This doesn't need much adjusting either.

MaxConnectionsPerChild
This directive limits how many request a child server process will handle before it is killed off. It is going to work the same as it does with prefork.


Test Load

ab -n 100000 -c 200 http://localhost/ 1>& /dev/null & - generates test load on the server


Version

See: Software Versions to check the installed version.