apache2配置django

apache2需要安装扩展

1
2
apt-get install libapache2-mod-wsgi-py3 # for python3
apt-get install libapache2-mod-wsgi # for python2

在httpd.conf启用

1
LoadModule wsgi_module modules/mod_wsgi.so

下面是我的配置

1
cat /etc/apache2/sites-available/school.conf
1
2
3
4
5
6
7
8
9
10
11
12
13
14
<virtualhost *:8001>
ServerName xxx.com
DocumentRoot /home/lc4t/web_py/school
Alias /static/ /home/lc4t/web_py/school/school/static/
# Alias /static/js/ /home/lc4t/web_py/school/school/static/js/
# Alias /static/css/ /home/lc4t/web_py/school/school/static/css/
WSGIScriptAlias / /home/lc4t/web_py/school/school/wsgi.py
<directory "/home/lc4t/web_py/school/school">
<files wsgi.py>
Require all granted
</files>
</directory>
</virtualhost>

然后a2ensite school.conf 启用它
注意这里用的8001端口 需要配置监听

还有一个主要的文件是wsgi.py
这个是会自己生成的:

1
2
3
4
5
6
7
8
9
import os
import sys
from django.core.wsgi import get_wsgi_application
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "school.settings")
sys.path.append('/home/lc4t/web_py/school')
application = get_wsgi_application()
# os.environ.setdefault("DJANGO_SETTINGS_MODULE", "settings")
# os.environ['LC_ALL']="en_US.UTF-8"

之后可能会出现一些小问题,注意看error.log就好
关于后台css丢失, 我的解决办法是直接复制admin到static里面

最近的文章

CentOS7/Firewall配置shadowsocks[Conoha]

¶shadowsocks 1234yum install -y python-setuptoolseasy_install pippip install shadowsocksvim /etc/shadowsocks/config.json 123456789&#123; "server": …

于  CentOS, Firewall, Linux, shadowsocks 继续阅读
更早的文章

nsctf2015-writeup

¶re1 ASCII找到flag:{NSCTF_md5065ca&gt;01??ab7e0f4&gt;&gt;a701c&gt;cd17340} 异或0x7 712df97688fe0b7a399f076d9dc60437 ¶re2 找字符串 flag:{NSCTF_md57e0cad17016b …

于  NSCTF, writeup 继续阅读