首先说下我的情况,Windows+mongodb开发的简单nodejs 小博客系统,
配置部署到centos7 nginx下,mongodb还是在我Windows机器下,
1、Linux安装node.详细:http://www.cnblogs.com/already/p/4680394.html
2、上传压缩的文件包,解压至指定目录
3、配置nginx的vhost配置,
server { listen 80; server_name blog.caesar.com; location ~ { proxy_pass http://127.0.0.1:3000; } root /usr/local/src/microblog/; access_log /var/log/nginx/blog.access.log; error_log /var/log/nginx/blog.error.log; index index.html index.php; autoindex off; location ~* .*\.(gif|jpg|jpeg|png|bmp|ico|css|js|txt|flv|swf|mid|doc|ppt|xls|pdf|txt|mp3|wma)$ { expires 2d; } }
4、hosts 文件添加blog.caesar.com :
vi /etc/hosts
127.0.0.1 blog.caesar.com localhost
5、修改nodejs app.js mongodb的链接配置,IP
6、nginx -t nginx -s reload
success!
(如果启动出现502 并且log日志显示connect() to 127.0.0.1:3000 failed (13: Permission denied) while connecting to upstream, client: 127.0.0.1, server: 错误信息,参照博文:http://www.cnblogs.com/already/p/4680259.html)
本地访问,hosts文件加上域名和IP即可。
时间: 2024-10-07 09:10:09