下面的设置只让我看到默认的Nginx html页面。去姜戈怎么走?
我一直在关注Linode的文档(以及许多其他教程),但它们没有使用systemd,所以情况有点不同。
我正在使用Linode和Fedora24。我已经在/home/ofey/djangoenv安装了我的virutalenv并激活了它,Django是使用pip在/home/ofey/qqiProject安装到我已经安装了uwsgi的virtualenv中的。首先,/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/site/qqProject.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/sites可用/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未更改。
用户是ofey,我用过,
$ 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任何帮助都将不胜感激,
谢谢
发布于 2016-12-04 21:57:26
下面的方法对我来说是有效的,但是我不确定这是不是正确的或者最有效的方法,特别是在涉及到套接字的时候。
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 /site,其中的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 = trueDjango位于/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“‘start”可以替换为“restart”或“stop”。
uwsgi和nginx的这些配置文件适用于我。
有用的链接:
https://stackoverflow.com/questions/40855861
复制相似问题