0

我有一个在 CentOS 6 下运行的 Django 应用程序。我现在想添加一个 LSB 脚本以使其在启动时运行。我用谷歌搜索了这个话题,并没有真正找到任何有趣的东西。

你有什么建议吗?一些样品?一些文档?最佳实践?

问候

4

1 回答 1

0

阿帕奇方式:

  1. 安装 apache (sudo yum install httpd mod_wsgi)
  2. 如 DJango 文档中所述,配置 apache 以使用您的wsgi.py
  3. /sbin/service httpd 重启
  4. chkconfig httpd on #this 会导致 apache 在启动时启动
  5. 修改 settings.py 以将静态文件放入 /var/www/html/static 并将它们作为 /static
  6. mkdir /var/www/html/static
  7. sudo python manage.py collectstatic;sudo chown -R apache:apache /var/www/html/static
  8. 确保您的 wsgi.py 等可由 apache 读取
  9. 将网络浏览器指向http://yourserver.com/

Example django.conf 进入 /etc/httpd/conf.d

Alias /static/ /var/www/html/static/

WSGIScriptAlias / /path/to/mysite.com/mysite/wsgi.py
WSGIPythonPath /path/to/mysite.com

<Directory /path/to/mysite.com/mysite>
<Files wsgi.py>
Require all granted
</Files>
</Directory>
于 2014-10-10T14:54:28.000 回答