The Funtoo Linux project has transitioned to "Hobby Mode" and this wiki is now read-only.
Difference between revisions of "Package:Apache"
Threesixes (talk | contribs) m (link to php) |
Threesixes (talk | contribs) m (add more goodies) |
||
Line 60: | Line 60: | ||
restart apache: | restart apache: | ||
<console>###i## rc-service apache2 restart</console> | <console>###i## rc-service apache2 restart</console> | ||
=== Enabling Security Module === | |||
<console>###i## emerge mod_security</console> | |||
{{file|name=/etc/conf.d/apache2|lang=|desc=enable mod_security|body= | |||
APACHE2_OPTS="... -D SECURITY"}} | |||
Control this module by editing these files, and restarting apache. | |||
<code>/etc/apache2/modules.d/79_modsecurity.conf</code> & <code>/etc/apache2/modules.d/80_modsecurity-crs.conf</code> | |||
== Service == | == Service == | ||
Revision as of 01:22, December 6, 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 which serves html/css/cgi/pl out of the box, and can serve other languages/frameworks via extensions.
The Apache Homepage says this of Apache:
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.
Install
Configure USE Flags
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
dev-lang/php
DSO / mod_php
To show which php versions are available for apache on your system:
root # eselect php list apache2 [1] php5.5 [2] php5.6 *
To select php5.5:
root # eselect php set apache2 php5.5
/etc/conf.d/apache2
- enable php dso module"... -D PHP5"
restart apache:
root # rc-service apache2 restart
Enabling Security Module
root # emerge mod_security
/etc/conf.d/apache2
- enable mod_securityAPACHE2_OPTS="... -D SECURITY"
Control this module by editing these files, and restarting apache.
/etc/apache2/modules.d/79_modsecurity.conf
& /etc/apache2/modules.d/80_modsecurity-crs.conf
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 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
/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 to http://127.0.0.1/test.html. You should see that the text from rewrite.html has been loaded.