pavement

Apache, Configuring

From FreeBSDwiki
(Difference between revisions)
Jump to: navigation, search
(minor updates)
m (Reverted edits by DavidYoung (talk) to last revision by 200.38.30.168)
 
Line 107: Line 107:
 
[[Category: Ports and Packages]]
 
[[Category: Ports and Packages]]
 
[[Category: Configuring FreeBSD]]
 
[[Category: Configuring FreeBSD]]
 
== 15 Things You Should Give Up To Be Happy ==
 
 
Here is a list of 15 things which, if you give up on them, will make your life a lot easier and much, much happier. We hold on to so many things that cause us a great deal of pain, stress and suffering and instead of letting them all go, instead of allowing ourselves to be stress free and happy we cling on to them. Not anymore. Starting today we will give up on all those things that no longer serve us, and we will embrace change. Ready? Here we go:
 
 
[[http://goodvillenews.com/15-Things-You-Should-Give-Up-To-Be-Happy-r1EA1L.html 15 Things You Should Give Up To Be Happy]]
 
 
[[http://goodvillenews.com/wk.html GoodvilleNews.com - good, positive news, inspirational stories, articles]]
 
 
== Food People Power ==
 
 
For many years, people living in West Oakland had accepted eating unhealthy food as a way of life. That is, until a small group of people decided to change their community through Mandela MarketPlace, a non-profit that partners with local residents and rural, minority farmers to bring fresh agricultural produce to their local corner stores. Mandela MarketPlace now represents the difference that youth can make by challenging prevailing paradigms - you CAN select what you put in your body.
 
 
[[http://goodvillenews.com/Food-People-Power-NPElli.html Food People Power]]
 
 
[[http://goodvillenews.com/wk.html GoodvilleNews.com - good, positive news, inspirational stories, articles]]
 
 
== Dalai Lama Awarded 2012 Templeton Prize ==
 
 
The Dalai Lama, the Tibetan Buddhist spiritual leader whose long-standing engagement with multiple dimensions of science and with people far beyond his own religious traditions has made him an incomparable global voice for universal ethics, nonviolence, and harmony among world religions, has won the 2012 Templeton Prize.
 
 
[[http://goodvillenews.com/Dalai-Lama-Awarded-2012-Templeton-Prize-UttyfI.html Dalai Lama Awarded 2012 Templeton Prize]]
 
 
[[http://goodvillenews.com/wk.html GoodvilleNews.com - good, positive news, inspirational stories, articles]]
 
 
== Learning from the Wisdom of the Body ==
 
 
"Its amazing that our interpretation of experiences can generate intense visceral responses. The fact that we get goosebumps when we are inspired or afraid is one of many everyday indicators of just how deeply and intricately connected our minds and bodies are. In fact, the mind and body are an intertwined whole -- and there is great wisdom in the totality of our mind-body experience.
 
 
[[http://goodvillenews.com/Learning-from-the-Wisdom-of-the-Body-lJQFSo.html Learning from the Wisdom of the Body]]
 
 
[[http://goodvillenews.com/wk.html GoodvilleNews.com - good, positive news, inspirational stories, articles]]
 
 
== Meeting Michael ==
 
 
I was sitting at my desk today, looking out the window. I saw an old homeless man crossing the street, carrying a suitcase. I remembered the many times I had looked on from afar, feeling sorry for the homeless but doing nothing. I do give money to homeless people when I walk by, but never really interact with them, beside a smile.
 
 
[[http://goodvillenews.com/Meeting-Michael-YCkylF.html Meeting Michael]]
 
 
[[http://goodvillenews.com/wk.html GoodvilleNews.com - good, positive news, inspirational stories, articles]]
 

Latest revision as of 17:30, 25 August 2012

The Apache webserver's main configuration file is the httpd.conf file, which, if you've installed apache via ports and left it at defaults, will be found in /usr/local/etc and basic management is done via apachectl. If you prefer a GUI method of configuring and managing apache, look to webmin, but it is always advisable to know how to make the changes in the config file manually, since you may not be able to configure a specific setting or change via the webmin GUI.

Contents

[edit] Testing your configuration

When changing your config file, you may want to verify that the config file doesn't have any syntax problems:

apachectl configtest

Note that your config can be free of syntax errors and still broken -- in the same way you can use words correctly but say the wrong thing, being free of syntax errors doesn't mean your config is free of all errors. :)

[edit] Advanced Config and Optimization

If you've got a busy webserver, you'll soon find yourself looking at tweaking the Apache configuration to get more. As it is, most Apache installs are configured for testing / development vs production use.

[edit] MPM

By default, the httpd.conf has MPM (multi-processing modules) specific settings for all possible MPM choices. However, since this choice is made at compile-time, all but one of these MPM specific can be safely removed. The default (and usually the recommended) MPM is prefork.

Look for this section in your default httpd.conf:

##
## Server-Pool Size Regulation (MPM specific)
##

Read more about what an MPM is here: http://httpd.apache.org/docs/2.0/mpm.html.

[edit] Prefork

This is the default MPM and will work fine for most applications.

Default:

# prefork MPM
# StartServers: number of server processes to start
# MinSpareServers: minimum number of server processes which are kept spare
# MaxSpareServers: maximum number of server processes which are kept spare
# MaxClients: maximum number of server processes allowed to start
# MaxRequestsPerChild: maximum number of requests a server process serves
<IfModule prefork.c>
StartServers         5
MinSpareServers      5
MaxSpareServers     10
MaxClients         150
MaxRequestsPerChild  0
</IfModule>

Tweaked:

StartServers        10
MinSpareServers     10
MaxSpareServers     20
MaxClients         256
MaxRequestsPerChild 15000

StartServers, MinSpareServers, MaxSpareServers Creating a child process can be one of the most expensive in terms of CPU usage. Experiment with raising these values... as a start, you can probably safely double them and go from there. During traffic spikes, the server will have more available, idle child processes already created, which should help reduce load and keep the server busier serving content than spawning new servers when needed.

MaxClients With a busy website you may start reaching the default MaxClients, in which case everyone else is locked out. This error will show up in your error logs. Please note that there is a hard limit of 256 for this directive. Raising it requires setting a compile-time option and reinstalling. Still, 256 is much heftier than 150, so this may work out fine.

MaxRequestsPerChild Leaving this at 0 means a child never dies... once its created it will serve an unlimited number of requests until the main daemon kills it off during traffic lulls. Setting this to a high number has the benefit of periodically refreshing the pool of child processes and keeping memory leakage to a minimum.

[edit] Worker

In order to try out the worker MPM, you must re-install Apache2 with different MAKE_ARGS. For the brave, please see this page: Apache2 with the Worker MPM.

[edit] KeepAlives

The KeepAlives directive is enabled by default; to quote from the Apache documentation:

The Keep-Alive extension to HTTP/1.0 and the persistent connection feature of 
HTTP/1.1 provide long-lived HTTP sessions which allow multiple requests to be 
sent over the same TCP connection. In some cases this has been shown to result
in an almost 50% speedup in latency times for HTML documents with many images. 

Which is a good thing, if you want fast pages and have a strong server to handle it. If you're more concerned with availability than speed, or are running Apache on a less-than-stellar machine, you may get better performance (cpu/processor-wise, at least,) by turning KeepAlives off:

Default:

KeepAlives On

Tweaked:

KeepAlives Off

[edit] Include directive

Note: Do not confuse the Include directive with Option Includes, or the INCLUDES filter.

httpd.conf is a large file, and it can be difficult to find things in it to maintain custom settings. The Include directive is very useful for maintaining custom configurations in a modular way. It allows inclusion of other configuration files, adding the directives contained in them to the server configuration.

For example, you may want to add virtual hosts, or temporarily grant browser-access to a directory, to others on your LAN, or similar custom configuration directives. You can put directives for any context into a separate file and save the file as (for example) /usr/local/etc/{apacheversion}/includes/{custom_directive}.conf. This is especially useful for configuration options that change relatively frequently. Your custom configuration will be added to the server by adding the following line to httpd.conf (e.g. for apache2):

Include etc/apache2/includes/custom_directive.conf

Multiple Include lines are permitted. You can include everything in the directory by specifying the directory rather than a single file, but much more preferrably since Apache 2.0.41, you can use wildcards:

# Include etc/apache2/includes/        # everything in the directory will be included
  Include etc/apache2/includes/*.conf  # wildcards recommended rather than the whole directory

The file path specified may be an absolute path or relative to the ServerRoot directory (as above).

Example
('/usr/local/etc/apache2/includes/directories.conf')
Alias /samples /usr/home/storage/_Samples
<Directory "/usr/home/storage/_Samples">
   Options Indexes
   DirectoryIndex index.html index.php
   AllowOverride None
   Order allow,deny
   Allow from all
</Directory>
Personal tools