8.6
坑16:让Nginx加载静态文件后在浏览器输入网址却发现了加载css文件的403错误
网上也有相似的问题
提问的人在评论里说他已经提到了解决方法,是因为给Nginx的权限不够。于是我又继续找这个错误的原因,后来找到了这个
nginx静态资源文件无法访问,403 forbidden错误
里面提到无法访问的原因是因为这个Nginx的配置文件是放在root目录下的,若用户不是root,则无法访问。
按照文章里的指引,我讲nginx.conf里的user从www-data修改为root再重启nginx,再访问网页就好了。
坑17:Upstart服务在Ubuntu 15后已经无法使用,用书中方法建.conf文件无法使用,提示 Upstart: Failed to connect to socket /com/ubuntu/upstart
这一点有两种不同的方法去解决
第一种是转移路径,具体命令为
dpkg-divert --local --rename --add /sbin/initctl
ln -s /bin/true /sbin/initctl
看起来很简单,也很快捷。不过看了作者的详细描述后决定放弃,这种方法风险太大。对于我这种linux小白来说要是把系统搞挂了,就呵呵了
坑爹的 socket /com/ubuntu/upstart: 拒绝连接
第二种办法就是把按照Ubuntu官方的做法,用systemd替换这个upstart,当然.conf也要改写成.service
原来的.conf是这样的
description "Gunicorn server for www.tonycodetest.site"
start on net-device-up
stop on shutdown
respawn
setuid root
chdir /home/tony/sites/www.tonycodetest.site/source
exec ../virtualenv/bin/gunicorn --bind unix:/tmp/www.tonycodetest.site.socket superlists.wsgi:application
按照第二种方法的对照表,用.service改造就变成
[Unit]
Description=Gunicorn server for www.tonycodetest.site
After=syslog.target network.target remote-fs.target nss-lookup.target
[Service]
Restart=on-failure
User=root
WorkingDirectory=/home/tony/sites/www.tonycodetest.site/source
ExecStart=/home/tony/sites/www.tonycodetest.site/virtualenv/bin/gunicorn --bind unix:/tmp/www.tonycodetest.site.socket superlists.wsgi:application
ExecStop=/bin/kill -s QUIT $MAINPID
[Install]
WantedBy=multi-user.target
改写完后再把这个service启动,就大功告成了
这个服务终于正常启动了。。。