發表文章

ssl憑證nginx 設定

首先建一個目錄 sudo mkdir /etc/nginx/ssl 進入目錄 cd /etc/nginx/ssl 產生 myserver.key和 server.csr sudo openssl req -nodes -newkey rsa:2048 -sha256 -keyout myserver.key -out server.csr 產生後上傳到有簽發ssl憑證的域名商 上傳後等待域名商 安全憑證簽發 簽發後下載 xxx.pem 和 yyy.crt 到  /etc/nginx/ssl xxx 或 yyy名稱可以看自己喜歡取名, 只要記得設定   nginx 時名稱路徑要對上 然後設定 nginx sudo vi /etc/nginx/sites-enabled/nginxsetupfile server {     listen   80; ## listen for ipv4; this line is default and implied     #listen   [::]:80 default ipv6only=on; ## listen for ipv6     rewrite ^(.*) https://$host$1 permanent; }      server {     listen 443 ssl;     server_name cclin.xyz;     access_log /var/log/nginx/mysite-access.log ;     error_log /var/log/nginx/mysite-error.log ;          location /static {         alias /home/for/static/path/static;     } ...

javascript regex

regex這東西不常用, 每次用都要google老半天. 這次是因為輸入的文字會變成url slug, 所以必須使javascript做出如果是非文字都不能輸入(包括標點或空格) <h1>Create a Thing</h1> <form role="form" action="" method="post" enctype="multipart/form-data"> <input type='hidden' name='csrfmiddlewaretoken' value='CiTMjJgFuTMRatFsQRBUT6z8JuyRhe2g' /> <p><label for="id_name">Name:</label> <input id="id_name" maxlength="255" name="name" type="text" /></p> <p><label for="id_image">Image:</label> <input id="id_image" name="image" type="file" /></p> <p><label for="id_description">Description:</label> <textarea cols="40" id="id_description" name="description" rows="10"> </textarea></p>  <input type="submit"  value="Sub...

line 1: Bad configuration option: useroaming

最近要用ssh連接aws ubuntu server突然發現一個問題 $ ssh -i "xxx.pem" ubuntu@xxx.xxx.xxx.com /Users/korekyourin/.ssh/config: line 1: Bad configuration option: useroaming /Users/korekyourin/.ssh/config: terminating, 1 bad configuration options 這時必須進入/Users/korekyourin/.ssh/config 把useroaming註解掉 vi /Users/korekyourin/.ssh/config UseRoaming no 註解掉,變成 #UseRoaming no 這樣ssh到server 才能成功 參考

python3 的lambda

bank.py class Account:     def __init__(self, name, number, balance):         self.__name = name         self.__number = number         self.__balance = balance     @property     def name(self):         return self.__name     @property     def number(self):         return self.__number     @property     def balance(self):         return self.__balance     def deposit(self, amount):         if amount <= 0:             print('存款金額不得為負')         else:             self.__balance += amount     def withdraw(self, amount):         if amount > self.__balance:             print('餘額不足')       ...

Homebrew安裝和啟動rabbitmq-server

圖片
安裝 brew update brew install rabbitmq 啟動 PATH=$PATH:/usr/local/sbin rabbitmq-server 參考

用shell script 執行python

圖片
我想用shell script 執行python,並執行時要選y,並讓sh檔每10秒執行一次,,. 因為當我用 python manage.py rebuild_index 時要選y 參考

在背景執行shell script

現在我有bash 檔run_rebuild.sh 因為我logout  server 後還要server繼續執行它 在背景執行run_rebuild.sh nohup ./run_rebuild.sh & 然後我就可以logout 了 或者 ./run_rebuild.sh & exit 直接 logout了 參考