yum -y install make zlib zlib-devel gcc-c++ libtool openssl openssl-devel
复制代码
PCRE 做用是让 Ngnix 支持 Rewrite 功能
javascript
一、下载PCRE安装包html
cd /usr/local/src复制代码
wget https://sourceforge.net/projects/pcre/files/pcre/8.43/pcre-8.43.tar.gz/复制代码
如若提示没有wget,则先安装wgetjava
yum -y install wget复制代码
二、解压安装包node
tar zxvf pcre-8.43.tar.gz复制代码
注意将文件名替换成你下载下来的安装包的文件名linux
三、进入安装包目录nginx
cd perc-8.43复制代码
四、编译安装c++
./configure 复制代码
make && make install复制代码
五、查看PCRE版本git
pcre-config –version复制代码
一、下载Nginxgithub
cd /usr/local/src 复制代码
wget http://nginx.org/download/nginx-1.15.9.tar.gz 复制代码
二、解压安装包web
tar zxvf nginx-1.15.9.tar.gz 复制代码
三、进入安装包目录
cd nginx-1.15.9复制代码
四、编译安装
./configure --prefix=/usr/local/nginx --with-http_stub_status_module --with-http_ssl_module --with-pcre=/usr/local/src/pcre-8.43复制代码
make && make install复制代码
五、查看nginx版本
/usr/local/nginx/sbin/nginx -v复制代码
六、启动nginx
/usr/local/nginx/sbin/nginx复制代码
七、nginx其余命令
/usr/local/nginx/sbin/nginx -s reload # 从新载入配置文件
/usr/local/nginx/sbin/nginx -s reopen # 重启 Nginx /usr/local/nginx/sbin/nginx -s stop # 中止 Nginx
复制代码
yum install -y vim*复制代码
https://docs.mongodb.com/manual/tutorial/install-mongodb-on-red-hat/复制代码
vim /etc/yum.repos.d/mongodb-org-4.0.repo复制代码
[mongodb-org-4.0]
name=MongoDB Repository
baseurl=https://repo.mongodb.org/yum/redhat/$releasever/mongodb-org/4.0/x86_64/
gpgcheck=1
enabled=1
gpgkey=https://www.mongodb.org/static/pgp/server-4.0.asc复制代码
yum install -y mongodb-org复制代码
vim /etc/mongod.conf复制代码
将net:bindIp: 127.0.0.1 改成 0.0.0.0
1.SElinux
semanage port -a -t mongod_port_t -p tcp 27017复制代码
2.防火墙(先打开防火墙,而后打开27017端口,最后从新载入配置)
systemctl start firewalld复制代码
firewall-cmd --zone=public --add-port=27017/tcp --permanent复制代码
firewall-cmd --reload复制代码
service mongod start
#或者
systemctl start mongod复制代码
关闭 service mongod stop 或者 systemctl stop mongod
重启 service mongod restart 或者 systemctl restart mongod
chkconfig mongod on
#或者
systemctl ennable mongod复制代码
mongo --host 127.0.0.1:27017复制代码
mongo --host 127.0.0.1:27017
use admin
db.createUser({user:"root",pwd:"root_password",roles:["root"]})复制代码
这里的root_password改为你本身想要的密码,最好设置的难一点
use admin
db.createUser({user:"admin",pwd:"admin_password",roles:[{role:"userAdminAnyDatabase",db:"admin"}]})复制代码
一样,这里的admin_password也改为你本身的密码
use foo
db.createUser({user:"admin", pwd:"admin_password", roles:["readWrite", "dbAdmin"]})
复制代码
foo能够改为任何你本身想要的数据库名
db.auth('admin', 'admin_password')
1 # 1 - 表示认证成功,0 - 表示失败
exit
bye复制代码
curl -sL https://rpm.nodesource.com/setup_10.x | bash -复制代码
上面命令将配置Node.js RPM存储库
sudo yum clean all && sudo yum makecache fastsudo yum install -y gcc-c++ makesudo yum install -y nodejs复制代码
node -v复制代码
npm config set registry https://registry.npm.taobao.org复制代码
npm config get registry复制代码
什么是EPEL 及 Centos上安装EPEL
RHEL以及他的衍生发行版如CentOS、Scientific Linux为了稳定,官方的rpm repository提供的rpm包每每是很滞后的,固然了,这样作这是无可厚非的,毕竟这是服务器版本,安全稳定是重点,官方的rpm repository提供的rpm包也不够丰富,不少时候须要本身编译那太辛苦了,而EPEL偏偏能够解决这两方面的问题。
先输入git --version
查看是否已经安装了git,若是已经安装了就先yum remove git
再执行下面的步骤
curl https://setup.ius.io | sh
yum install -y git2u
git --version复制代码
yum install -y wget复制代码
cd opt/复制代码
我我的喜欢把软件安装到这个目录,你要是不喜欢就跳下一步
git clone https://github.com/ParsePlatform/parse-server-example.git复制代码
cd parse-server-example/
vim index.js复制代码
// Example express application adding the parse-server module to expose Parse
// compatible API routes.
var express = require('express');
var ParseServer = require('parse-server').ParseServer;
var ParseDashboard = require('parse-dashboard');
var path = require('path');
var databaseUri = process.env.DATABASE_URI || process.env.MONGODB_URI;
//Parse服务的域名
var parseDomain = process.env.PARSE_DOMAIN;
if (!databaseUri) {
console.log('DATABASE_URI not specified, falling back to localhost.');
}
var api = new ParseServer({
databaseURI: databaseUri || 'mongodb://localhost:27017/meetwish',
cloud: process.env.CLOUD_CODE_MAIN || __dirname + '/cloud/main.js',
appId: process.env.APP_ID || 'myAppId',
masterKey: process.env.MASTER_KEY || '', //Add your master key here. Keep it secret!
serverURL: `http://localhost:1337/parse`, // Don't forget to change to https if needed liveQuery: { classNames: ['Posts', 'Comments'] // List of classes to support for query subscriptions } }); var dashboard = new ParseDashboard({ 'apps': [ { 'serverURL': `https://${parseDomain}/parse`, 'appId': process.env.APP_ID || 'myAppId', 'masterKey': process.env.MASTER_KEY || '', 'appName': 'meetwish' } ], 'users': [ { 'user': process.env.USER_NAME || 'username', 'pass': process.env.PASSWORD || 'password' } ] }, false); // Client-keys like the javascript key or the .NET key are not necessary with parse-server // If you wish you require them, you can set them as options in the initialization above: // javascriptKey, restAPIKey, dotNetKey, clientKey var app = express(); // Serve static assets from the /public folder app.use('/public', express.static(path.join(__dirname, '/public'))); // make the Parse Dashboard available at /dashboard app.use('/dashboard', dashboard); // Serve the Parse API on the /parse URL prefix var mountPath = process.env.PARSE_MOUNT || '/parse'; app.use(mountPath, api); // Parse Server plays nicely with the rest of your web routes app.get('/', function(req, res) { res.status(200).send('I dream of being a website. Please star the parse-server repo on GitHub!'); }); // There will be a test page available on the /test path of your server url // Remove this before launching your app app.get('/test', function(req, res) { res.sendFile(path.join(__dirname, '/public/test.html')); }); var port = process.env.PORT || 1337; var httpServer = require('http').createServer(app); httpServer.listen(port, function() { console.log('parse-server running on port ' + port + '.'); }); // This will enable the Live Query real-time server ParseServer.createLiveQueryServer(httpServer); 复制代码
启动时需指定APP_ID
,MASTER_KEY
,USER_NAME
,PASSWORD
,PARSE_DOMAIN
等环境变量。
"parse-dashboard":"*"复制代码
npm install
npm audit fix #提示修复就修复一下,不提示就无论了复制代码
npm install -g mongodb-runner复制代码
node index.js复制代码
假设Parse Server服务器的域名是:api.example.com
新版的nginx语法有些不同
server {
listen 443;
server_name api.example.com;
ssl on;
ssl_certificate cert/312431314412324.pem;
ssl_certificate_key cert/312431314412324.key;
ssl_session_timeout 5m;
ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:ECDHE:ECDH:AES:HIGH:!NULL:!aNULL:!MD5:!ADH:!RC4;
ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
ssl_prefer_server_ciphers on;
location / {
proxy_pass http://127.0.0.1:1337;
proxy_redirect off;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
}
复制代码
service nginx restart复制代码
firewall-cmd --add-port=80/tcp --permanent
复制代码
firewall-cmd --add-port=443/tcp --permanent复制代码
firewall-cmd --add-port=1337/tcp --permanent复制代码
firewall-cmd --add-port=4040/tcp --permanent复制代码
firewall-cmd --add-port=27017/tcp --permanent复制代码
这步要是不作,你只能从localhost访问,以前我就被坑了,总之你最后只要保证服务运行且能在远程端口访问到就OK了
1.查看已打开的端口 # netstat -anp
2.查看想开的端口是否已开 # firewall-cmd --query-port=4040/tcp
若此提示 FirewallD is not running
表示为不可知的防火墙 须要查看状态并开启防火墙
3. 查看防火墙状态 # systemctl status firewalld
running 状态即防火墙已经开启
dead 状态即防火墙未开启
4. 开启防火墙,# systemctl start firewalld 没有任何提示即开启成功
5. 开启防火墙 # service firewalld start
关闭防火墙 # systemctl stop firewalld
centos7.3 上述方式可能没法开启,能够先#systemctl unmask firewalld.service 而后 # systemctl start firewalld.service
6. 查看想开的端口是否已开 # firewall-cmd --query-port=4040/tcp 提示no表示未开
7. 开永久端口号 firewall-cmd --add-port=4040/tcp --permanent 提示 success 表示成功
8. 从新载入配置 # firewall-cmd --reload 好比添加规则以后,须要执行此命令
9. 再次查看想开的端口是否已开 # firewall-cmd --query-port=4040/tcp 提示yes表示成功
10. 若移除端口 # firewall-cmd --permanent --remove-port=4040/tcp复制代码