您的位置:首页 > 理论基础 > 计算机网络

【腾讯云的1001种玩法】使用腾讯云自建一个专属于自己的网络笔记本

2017-04-14 12:00 549 查看
腾讯云技术社区-博客主页持续为大家呈现云计算技术文章,欢迎大家关注!

作者:慕星星

1、说明:

很多情况下,对于一个程序员,作家、等等行业,都需要一个笔记本来记录自己的经验,创作等等。这么说来一个好的笔记本就需要好好选择和考虑的了。

今天我推荐一款笔记本,是网络笔记,名字是:蚂蚁笔记,leanote:开源产品。

需要一个域名,可以从腾讯、阿里申请。

需要一台服务器,建议从腾讯云购买,很便宜的,最低只需要45/月。

这是我的博客,正在备案,可能打不开。http://www.itgrub.com

配置环境:CentOS7 64

2、安装:mongodb数据

####安装mongodb部分
yum -y install wget  vim   #可以从网络获取资源
cd /home
wget  https://fastdl.mongodb.org/linux/mongodb-linux-x86_64-3.0.1.tgz mv mongodb-linux-x86_64-3.0.1.tgz mongodb
tar -xzvf mongodb-linux-x86_64-3.0.1.tgz/
mkdir mongoData #用于存储数据

####设置mongodb部分
vim /etc/profile
#插入一行
export PATH=$PATH:/home/user1/mongodb-linux-x86_64-3.0.1/bin
#使之生效
source /etc/profile

####测试mongodb能否正常运行
mongodb --dbpath /home/mongoData
#重新开一个窗口
mongo
show dbs
#如果是有数据表列出,说明安装成功


3、安装:leanote程序

最新的leanote程序可以从这里下载:http://leanote.org/#download

选择:linux 64,具体还是根据自己的服务器来决定的

####安装并设置leanote

cd /home
wget https://iweb.dl.sourceforge.net/project/leanote-bin/2.4/leanote-linux-amd64-v2.4.bin.tar.gz tar -zxvf  leanote-linux-amd64-v2.4.bin.tar.gz
vim /home/leanote/conf/app.conf
#必须改变这里:app.secret

####导入leanote初始数据库
mongorestore -h localhost -d leanote --dir /home/leanote/mongodb_backup/leanote_install_data/

####启动leanote
cd /home/leanote/bin
sh run.sh
#现在再开一个窗口,从第三个窗口访问


4、安装:nginx,启用:https,从腾讯云SSL申请证书

yum -y install nginx
#设置nginx开机自启动和启动nginx
systemctl enable nginx.service
systemctl start nginx.service

#把申请下来的证书放在/home/SSL中

#在nginx中创建一个配置文档,启用自己的域名并准备访问
cd /etc/nginx/conf.d/
vim leanote.conf
#输入以下文本
# http
server
{
listen  80;
server_name  note.test.com;

rewrite ^/(.*) https://note.itgrub.com/$1 permanent;
proxy_set_header X-Forwarded-For $remote_addr;
location / {
proxy_pass        http://127.0.0.1:9000; proxy_set_header   Host             $host;
proxy_set_header   X-Real-IP        $remote_addr;
proxy_set_header   X-Forwarded-For  $proxy_add_x_forwarded_for;
}
error_page 400 403 404 497 https://$host$uri$args; }

# https
server
{
listen  443 ssl;
server_name  note.test.com;
ssl on;
ssl_certificate     /home/SSL/note.test.com.crt;
ssl_certificate_key /home/SSL/note.test.com.key;

proxy_set_header X-Forwarded-For $remote_addr;

location / {
proxy_pass        http://127.0.0.1:9000; proxy_set_header   Host             $host;
proxy_set_header   X-Real-IP        $remote_addr;
proxy_set_header   X-Forwarded-For  $proxy_add_x_forwarded_for;
}
}

#输入完成后保存
systemctl nginx restart

#现在就可以看下自己的网页了,而且还是支持https的哦!


5、自启动处理:使用supervisord服务

使用supervisord服务来控制leanote与mongodb自启动

yum install -y epel-release
yum install -y python-setuptools m2crypto
easy_install supervisor
echo_supervisord_conf > /etc/supervisord.conf

#编辑配置文件,末尾加入
vim /etc/supervisord.conf

[program:mongodb]
command=/home/mongodb/bin/mongod  --bind_ip 127.0.0.1   --dbpath=/home/mongoData
autostart=true
autorestart=true
user=root
log_stderr=true
logfile=/var/log/mongodb.log

[program:leanote]
command=/bin/bash /home/leanote/bin/run.sh
autostart=true
autorestart=true
user=root
log_stderr=true
logfile=/var/log/leanote.log

#保存后,关闭第一个、第二个窗口,在关闭前使用ctrl+c,然后启动supervisord服务
systemctl start superviord.service
echo 'systemctl start superviord.service' >>  /etc/rc.local


6、配置防火墙

systemctl enable firewalld.service
systemctl start firewalld.service
firewall-cmd --permanent --add-service=http
firewall-cmd -<
d842
/span>-permanent --add-service=https
firewall-cmd --reload
##此时防火墙生效


相关推荐

如何购买腾讯云服务器

【腾讯云的1001种玩法】如何使用腾讯云服务器作为微信公众号的开发空间

此文已由作者授权腾讯云技术社区发布,转载请注明文章出处

原文链接:https://www.qcloud.com/community/article/11431001491442349

获取更多腾讯海量技术实践干货,欢迎大家前往腾讯云技术社区
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
相关文章推荐