创建yum源文件:
vim /etc/yum.repos.d/mongodb-org-3.4.repo
添加以下内容:(用Linux命令:shift+i 进入 esc + :wq 退出)
[mongodb-org-3.4]
name=MongoDB Repository
baseurl=https://repo.mongodb.org/yum/redhat/$releasever/mongodb-org/3.4/x86_64/
gpgcheck=1
enabled=1
gpgkey=https://www.mongodb.org/static/pgp/server-3.4.asc
这里可以修改 gpgcheck=0, 省去gpg验证
安装之前先更新所有包 :yum update (可选操作)
(2).安装MongoDB
安装命令:
yum -y install mongodb-org

安装完成后
查看mongo安装位置 whereis mongod
查看修改配置文件 : vim /etc/mongod.conf
(3).启动MongoDB
启动mongodb :systemctl start mongod.service
停止mongodb :systemctl stop mongod.service
查到mongodb的状态:systemctl status mongod.service

(4).设置开机启动

(5).启动Mongo shell
查看数据库:show dbs
(6).设置mongodb远程访问:

重启mongodb:systemctl restart mongod.service
13. nginx 静态服务器
https://www.linuxidc.com/Linux/2016-09/134907.htm
安装所需环境
Nginx 是 C语言 开发,建议在 Linux 上运行,当然,也可以安装 Windows 版本,本篇则使用 [CentOS](https://www.linuxidc.com/topicnews.aspx?tid=14) 7 作为安装环境。
一. gcc 安装
安装 nginx 需要先将官网下载的源码进行编译,编译依赖 gcc 环境,如果没有 gcc 环境,则需要安装:
yum install gcc-c++
二. PCRE pcre-devel 安装
PCRE(Perl Compatible Regular Expressions) 是一个Perl库,包括 perl 兼容的正则表达式库。nginx 的 http 模块使用 pcre 来解析正则表达式,所以需要在 linux 上安装 pcre 库,pcre-devel 是使用 pcre 开发的一个二次开发库。nginx也需要此库。命令:
yum install -y pcre pcre-devel
三. zlib 安装
zlib 库提供了很多种压缩和解压缩的方式, nginx 使用 zlib 对 http 包的内容进行 gzip ,所以需要在 Centos 上安装 zlib 库。
yum install -y zlib zlib-devel
四. OpenSSL 安装
OpenSSL 是一个强大的安全套接字层密码库,囊括主要的密码算法、常用的密钥和证书封装管理功能及 SSL 协议,并提供丰富的应用程序供测试或其它目的使用。
nginx 不仅支持 http 协议,还支持 https(即在ssl协议上传输http),所以需要在 Centos 安装 OpenSSL 库。
yum install -y openssl openssl-devel
官网下载
1.直接下载`.tar.gz`安装包,地址:<https://nginx.org/en/download.html>

2.使用`wget`命令下载(推荐)。
wget -c https://nginx.org/download/nginx-1.10.1.tar.gz

我下载的是1.10.1版本,这个是目前的稳定版。
解压
依然是直接命令:
tar -zxvf nginx-1.10.1.tar.gz
cd nginx-1.10.1
配置
其实在 nginx-1.10.1 版本中你就不需要去配置相关东西,默认就可以了。当然,如果你要自己配置目录也是可以的。
1.使用默认配置
./configure
2.自定义配置(不推荐)
./configure \
--prefix=http://www.likecs.com/usr/local/nginx \
--conf-path=http://www.likecs.com/usr/local/nginx/conf/nginx.conf \
--pid-path=http://www.likecs.com/usr/local/nginx/conf/nginx.pid \
--lock-path=http://www.likecs.com/var/lock/nginx.lock \
--error-log-path=http://www.likecs.com/var/log/nginx/error.log \
--http-log-path=http://www.likecs.com/var/log/nginx/access.log \
--with-http_gzip_static_module \
--http-client-body-temp-path=http://www.likecs.com/var/temp/nginx/client \
--http-proxy-temp-path=http://www.likecs.com/var/temp/nginx/proxy \
--http-fastcgi-temp-path=http://www.likecs.com/var/temp/nginx/fastcgi \
--http-uwsgi-temp-path=http://www.likecs.com/var/temp/nginx/uwsgi \
--http-scgi-temp-path=http://www.likecs.com/var/temp/nginx/scgi
> 注:将临时文件目录指定为/var/temp/nginx,需要在/var下创建temp及nginx目录
编译安装
make
make install
查找安装路径:
whereis nginx

启动、停止nginx
cd /usr/local/nginx/sbin/
./nginx
./nginx -s stop
./nginx -s quit
./nginx -s reload