Ubuntu下安装python和nginx

  1. Ubuntu下cat /etc/issue获得版本号是Ubuntu 14.04.2 LTS
  2. sudo apt-get install update
  3. sudo apt-get install update
  4. sudo apt-get install pip
  5. sudo pip install scanf
  6. sudo pip install python-matplotlib,直接install matplotlib可能报很多错误
  7. sudo pip install python-numpy
  8. sudo apt-get install nginx
  9. cp /usr/share/zoneinfo/Asia/Shanghai /etc/localtime设置东八区为本机时间,命令date -R测试是否有效
  10. 编辑/etc/nginx/nginx.conf,在http{}大括号内添加:
     1 http {
     2     # some other code
     3     server {
     4         listen 8080;
     5         server_name localhost;
     6         location / {
     7               root /home/xxxx/document;
     8               index xxx.html;
     9         }
    10     }
    11     # some other code
    12 }
  11. 运行命令nginx启动服务,但是可能会报错:nginx:[emerg] listen() to 0.0.0.0:80, backlog 511 failed (98:Address already in use),运行netstat -ntpl找到占用80端口的PID,运行kill xxx干掉这个任务,重新运行nginx,在浏览器内运行就可以看到网页了。虽然上一步骤我们只想运行8080端口,为何会占用80端口呢?原因在于这段代码前面有“include /etc/nginx/sites-enabled/*”,这个目录下有个default文件,其中代码和上一步类似,里面默认是80端口,所以上一步内容可以改到default文件内。

猜你喜欢

转载自www.cnblogs.com/songyj06/p/9297473.html
今日推荐