Created
October 5, 2014 23:30
-
-
Save fabiopiovam/476cc8f15916bcedb944 to your computer and use it in GitHub Desktop.
Deployment config of Django project using Apache
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import os, sys, site | |
# Add the site-packages of the chosen virtualenv to work with | |
site.addsitedir('PATH_TO_YOUR_PROJECT/venv/local/lib/python2.7/site-packages') | |
sys.path.append('PATH_TO_YOUR_PROJECT') | |
os.environ['DJANGO_SETTINGS_MODULE'] = 'PROJECT_NAME.settings' | |
os.environ['PYTHON_EGG_CACHE'] = 'PATH_TO_YOUR_PROJECT/.python-egg' | |
# Activate your virtual env | |
activate_env=os.path.expanduser("PATH_TO_YOUR_PROJECT/venv/bin/activate_this.py") | |
execfile(activate_env, dict(__file__=activate_env)) | |
import django.core.handlers.wsgi | |
from dj_static import Cling | |
application = Cling(django.core.handlers.wsgi.WSGIHandler()) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<VirtualHost *:80> | |
ServerAdmin admin@localhost | |
ServerName HOST_NAME | |
ServerAlias HOST_NAME *.HOST_NAME | |
DocumentRoot PATH_TO_YOUR_PROJECT | |
WSGIScriptAlias / PATH_TO_YOUR_PROJECT/MAIN_PROJECT/WSGI_FILE | |
<Directory PATH_TO_YOUR_PROJECT/MAIN_PROJECT> | |
Order allow,deny | |
Allow from all | |
</Directory> | |
Alias /media "PATH_TO_YOUR_PROJECT/media" | |
<Directory "PATH_TO_YOUR_PROJECT/media"> | |
Order allow,deny | |
Allow from all | |
</Directory> | |
<Location "/media"> | |
SetHandler None | |
</Location> | |
<Directory /> | |
Options FollowSymLinks | |
AllowOverride All | |
</Directory> | |
<Directory PATH_TO_YOUR_PROJECT> | |
Options Indexes FollowSymLinks MultiViews | |
AllowOverride None | |
Order allow,deny | |
allow from all | |
</Directory> | |
ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/ | |
<Directory "/usr/lib/cgi-bin"> | |
AllowOverride None | |
Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch | |
Order allow,deny | |
Allow from all | |
</Directory> | |
ErrorLog ${APACHE_LOG_DIR}/error.log | |
# Possible values include: debug, info, notice, warn, error, crit, | |
# alert, emerg. | |
LogLevel warn | |
CustomLog ${APACHE_LOG_DIR}/access.log combined | |
</VirtualHost> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<VirtualHost *:443> | |
ServerAdmin admin@localhost | |
ServerName HOST_NAME | |
ServerAlias HOST_NAME *.HOST_NAME | |
DocumentRoot PATH_TO_YOUR_PROJECT | |
WSGIScriptAlias / PATH_TO_YOUR_PROJECT/MAIN_PROJECT/WSGI_FILE | |
<Directory PATH_TO_YOUR_PROJECT/MAIN_PROJECT> | |
Order allow,deny | |
Allow from all | |
</Directory> | |
Alias /media "PATH_TO_YOUR_PROJECT/media" | |
<Directory "PATH_TO_YOUR_PROJECT/media"> | |
Order allow,deny | |
Allow from all | |
</Directory> | |
<Location "/media"> | |
SetHandler None | |
</Location> | |
<Directory /> | |
Options FollowSymLinks | |
AllowOverride All | |
</Directory> | |
<Directory PATH_TO_YOUR_PROJECT> | |
Options Indexes FollowSymLinks MultiViews | |
AllowOverride None | |
Order allow,deny | |
allow from all | |
</Directory> | |
ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/ | |
<Directory "/usr/lib/cgi-bin"> | |
AllowOverride None | |
Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch | |
Order allow,deny | |
Allow from all | |
</Directory> | |
ErrorLog ${APACHE_LOG_DIR}/error.log | |
# Possible values include: debug, info, notice, warn, error, crit, | |
# alert, emerg. | |
LogLevel warn | |
TransferLog ${APACHE_LOG_DIR}/access.log | |
SSLEngine on | |
SSLProtocol all -SSLv2 | |
SSLCipherSuite ALL:!ADH:!EXPORT:!SSLv2:RC4+RSA:+HIGH:+MEDIUM | |
SSLCertificateFile PATH_TO_CERTIFICATE/PROJECT_NAME.ssl.crt | |
SSLCertificateKeyFile PATH_TO_CERTIFICATE/PROJECT_NAME.ssl.key | |
SSLCertificateChainFile PATH_TO_CERTIFICATE/sub.class1.server.ca.pem | |
CustomLog ${APACHE_LOG_DIR}/ssl_request_log \ | |
"%t %h %{SSL_PROTOCOL}x %{SSL_CIPHER}x \"%r\" %b" | |
</VirtualHost> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment