项目部署的环境:
- 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 # 查看是否重启成功
- 参考链接地址: