启动Ubuntu 14.04 AWS实例后,更新并升级服务器,获取pip3,并成功安装Apache2。 将/etc/apache2/sites-enabled/000-default.conf文件更改为:
<VirtualHost *:80>
<Directory /var/www/test>
Options +ExecCGI
DirectoryIndex index.py
</Directory>
AddHandler cgi-script .py
...
DocumentRoot /var/www/test
...
使用以下方法安装mod_wsgi:
sudo apt-get install libapache2-mod-wsgi-py3
将Apache2.conf文件更改为:
WSGIScriptAlias / /var/www/html/myproject/myproject/myproject/wsgi.py
WSGIPythonPath /var/www/html/myproject/myproject
<Directory /var/www/html/myproject/myproject/myproject>
<Files wsgi.py>
Require all granted
</Files>
</Directory>
并进行迁移,并通过键入以下命令来运行服务器:
python3 manage.py runserver 0.0.0.0:8000
我试图在publicdns上查看它:8000但它说网站不可用。任何关于如何启动和运行的建议将不胜感激。 谢谢。
编辑:这里要求的是settings.py文件:
},
]
# Internationalization
# https://docs.djangoproject.com/en/1.9/topics/i18n/
LANGUAGE_CODE = 'en-us'
TIME_ZONE = 'UTC'
USE_I18N = True
USE_L10N = True
USE_TZ = True
# Static files (CSS, JavaScript, Images)
# https://docs.djangoproject.com/en/1.9/howto/static-files/
STATIC_URL = '/static/'
STATIC_ROOT = os.path.join(BASE_DIR, "static/")
以下是网络服务器的卷曲:
curl -i http://ipaddress
HTTP/1.0 503 Service Unavailable
Cache-Control: no-cache
Connection: close
Content-Type: text/html
<html><body><h1>503 Service Unavailable</h1>
No server is available to handle this request.
</body></html>
带端口的卷曲-i根本没有返回任何内容。