Difference between pages "Template:Use" and "Package:Apache"
Line 1: | Line 1: | ||
;< | {{Ebuild | ||
|Summary=The Apache Web Server | |||
|CatPkg=www-servers/apache | |||
|Maintainer=polynomial-c@gentoo.org | |||
|Homepage=http://httpd.apache.org/ | |||
}} | |||
Apache is a powerful web server. apache serves html/css/cgi/pl out of the box, and other languages/frameworks via extensions. | |||
== Install == | |||
=== USE Flags === | |||
{| class="wikitable" style="margin: 1em auto;" width=80% | |||
! width="20%" | Use flag | |||
! width="10%" | Default | |||
! width="10%" | Recommended | |||
! width="60%" | Description | |||
|- | |||
| style="text-align: center;" | debug | |||
| style="text-align: center;" | No | |||
| style="text-align: center; background-color: red;" | No | |||
| style="text-align: center;" | Enable extra debug codepaths, like asserts and extra output. If you want to get meaningful backtraces see http://www.gentoo.org/proj/en/qa/backtraces.xml. | |||
|- | |||
| style="text-align: center;" | doc | |||
| style="text-align: center;" | No | |||
| style="text-align: center;" | | |||
| style="text-align: center;" | Add extra documentation (API, Javadoc, etc). It is recommended to enable per package instead of globally | |||
|- | |||
| style="text-align: center;" | ldap | |||
| style="text-align: center;" | No | |||
| style="text-align: center;" | | |||
| style="text-align: center;" | Add LDAP support (Lightweight Directory Access Protocol). | |||
|- | |||
| style="text-align: center;" | selinux | |||
| style="text-align: center;" | No | |||
| style="text-align: center; background-color: yellow" | No, unless selected by default. | |||
| style="text-align: center;" | !!internal use only!! Security Enhanced Linux support, this must be set by the selinux profile or breakage will occur | |||
|- | |||
| style="text-align: center;" | ssl | |||
| style="text-align: center;" | Yes | |||
| style="text-align: center;" | | |||
| style="text-align: center;" | Add support for Secure Socket Layer connections. | |||
|- | |||
| style="text-align: center;" | static | |||
| style="text-align: center;" | No | |||
| style="text-align: center;" | | |||
| style="text-align: center;" | !!do not set this during bootstrap!! Causes binaries to be statically linked instead of dynamically. | |||
|- | |||
| style="text-align: center;" | threads | |||
| style="text-align: center;" | No | |||
| style="text-align: center;" | | |||
| style="text-align: center;" | Add threads support for various packages. Usually pthreads. | |||
|} | |||
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 /var/www/localhost/htdocs/mediawiki/.htaccess & so on}} | |||
{{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 @ http://127.0.0.1/test.html the text from rewrite.html should be loaded. | |||
{{EbuildFooter}} |
Revision as of 02:06, September 16, 2014
Apache
We welcome improvements to this page. To edit this page, Create a Funtoo account. Then log in and then click here to edit this page. See our editing guidelines to becoming a wiki-editing pro.
Apache is a powerful web server. apache serves html/css/cgi/pl out of the box, and other languages/frameworks via extensions.
Install
USE Flags
Use flag | Default | Recommended | Description |
---|---|---|---|
debug | No | No | Enable extra debug codepaths, like asserts and extra output. If you want to get meaningful backtraces see http://www.gentoo.org/proj/en/qa/backtraces.xml. |
doc | No | Add extra documentation (API, Javadoc, etc). It is recommended to enable per package instead of globally | |
ldap | No | Add LDAP support (Lightweight Directory Access Protocol). | |
selinux | No | No, unless selected by default. | !!internal use only!! Security Enhanced Linux support, this must be set by the selinux profile or breakage will occur |
ssl | Yes | Add support for Secure Socket Layer connections. | |
static | No | !!do not set this during bootstrap!! Causes binaries to be statically linked instead of dynamically. | |
threads | No | Add threads support for various packages. Usually pthreads. |
If you want to enable any of the above use flags, create a file called /etc/portage/package.use/apache and add the options that you want to enable to it. For example:
/etc/portage/package.use/apache
www-servers/apache ssl threads
Emerge
After you have configured the USE flags that you want to build Apache with, emerge it:
root # emerge apache
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.
/etc/portage/make.conf
- set system wide apache2 useflagUSE="...,apache2,..."
Package
Apache's configuration files are broken up and located in several spots.
/etc/conf.d/apache2
/etc/apache2/httpd.conf
/etc/apache2/modules.d/*
/etc/apache2/vhosts.d/*
conf.d
controls the init script, adding things to it such as -D SECURITY & -D PHP5 will enable web application fire-walling & the php scripting language.
httpd.conf
controls how the server behaves, at the bottom of the file it has directives to include configuration files ending in .conf in /etc/apache2/modules.d
and /etc/apache2/vhosts.d
Service
To start apache immediately:
root # rc-service apache2 start
To start apache upon boot:
root # rc-update add apache2
mod_rewrite
What is mod_rewrite
?
The [ http://httpd.apache.org/docs/current/mod/mod_rewrite.html Apache documentation ] describes mod_rewrite
as:
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.
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.
If you want to test this for web applications such as mediawiki adjust the path to /var/www/localhost/htdocs/mediawiki/.htaccess & so on
/var/www/localhost/htdocs/.htaccess
- enable the rewrite engineRewriteEngine on
RewriteRule ^test.html$ rewrite.html
/var/www/localhost/htdocs/test.html
- set system wide apache2 useflagrewrite is not working
/var/www/localhost/htdocs/rewrite.html
- set system wide apache2 useflagrewrite is working
Then point your browser @ http://127.0.0.1/test.html the text from rewrite.html should be loaded.