标签:ror 没有权限 local cat socket 链接 event 内容 err
接上一章:已经按照之前章节安装了Python2.7.10,Django 1.8.14. 以及mysql,并创建了数据库以及数据库帐号密码。
yum -y install nginx
#设置nginx开机启动:
chkconfig nginx on
启动nginx:service nginx start
启动报错:nginx: [emerg] socket() [::]:80 failed (97: Address family not supported by protocol)
解决办法:vim /etc/nginx/conf.d/default.conf
将: listen 80 default_server;
listen [::]:80 default_server;
启动nginx就行了。。
vi /etc/nginx/nginx.conf
(修改成自己的用户账号,它默认用的是nginx用户,但我们博客的目录下访问这些是需要用户账号的,而nginx这个用户是没有权限的。所以将user后改成自己的用户账号shawn。如果不做这些修改,我们后面访问静态文件会出现问题。因为nginx本来就没有权限去访问这些静态的文件。)
/usr/local/bin/pip install gunicorn
import multiprocessing bind = "127.0.0.1:8080" workers = 2 errorlog = ‘/home/brad/xxx_project/gunicorn.error.log‘ #accesslog = ‘./gunicorn.access.log‘ #loglevel = ‘debug‘ proc_name = ‘gunicorn_blog_project‘
server { listen 80; server_name localhost example.com; access_log /home/brad/xxx_project/nginx.access.log; error_log /home/brad/xxx_project/nginx.error.log; location / { proxy_pass http://127.0.0.1:8080; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; } location /robots.txt { alias /home/brad/xxx_project/static/robots.txt; } location /favicon.ico { alias /home/brad/xxx_project/static/img/favicon.ico; } location ~ ^/(media|static)/ { root /home/brad/xxx_project; expires 30d; } # this prevents hidden files (beginning with a period) from being served location ~ /\. { access_log off; log_not_found off; deny all; } }
sudo ln -s /home/brad/xxx_project/nginx.conf /etc/nginx/conf.d/xxx_project.conf
sudo vi settings.py
sudo nohup /usr/local/python2710/bin/gunicorn xz1024_project.wsgi:application -c /home/brad/xz1024_project/gunicorn.conf.py&
注意:需要在/home/brad/xxx_project目录下面执行。
sudo /sbin/iptables -I INPUT -p tcp --dport 80 -j ACCEPT sudo service iptatbles save
centos6.5腾讯云django环境部署---2、Gunicorn+Django+nginx+mysql部署
标签:ror 没有权限 local cat socket 链接 event 内容 err
原文地址:http://www.cnblogs.com/xz1024/p/6134359.html