我正在尝试使用apache2
将我的项目连接到服务器。
这是我在domainname.conf
文件中的代码:
<VirtualHost *:80>
LoadModule wsgi_module modules/mod_wsgi.so
WSGIScriptAlias / /var/www/<project>/<project>/wsgi.py
ServerName <domainname.com>
Alias /static /var/www/<project>/static/
<Directory /var/www/<project>/>
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
最后,我无法连接到服务器。有人请看看这个。
我认为你应该用你的IP地址替换*:80。还检查wsgi脚本。重新启动apache2后,请参阅日志文件(access.log和error.log)
<VirtualHost 132.123.123.2 >
....
WSGIDaemonProcess yourdomain.com
WSGIProcessGroup yourdomain.com
WSGIScriptAlias / /var/www/yourdomain.com/index.wsgi
....
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
和wsgi脚本这样的东西:
import os
import sys
import site
site.addsitedir('/user/lib/python3.4/site-packages')
sys.path.append('/home/path/to/project')
sys.path.append('/home/path/to/project/main_app')
os.environ['DJANGO_SETTINGS_MODULE'] = 'main_app.settings'
from django.core.wsgi import get_wsgi_application
application = get_wsgi_application()