發表文章

目前顯示的是有「nginx」標籤的文章

add localhost ssl certificate to nginx

1. key openssl genrsa -des3 -out localssl.key 1024 2. csr openssl req -new -key localssl.key -out localssl.csr 3. remove passphrase cp localssl.key localssl.key.org openssl rsa -in localssl.key.org -out localssl.key 4. crt openssl x509 -req -days 365 -in localssl.csr -signkey localssl.key -out localssl.crt 5. add to ssl certificate sudo cp localssl.crt /etc/ssl/certs/ sudo cp localssl.key /etc/ssl/private/ 6. modify /etc/nginx/sites-enabled/flask.conf (flask.conf to be replace to your configure name) server {     listen      80;     server_name admin.domain.com;     charset     utf-8;     client_max_body_size 75M;        location / {         include uwsgi_params;         uwsgi_pass unix:/var/www/app/uwsgi.sock;     }     location /static {     ro...

flask + nginx + uwsgi

套件簡略說明 flask: python micro web framework nginx: web socket service uwsgi: protocol between python and nginx -------------------------------------------------- 環境介紹 os: ubuntu 64bit web server: nginx + uwsgi + uwsgi-plugin-python web framework: python 2.7 + flask other packages: pip, virtualenv -------------------------------------------------- 套件安裝 1. virtualenv: sudo apt-get install virtualenv 2. nginx: sudo apt-get install nginx uwsgi  uwsgi-plugin-python 3. flask: pip install flask (在虛擬環境下) ps. 系統不要裝 pip,以免虛擬環境安裝套件時安裝到系統上 -------------------------------------------------- 環境建置 1. virtualenv root> virtualenv /var/www/app/venv root> source /var/www/app/venv/bin/activate  #進入虛擬環境 (venv) root> #前綴字表示虛擬環境 2. environment configure   (1) nginx #nginx configuration: /etc/nginx/sites-enables/flask.conf root> rm /etc/nginx/sites-enables/default root> cat /etc/nginx/sites-enables/flask.conf server {     listen...