Ubuntu server16.04.3,apache2.4.18,django2,python3.5,virtualenv部署问题

General_G 2017-12-10 05:12:46
最近学习django,第一次架站,具体配置信息如标题,按网上的教程部署如下:
apache2的默认网页在/var/www/html目录下,所以我在该目录下创建django工程,名为myweb,
修改setting.py中debug为False, allowed_host为‘*’
在/etc/apahce/site-available下新建sitename.conf, 内容为:
<VirtualHost *:80>
ServerName 192.168.1.111
ServerAlias 192.168.1.111
ServerAdmin 844364778@qq.com

DocumentRoot /var/www/html/myweb
#Alias /static/ /home/gf/DjangoProject/myblog

WSGIDaemonProcess myweb python-path=/var/www/html/myweb:/var/www/html/venu/lib/python3.5/site-packages
WSGIProcessGroup myweb
WSGIScriptAlias / /var/www/html/myweb/myweb/wsgi.py
<Directory /var/www/html/myweb/myweb>
<Files wsgi.py>
Require all granted
</Files>
</Directory>
</VirtualHost>
因为没有static和template文件,这两部分就没加进去,a2ensite sitename.conf并service apache2 restart后,访问后出现:
Internal Server Error
The server encountered an internal error or misconfiguration and was unable to complete your request.
Please contact the server administrator at 844364778@qq.com to inform them of the time this error occurred, and the actions you performed just before this error.
More information about this error may be available in the server error log.

查看error log信息为:
mod_wsgi (pid=6331): Call to 'site.addsitedir()' failed for '(null)', stopping.
[wsgi:error] [pid 6331:tid 3074562624] mod_wsgi (pid=6331): Call to 'site.addsitedir()' failed for '/var/www/html/venu/lib/python3.5/site-packages'.
[wsgi:error] [pid 6331:tid 3048786752] mod_wsgi (pid=6331): Call to 'site.addsitedir()' failed for '(null)', stopping.
[wsgi:error] [pid 6331:tid 3048786752] mod_wsgi (pid=6331): Call to 'site.addsitedir()' failed for '/var/www/html/venu/lib/python3.5/site-packages'.
[wsgi:error] [pid 6331:tid 3048786752] [remote 192.168.1.111:14007] mod_wsgi (pid=6331): Target WSGI script '/var/www/html/myweb/myweb/wsgi.py' cannot be loaded as Python module.
[wsgi:error] [pid 6331:tid 3048786752] [remote 192.168.1.111:14007] mod_wsgi (pid=6331): Exception occurred processing WSGI script '/var/www/html/myweb/myweb/wsgi.py'.
[pid 6331:tid 3048786752] [remote 192.168.1.111:14007] Traceback (most recent call last):
[wsgi:error] [pid 6331:tid 3048786752] [remote 192.168.1.111:14007] File "/var/www/html/myweb/myweb/wsgi.py", line 16, in <module>
[wsgi:error] [pid 6331:tid 3048786752] [remote 192.168.1.111:14007] application = get_wsgi_application()
[wsgi:error] [pid 6331:tid 3048786752] [remote 192.168.1.111:14007] File "/usr/local/lib/python3.5/dist-packages/django/core/wsgi.py", line 12, in get_wsgi_application
[wsgi:error] [pid 6331:tid 3048786752] [remote 192.168.1.111:14007] django.setup(set_prefix=False)
[wsgi:error] [pid 6331:tid 3048786752] [remote 192.168.1.111:14007] File "/usr/local/lib/python3.5/dist-packages/django/__init__.py", line 19, in setup
[wsgi:error] [pid 6331:tid 3048786752] [remote 192.168.1.111:14007] configure_logging(settings.LOGGING_CONFIG, settings.LOGGING)
[wsgi:error] [pid 6331:tid 3048786752] [remote 192.168.1.111:14007] File "/usr/local/lib/python3.5/dist-packages/django/conf/__init__.py", line 56, in __getattr__
[wsgi:error] [pid 6331:tid 3048786752] [remote 192.168.1.111:14007] self._setup(name)
[wsgi:error] [pid 6331:tid 3048786752] [remote 192.168.1.111:14007] File "/usr/local/lib/python3.5/dist-packages/django/conf/__init__.py", line 43, in _setup
[wsgi:error] [pid 6331:tid 3048786752] [remote 192.168.1.111:14007] self._wrapped = Settings(settings_module)
[wsgi:error] [pid 6331:tid 3048786752] [remote 192.168.1.111:14007] File "/usr/local/lib/python3.5/dist-packages/django/conf/__init__.py", line 106, in __init__
[wsgi:error] [pid 6331:tid 3048786752] [remote 192.168.1.111:14007] mod = importlib.import_module(self.SETTINGS_MODULE)
[wsgi:error] [pid 6331:tid 3048786752] [remote 192.168.1.111:14007] File "/usr/lib/python3.5/importlib/__init__.py", line 126, in import_module
[wsgi:error] [pid 6331:tid 3048786752] [remote 192.168.1.111:14007] return _bootstrap._gcd_import(name[level:], package, level)
[wsgi:error] [pid 6331:tid 3048786752] [remote 192.168.1.111:14007] File "<frozen importlib._bootstrap>", line 986, in _gcd_import
[wsgi:error] [pid 6331:tid 3048786752] [remote 192.168.1.111:14007] File "<frozen importlib._bootstrap>", line 969, in _find_and_load
[wsgi:error] [pid 6331:tid 3048786752] [remote 192.168.1.111:14007] File "<frozen importlib._bootstrap>", line 944, in _find_and_load_unlocked
[wsgi:error] [pid 6331:tid 3048786752] [remote 192.168.1.111:14007] File "<frozen importlib._bootstrap>", line 222, in _call_with_frames_removed
[wsgi:error] [pid 6331:tid 3048786752] [remote 192.168.1.111:14007] File "<frozen importlib._bootstrap>", line 986, in _gcd_import
[wsgi:error] [pid 6331:tid 3048786752] [remote 192.168.1.111:14007] File "<frozen importlib._bootstrap>", line 969, in _find_and_load
[wsgi:error] [pid 6331:tid 3048786752] [remote 192.168.1.111:14007] File "<frozen importlib._bootstrap>", line 956, in _find_and_load_unlocked
[wsgi:error] [pid 6331:tid 3048786752] [remote 192.168.1.111:14007] ImportError: No module named 'myweb'
从网上搜了一些信息还是没有解决问题,新手上路,感谢各路大神指导!
...全文
571 回复 打赏 收藏 转发到动态 举报
写回复
用AI写文章
回复
切换为时间正序
请发表友善的回复…
发表回复

24,923

社区成员

发帖
与我相关
我的任务
社区描述
Web 开发 Apache
社区管理员
  • Apache
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧