以下设置只让我看到默认的Nginx html页面。我怎么才能到达Django?
我一直在关注如何设置它的Linode的文档(以及许多其他教程),但是他们没有使用systemd,所以事情有点不同。
我正在使用Linode和Fedora24。我安装了我的virutalenv / home / ofey / djangoenv并激活它, Django使用pip安装 /家庭/ ofey / qqiProject 进入virtualenv我已经安装了uwsgi。 首先, /etc/systemd/system/uwsgi.service
[Unit]
Description=uWSGI Emperor service
After=syslog.target
[Service]
ExecStart=/home/ofey/djangoenv/bin/uwsgi --emperor /etc/uwsgi/sites
Restart=always
KillSignal=SIGQUIT
Type=notify
StandardError=syslog
NotifyAccess=all
[Install]
WantedBy=multi-user.target
执行,
/etc/uwsgi/sites/qqiProject.ini
[uwsgi]
project = qqiProject
base = /home/ofey
chdir = %(base)/%(project)
home = %(base)/djangoenv
module = %(project).wsgi:application
master = true
processes = 2
socket = %(base)/%(project)/%(project).sock
chmod-socket = 664
vacuum = true
此外,
的/ etc / nginx的/位点可用/ qqiProject
server {
listen 80;
server_name qqiresources.com www.qqiresources.com;
location = /favicon.ico { access_log off; log_not_found off; }
location /static/ {
root /home/django/qqiProject;
}
location / {
include uwsgi_params;
uwsgi_pass unix:/home/django/qqiProject/qqiProject.sock;
}
}
文件/etc/nginx/nginx.conf尚未更改。
用户是,我已经使用过,
$ sudo systemctl daemon-reload
$ sudo systemctl restart nginx
$ sudo systemctl start uwsgi.service
启动Django,
$ python manage.py runserver
对于Django的settings.py我关闭了调试并添加了一个主机
DEBUG = False
ALLOWED_HOSTS = ['qqiresources.com']
我还创建了一个符号链接,
sudo ln -s /etc/nginx/sites-available/qqiProject /etc/nginx/sites-enabled
非常感谢任何帮助,
由于
答案 0 :(得分:0)
以下内容对我有用,但我不确定这是否是正确或最有效的方法,特别是在涉及套接字的情况下。
systemd运行uwsgi.service,可以使用
启动$ sudo systemctl start uwsgi.service
有时需要使用
重新加载systemd$ sudo systemctl daemon-reload
/etc/sysemd/system/uwsgi.service
[Unit]
Description=uWSGI Emperor service
After=syslog.target
[Service]
ExecStart=/home/ofey/djangoenv/bin/uwsgi --emperor /etc/uwsgi/sites
Restart=always
KillSignal=SIGQUIT
Type=notify
StandardError=syslog
NotifyAccess=all
[Install]
WantedBy=multi-user.target
使用
调用django虚拟环境目录中的二进制文件ExecStart = / home / ofey / djangoenv / bin / uwsgi
并将我们带到/ etc / uwsgi / sites,其中uwsgi配置文件名为djangoForum.ini
/etc/uwsgi/sites/djangoForum.ini
[uwsgi]
project = djangoForum
base = /home/ofey
chdir = %(base)/%(project)
home = %(base)/djangoenv
module = crudProject.wsgi:application
master = true
processes = 2
socket = 127.0.0.1:3031
chmod-socket = 664
vacuum = true
Django位于/ home / ofey / djangoForum,我的django项目位于/ home / ofey / djangoForum / crudProject
/etc/nginx/nginx.conf
events {
worker_connections 1024;
}
http{
upstream django {
# connect to this socket
# server unix:///tmp/uwsgi.sock; # for a file socket
server 127.0.0.1:3031; # for a web port socket
}
server {
# the port your site will be served on
listen 80;
# the domain name it will serve for
server_name example.com; # substitute your machine's IP address or FQDN
charset utf-8;
#Max upload size
client_max_body_size 75M; # adjust to taste
# Django media
location /media {
alias /home/ofey/djangoForum/fileuploader/uploaded_files; # your Django project's media files
}
location /static {
alias /home/ofey/djangoForum/noAppBoundStaticDirectory; # your Django project's static files
}
# Finally, send all non-media requests to the Django server.
location / {
uwsgi_pass django;
# uwsgi_pass 127.0.0.1:3031;
include /etc/nginx/uwsgi_params; # or the uwsgi_params you installed manually
}
}
}
nginx可以打开,
$ sudo systemctl start nginx.service
'开始'可以替换,重启'或者'停止'
uwsgi和nginx的这些配置文件对我有用。
有用的链接: