|
|
Line 1: |
Line 1: |
| {{Ebuild | | {{#vardefine:Next|{{#show:{{FULLPAGENAME}}|?Next in Series|link=none}}}} |
| |Summary=The Apache Web Server | | {{#if:{{#var:Next|}}|'''Read the next article in this series: [[{{#var:Next}}]]'''}} |
| |CatPkg=www-servers/apache | | {{Tip|[[Support Funtoo]] and help us grow! '''Donate $15 per month and get a free SSD-based [[Funtoo Hosting|Funtoo Virtual Container]].'''}} |
| |Maintainer=polynomial-c@gentoo.org | | </div><div class="col-xs-12 col-md-3">{{#vardefine:Summary|{{#show:{{FULLPAGENAME}}|?Summary}}}} |
| |Homepage=http://httpd.apache.org/
| | {{#vardefine:Author|{{#show:{{FULLPAGENAME}}|?Author|link=none}}}} |
| | {{#vardefine:Icon|{{#show:{{FULLPAGENAME}}|?Icon}}}} |
| | {{#if:{{#var:Author|}}|{{#widget:ArticleBio|body={{#show: {{#var:Author}} | ?Bio }}|user={{#var:Author|}}|icon_url={{#if:{{#var:Icon|}}|{{filepath:{{#sub:{{#var:Icon}}|5}}|80}}|http://www.gravatar.com/avatar/{{#show: {{FULLPAGENAME}} | ?Gravatar MD5}}/?s=80&d=retro&r=g}}}}}} |
| | <div class="bs-head" style="text-decoration: underline; margin-bottom: 15px;">Got Funtoo?</div> |
| | Have you installed Funtoo Linux yet? Discover the power of a from-source meta-distribution optimized for your hardware! See our [[Funtoo Linux Installation|installation instructions]] and [[Subarches|browse our CPU-optimized builds]]. |
| | <div class="bs-head" style="text-decoration: underline; margin-bottom: 15px;">More Articles</div> |
| | Browse all our Linux-related articles, below: |
| | {{#ask:[[Category:Articles]] |
| | |format=category |
| | |link=all |
| | |headers=show |
| | |searchlabel=... further results |
| | |columns=1 |
| }} | | }} |
| Apache is a powerful web server which serves html/css/cgi/pl out of the box, and can serve other languages/frameworks via extensions.
| | __NOEDITSECTION__ |
| | | </div></div></div> |
| The [http://httpd.apache.org/ Apache Homepage] says this of Apache:
| | [[Category:Articles]] |
| | |
| <blockquote>
| |
| The Apache HTTP Server Project is an effort to develop and maintain an open-source HTTP server for modern operating systems including UNIX and Windows NT. The goal of this project is to provide a secure, efficient and extensible server that provides HTTP services in sync with the current HTTP standards.
| |
| </blockquote> | |
| | |
| == Install ==
| |
| === Configure USE Flags ===
| |
| If you want to enable any of the above use flags, create a file called <tt>/etc/portage/package.use/apache</tt> and add the options that you want to enable to it. For example:
| |
| {{file|name=/etc/portage/package.use/apache|desc= |body=
| |
| www-servers/apache ssl threads
| |
| }}
| |
| | |
| === Emerge ===
| |
| After you have configured the USE flags that you want to build Apache with, emerge it:
| |
| <console>###i## emerge apache</console>
| |
| | |
| == Configuration ==
| |
| === System ===
| |
| Many packages have apache2 use flags. These use flags are often required for an application to be supported by Apache. Setting a system wide apache2 use flag is a good idea.
| |
| | |
| {{file|name=/etc/portage/make.conf|desc=set system wide apache2 useflag|body=
| |
| USE="...,apache2,..."
| |
| }}
| |
| | |
| === Package ===
| |
| Apache's configuration files are broken up and located in several spots.
| |
| *<code>/etc/conf.d/apache2</code>
| |
| *<code>/etc/apache2/httpd.conf</code>
| |
| *<code>/etc/apache2/modules.d/*</code>
| |
| *<code>/etc/apache2/vhosts.d/*</code>
| |
| | |
| <code>conf.d</code> controls the init script, adding things to it such as -D SECURITY & -D PHP5 will enable web application fire-walling & the php scripting language.
| |
| | |
| <code>httpd.conf</code> controls how the server behaves, at the bottom of the file it has directives to include configuration files ending in .conf in <code>/etc/apache2/modules.d</code> and <code>/etc/apache2/vhosts.d</code>
| |
| | |
| == Service ==
| |
| | |
| To start apache immediately:
| |
| <console>
| |
| ###i## rc-service apache2 start
| |
| </console>
| |
| | |
| To start apache upon boot:
| |
| <console>
| |
| ###i## rc-update add apache2
| |
| </console>
| |
| | |
| == mod_rewrite ==
| |
| === What is <code>mod_rewrite</code>? ===
| |
| The [http://httpd.apache.org/docs/current/mod/mod_rewrite.html Apache documentation] describes <code>mod_rewrite</code> as:
| |
| | |
| <blockquote>
| |
| The mod_rewrite module uses a rule-based rewriting engine, based on a PCRE regular-expression parser, to rewrite requested URLs on the fly. By default, mod_rewrite maps a URL to a filesystem path. However, it can also be used to redirect one URL to another URL, or to invoke an internal proxy fetch.
| |
| </blockquote>
| |
| | |
| === Setting it up ===
| |
| mod_rewrite has a reputation of being difficult to set up. mod_rewrite requires following symlinks & Order allow,deny (apache 2.2) or Require all granted (apache 2.4) is set. To test functionality of mod_rewrite we will need to make a few files.
| |
| | |
| {{fancynote|If you want to test this for web applications such as mediawiki adjust the path to <code>/var/www/localhost/htdocs/mediawiki/.htaccess</code>}}
| |
| | |
| {{file|name=/var/www/localhost/htdocs/.htaccess|desc=enable the rewrite engine|body=
| |
| RewriteEngine on
| |
| RewriteRule ^test.html$ rewrite.html
| |
| }}
| |
| | |
| {{file|name=/var/www/localhost/htdocs/test.html|desc=set system wide apache2 useflag|body=
| |
| rewrite is not working
| |
| }}
| |
| | |
| {{file|name=/var/www/localhost/htdocs/rewrite.html|desc=set system wide apache2 useflag|body=
| |
| rewrite is working
| |
| }}
| |
| | |
| Then point your browser to http://127.0.0.1/test.html. You should see that the text from rewrite.html has been loaded.
| |
| | |
| {{EbuildFooter}}
| |