我正在尝试使用django site here中的教程设置现有django项目的apache。我的操作系统是Ubuntu,一切都已安装(django apache2 libapache2-mod-wsgi)
我的conf文件
WSGIPythonPath /home/avlahop/development/django/rhombus2/rhombus/
<VirtualHost *:80>
ServerName myrhobmus.com
ServerAlias www.myrhombus.com
WSGIScriptAlias / /home/avlahop/development/django/rhombus2/rhombus/rhombus/wsgi.py
</VirtualHost>
创建conf文件后,我运行了a2ensite Ubuntu命令来启用该站点。
将WSGIPythonPath放在VirtualHost中会给我一个apache configtest失败 目录内的文件内部的文件(如示例中所述)给出了同样的失败
如果我访问www.myrhombus.com,我收到Google Chrome无法找到指定的地址讯息。
我做错了什么?互联网上的每个教程都使用旧的file.wsgi,而现在Django为你创建了这个教程,但它是一个扩展名为.py的python文件。我如何用apache服务我的django?如果我想在我自己的服务器上进行生产,你会在哪里放置django代码,你会在哪里放置模板文件?
编辑:我只获得/ page的索引。在权限方面我是否有与mysites位置有关的事情?你能给我一个django站点apache conf文件的工作示例吗?
答案 0 :(得分:0)
我使用Django 1.8并成功部署了我的项目Apache服务器。我像你一样遵循基本概念,并尽早启用Apache这个模块。
您可以在我的项目中构建此问题。Refer this question to understand project structure
--------------这是我的虚拟主机文件--------------------------- -------
if (convertView == null) {
LayoutInflater inflator = context.getLayoutInflater();
convertView = inflator.inflate(R.layout.row, null);
viewHolder = new ViewHolder();
viewHolder.text = (TextView) convertView.findViewById(R.id.label);
viewHolder.checkbox = (CheckBox) convertView.findViewById(R.id.check);
convertView.setTag(viewHolder);
convertView.setTag(R.id.label, viewHolder.text);
convertView.setTag(R.id.check, viewHolder.checkbox);
} else {
viewHolder = (ViewHolder) convertView.getTag();
}
viewHolder.checkbox.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
int getPosition = (Integer) buttonView.getTag(); // Here we get the position that we have set for the checkbox using setTag.
list.get(getPosition).setSelected(buttonView.isChecked()); // Set the value of checkbox to maintain its state.
}
});
----------------- wsgi.py --------------------------- ------------
WSGIPythonPath /home/umayanga/Desktop/view_site/serialKey_gen_site:/home/umayanga/Desktop/view_site/serialKey_gen_site/myvenv/lib/python3.4/site$
<VirtualHost *:80>
ServerAdmin admin@key.com
ServerName key.com
ServerAlias www.key.com
Alias /templates/ /home/umayanga/Desktop/view_site/serialKey_gen_site/templates/
Alias /static/ /home/umayanga/Desktop/view_site/serialKey_gen_site/static/
<Directory "/home/umayanga/Desktop/view_site/serialKey_gen_site/static">
Require all granted
</Directory>
<Directory "/home/umayanga/Desktop/view_site/serialKey_gen_site/templates">
Require all granted
</Directory>
WSGIScriptAlias / /home/umayanga/Desktop/view_site/serialKey_gen_site/mysite/wsgi.py
<Directory "/home/umayanga/Desktop/view_site/serialKey_gen_site/mysite">
Options Indexes FollowSymLinks
AllowOverride all
Require all granted
<Files wsgi.py>
Require all granted
</Files>
</Directory>
</VirtualHost>
我认为这会对你有所帮助。