Apache
Table of contents
Installation
Since a good while back I have been using FreeBSD ports for installing Apache 2.2 - because it just works!I usually also install these ports:
databases/p5-DBD-mysql50 mail/p5-Mail-CheckUser www/p5-libapreq2 && make (WAS: www/libapreq2 && make WITH_MODPERL2=1) www/p5-CGI.pm www/p5-MasonX-Request-WithApacheSession
And a few not found in ports, installed via "perl -MCPAN -e shell":
Time::Format
But if you desire a manual configuration...
Configure options for Apache 2.2.x:
./configure \ --prefix=/usr/local/www22 \ --enable-ssl \ --with-ssl=/usr/local \ --enable-expires \ --enable-headers \ --enable-usertrack \ --enable-unique-id \ --enable-vhost-alias \ --enable-rewrite \ --enable-so
If you don't have httpaccept loaded in your kernel - please take a look at these options:
<IfDefine NOHTTPACCEPT> AcceptFilter http none AcceptFilter https none </IfDefine>
Also see FreeBSD for optional kernel options (recommended).
Table of contents
SSL certificate (self-signed)
How to generate a self signed SSL certificate without pass phrase:openssl genrsa -out server.key openssl req -new -nodes -key server.key -out server.csr openssl x509 -req -days 365 -in server.csr -signkey server.key -out server.crt
Generate a SSL certificate
Create key
With file encryptionopenssl genrsa -des3 -out domain.key 2048
Without file encryption
openssl genrsa -out domain.key 2048
Create request
openssl req -new -key domain.key -out domain.csr
Create key and request in one go
openssl req -new -newkey rsa:2048 -nodes -keyout server.key -out server.csr
Use SSL certificate
Inside your VirtualHost put thisSSLEngine on
SSLCipherSuite ALL:!ADH:!EXPORT56:RC4+RSA:+HIGH:+MEDIUM:+LOW:+SSLv2:+EXP:+eNULL
BrowserMatch ".*MSIE.*" nokeepalive ssl-unclean-shutdown downgrade-1.0 force-response-1.0
CustomLog "/var/log/httpd-ssl_request.log" "%t %h %{SSL_PROTOCOL}x %{SSL_CIPHER}x \"%r\" %b"
SSLCertificateFile "/usr/local/etc/apache22/ssl/domain.crt"
SSLCertificateKeyFile "/usr/local/etc/apache22/ssl/domain.key"Make sure these options are enabled
Normally these options can be included by including the file httpd-ssl.confListen 78.47.207.147:443 NameVirtualHost *:443 SSLStrictSNIVHostCheck off
Note: Using NameVirtualHost for SSL sites is only available from Apache 2.2.12 and above.
Hosting multiple Django sites in one virtual host
First, setup your virtual host<VirtualHost *:80>
...
DocumentRoot /home/sites/example/htdocs
<Location "/site1">
SetHandler python-program
PythonInterpreter site1
PythonHandler django.core.handlers.modpython
SetEnv DJANGO_SETTINGS_MODULE site1.settings
PythonOption django.root /site1
PythonDebug On
PythonPath "['/home/sites/example'] + sys.path"
</Location>
Alias /site1/media/ /home/sites/example/htdocs/site1/media/
<Location "/site2">
SetHandler python-program
PythonInterpreter site2
PythonHandler django.core.handlers.modpython
SetEnv DJANGO_SETTINGS_MODULE site2.settings
PythonOption django.root /site2
PythonDebug On
PythonPath "['/home/sites/example'] + sys.path"
</Location>
Alias /site2/media/ /home/sites/example/htdocs/site2/media/
</VirtualHost>Then, inside each settings.py remember to set
TIME_ZONE = 'Europe/Copenhagen' SITE_ID = 'X' SESSION_COOKIE_NAME = 'Y'
Where X is 1 and 2 respectively, and Y is site1 and site2.
If your media path is not working correctly, maybe try this alternative location
MEDIA_ROOT = '/home/sites/example/htdocs/media/siteX/' MEDIA_URL = '/media/siteX' ADMIN_MEDIA_PREFIX = '/media/siteX'
Hints
IndexOptions FancyIndexing VersionSort NameWidth=*
AddDefaultCharset On
