美文网首页
记一次已经线上项目转移到虚拟环境中运行的坑

记一次已经线上项目转移到虚拟环境中运行的坑

作者: ALLIN5 | 来源:发表于2019-08-06 13:55 被阅读0次

项目部署的环境:

  • django + ubuntu + virturalenv + python2.7 + apache + uwsgi

报错日志:

image.png

报错原因分析:

  • 新建的虚拟环境apache没有识别到;

解决方法:

  • 在apache 配置文件中虚拟环境的路径
sudo vim /etc/apache2/sites-enabled/BsmRel.conf
  • 配置文件内容如下:

WSGIPythonPath /home/baohe/.virtualenvs/pbsenv:/home/baohe/.virtualenvs/pbsenv/lib/python2.7/site-packages
WSGIPythonHome /home/baohe/.virtualenvs/pbsenv

"""
新增上面两行, 即为为虚拟环境的路径,
"""


<VirtualHost *:8000>
    ServerAdmin root@localhost
    ServerName bsmdev.ilinkin.com.cn

    DocumentRoot /srv/projects/bsm_rel/webapp/
    DirectoryIndex index.html index.htm index.php
        <Directory />
                Options FollowSymLinks
                AllowOverride None
                Order allow,deny
                allow from all
        </Directory>
        <Directory /srv/projects/bsm_rel/webapp/>
                Options Indexes FollowSymLinks MultiViews
                AllowOverride None
                Order allow,deny
                allow from all
        </Directory>

        CustomLog "|/usr/sbin/rotatelogs /data/Logs/bsm_rel/apache2/custom.%Y%m%d-%H%M%S.log 5M" combined
        ErrorLog "|/usr/sbin/rotatelogs /data/Logs/bsm_rel/apache2/error.%Y%m%d-%H%M%S.log 5M"

        LogLevel warn


        WSGIDaemonProcess bsm-rel-server processes=2 threads=16 maximum-requests=10000 python-path=/home/baohe/.virtualenvs/pbsenv/lib/python2.7/site-packages
        WSGIProcessGroup bsm-rel-server
        WSGIScriptAlias / /srv/projects/bsm_rel/webapp/stationclient/wsgi.py
</VirtualHost>

  • 重启apahce 服务 即可;
sudo service apache2 restart


sudo service apache2 status # 查看是否重启成功

  • 参考链接地址:

https://www.cnblogs.com/acer-haitao/p/8372416.html

http://www.huangwenchao.com.cn/2014/04/linux-deploy-2.html

相关文章

网友评论

      本文标题:记一次已经线上项目转移到虚拟环境中运行的坑

      本文链接:https://www.haomeiwen.com/subject/kkiidctx.html