1. 已經安裝好 homebrew
2. 並使用 brew 安裝 python3
python3 在 3.5 之後的版本,都會隨附安裝 pip3 和 pyvenv,因此要建立虛擬環境,十分容易。建立專案資料夾後,進入專案目錄,並執行:
python3 -m venv venv
建立之後,Mac 在專案的資料夾內的 terminal 命令列執行下式以啟動虛擬設定:
source venv/bin/activate
離開則是下:
deactivate
python3 -m venv venv
source venv/bin/activate
deactivate
use admin
db.createUser(
{
user: "myUserAdmin",
pwd: "abc123",
roles: [ { role: "userAdminAnyDatabase", db: "admin" }, "readWriteAnyDatabase" ]
}
)
$ sudo service mongod stop
net:
port: 27017
bindIp: 127.0.0.1,157.23.???.???
security:
authorization: enabled
$ sudo service mongod start
$ mongo -u myUserAdmin -p abc123
$ sudo ufw allow OpenSSH
$ sudo ufw allow from 你個人電腦的IP to any port 27017
$ sudo ufw allow http
$ sudo ufw allow https
sudo npm i -g pm2
pm2 init
apps: [{
name: 'der_linebot',
script: 'app.js',
output: './logs/output.log',
error: './logs/error.log',
// log: './logs/combined.log',
// Options reference: https://pm2.io/doc/en/runtime/reference/ecosystem-file/
args: 'one two',
instances: 1,
autorestart: true,
watch: false,
max_memory_restart: '1G',
env: {
NODE_ENV: 'development',
HTTP_PORT: 3000,
HTTPS_PORT: 3002
},
env_production: {
NODE_ENV: 'production',
HTTP_PORT: 80,
HTTPS_PORT: 443
}
}],
"scripts": {
"dev": "pm2 start",
"pro": "sudo pm2 start --env production"
},
sudo chown shinder:shinder /home/shinder/.pm2/rpc.sock /home/shinder/.pm2/pub.sock
$ apt-get update
$ apt-get install certbot
$ certbot certonly --manual
Create a file containing just this data:
辨識用的一串編碼
And make it available on your web server at this URL:
http://你的網域/.well-known/acme-challenge/一串編碼
app.get('/.well-known/acme-challenge/一串編碼', (req, res)=>{
res.send('辨識用的一串編碼');
});
IMPORTANT NOTES:
- Congratulations! Your certificate and chain have been saved at:
/etc/letsencrypt/live/你的網域/fullchain.pem
Your key file has been saved at:
/etc/letsencrypt/live/你的網域/privkey.pem
Your cert will expire on 2019-05-04. To obtain a new or tweaked
version of this certificate in the future, simply run certbot
again. To non-interactively renew *all* of your certificates, run
"certbot renew"
- If you like Certbot, please consider supporting our work by:
Donating to ISRG / Let's Encrypt: https://letsencrypt.org/donate
Donating to EFF: https://eff.org/donate-le
const privateKey = fs.readFileSync('/etc/letsencrypt/live/你的網域/privkey.pem', 'utf8');
const certificate = fs.readFileSync('/etc/letsencrypt/live/你的網域/fullchain.pem', 'utf8');
const credentials = {
key: privateKey,
cert: certificate,
ca: certificate
};
$ docker run -d -p 27017:27017 --name 容器名稱 mongo
$ docker run -it --link 容器名稱:mongo --rm mongo mongo --host mongo test
mkdir ~/data
sudo docker run -d -p 27017:27017 -v ~/data:/data/db mongo
/Applications/MAMP/conf/ dir.$ cd ~
# generate a private key (will request a password twice)
$ openssl genrsa -des3 -out server.key 1024
# generate certificate signing request (same password as above)
$ openssl req -new -key server.key -out server.csr
# Answer the questions
Country Name (2 letter code) [AU]: CA
State or Province Name (full name) [Some-State]: Quebec
Locality Name (eg, city) []: Montreal
Organization Name (eg, company) [Internet Widgits Pty Ltd]: Your Company
Organizational Unit Name (eg, section) []: Development
Common Name (eg, YOUR name) []: localhost
Email Address []: your_email@domain.com
A challenge password []: # leave this empty
An optional company name []: # leave this empty
# generate the certificate
$ openssl x509 -req -days 365 -in server.csr -signkey server.key -out server.crt
# remove the password from the server key
$ cp server.key server.tmp
$ openssl rsa -in server.tmp -out server.key
# Move the certificate into your MAMP apache configuration folder
$ cp server.crt /Applications/MAMP/conf/apache
$ cp server.key /Applications/MAMP/conf/apache
Include /Applications/MAMP/conf/apache/extra/httpd-ssl.conf./Applications/MAMP/conf/apache/extra/httpd-vhosts.conf just the same./Applications/MAMP/conf/apache/extra/httpd-ssl.conf, find the following block and edit the fields Server Name and Document Root with the values you already have in your vhost.# General setup for the virtual host
DocumentRoot "/Applications/MAMP/Library/htdocs"
ServerName www.example.com:443
ServerAdmin you@example.com
ErrorLog "/Applications/MAMP/Library/logs/error_log"
TransferLog "/Applications/MAMP/Library/logs/access_log"
and edit in your DocumentRoot and ServerName settings: