我已将服务器迁移到 amazon ec2,并尝试在那里设置以下环境:
Nginx 在前端提供静态内容,传递给 django 获取动态内容。我也想在这个设置中使用 phpmyadmin。
我不是服务器管理员,所以我只是按照一些教程来让 nginx 和 django 启动并运行。但是我已经工作了两天,试图将 phpmyadmin 挂接到此设置,但无济于事。我现在正在发送我当前的服务器配置,如何在这里为 phpmyadmin 提供服务?
server {
listen 80;
server_name localhost;
access_log /opt/django/logs/nginx/vc_access.log;
error_log /opt/django/logs/nginx/vc_error.log;
# no security problem here, since / is always passed to upstream
root /opt/django/;
# serve directly - analogous for static/staticfiles
location /media/ {
# if asset versioning is used
if ($query_string) {
expires max;
}
}
location /admin/media/ {
# this changes depending on your python version
root /path/to/test/lib/python2.7/site-packages/django/contrib;
}
location /static/ {
# if asset versioning is used
if ($query_string) {
expires max;
}
}
location / {
proxy_pass_header Server;
proxy_set_header Host $http_host;
proxy_redirect off;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Scheme $scheme;
proxy_connect_timeout 10;
proxy_read_timeout 10;
proxy_pass http://localhost:8000/;
}
# what to serve if upstream is not available or crashes
error_page 500 502 503 504 /media/50x.html;
}