web2py là một khuôn khổ python tuyệt vời có tài liệu tuyệt vời bao gồm một số triển khai recipes. Tuy nhiên, những gì tôi nhớ có là công thức để triển khai bằng cách sử dụng nginx (tốt hơn với uwsgi). Có một số ghi chú không đầy đủ trên web (như here), nhưng tôi không thể tìm thấy bất kỳ hướng dẫn hoàn chỉnh, độc lập nào. Vì vậy, tôi đánh giá cao sự giúp đỡ của bạn.Làm thế nào để deply web2py sử dụng nginx?
15
A
Trả lời
12
OK, nhìn kỹ vào danh sách email web2py mà tôi đã liên kết ở trên, tôi đã tìm ra giải pháp copmlete đã có sẵn. Tôi có thể làm theo các hướng dẫn và, nhờ bài viết tuyệt vời của pbreit, bây giờ triển khai của tôi hoạt động như một nét duyên dáng (chỉ sử dụng RAM 38MB ở trạng thái nhàn rỗi) với nginx + uwsgi.
Dưới đây là các phần tôi đã sử dụng (Tôi vừa loại bỏ fabfile.py để sử dụng nó trên dòng lệnh) Lưu ý: nơi có 'put (' .... 'Tôi đã sử dụng trình soạn thảo văn bản nano để tạo và chỉnh sửa file
apt-get -y install build-essential psmisc python-dev libxml2 libxml2-dev python-setuptools
cd /opt;
wget http://projects.unbit.it/downloads/uwsgi-latest.tar.gz
tar -zxvf uwsgi*
mv /opt/uwsgi*/ /opt/uwsgi/
cd /opt/uwsgi/; python setup.py install
chown -R www-data:www-data /opt/uwsgi
touch /var/log/uwsgi.log
chown www-data /var/log/uwsgi.log
apt-get -y install libpcre3-dev build-essential libssl-dev
cd /opt; wget http://nginx.org/download/nginx-0.8.54.tar.gz
cd /opt; tar -zxvf nginx*
cd /opt/nginx*/; ./configure --prefix=/opt/nginx --user=nginx --group=nginx --with-http_ssl_module
cd /opt/nginx*/; make
cd /opt/nginx*/; make install
adduser --system --no-create-home --disabled-login --disabled-password --group nginx
cp /opt/uwsgi*/nginx/uwsgi_params /opt/nginx/conf/uwsgi_params
wget https://library.linode.com/web-servers/nginx/installation/reference/init-deb.sh
mv init-deb.sh /etc/init.d/nginx
chmod +x /etc/init.d/nginx
/usr/sbin/update-rc.d -f nginx defaults
/etc/init.d/nginx start
cd /opt/
wget https://library.linode.com/web-servers/nginx/python-uwsgi/reference/init-deb.sh
mv /opt/init-deb.sh /etc/init.d/uwsgi
chmod +x /etc/init.d/uwsgi
echo 'PYTHONPATH=/var/web2py/ MODULE=wsgihandler' >> /etc/default/uwsgi
/usr/sbin/update-rc.d -f uwsgi defaults
/etc/init.d/uwsgi start
rm /opt/nginx/conf/nginx.conf
# modify nginx.conf below and save it as /opt/nginx/conf/nginx.conf
cd /opt/nginx/conf; openssl genrsa -out server.key 1024
cd /opt/nginx/conf; openssl req -batch -new -key server.key -out server.csr
cd /opt/nginx/conf;
openssl x509 -req -days 1780 -in server.csr -signkey server.key -out server.crt
/etc/init.d/nginx restart
nginx.conf
user www-data;
worker_processes 4;
events {
worker_connections 1024;
}
http {
include mime.types;
default_type application/octet-stream;
keepalive_timeout 2;
sendfile on;
#tcp_nopush on;
tcp_nodelay on;
gzip on;
server {
listen 80;
server_name example.com www.example.com;
location/{
uwsgi_pass 127.0.0.1:9001;
include uwsgi_params;
}
location /static {
root /var/web2py/applications/init/;
}
}
# HTTPS server
server {
listen 443;
server_name www.example.com example.com;
ssl on;
ssl_certificate /opt/nginx/conf/server.crt;
ssl_certificate_key /opt/nginx/conf/server.key;
location/{
uwsgi_pass 127.0.0.1:9001;
include uwsgi_params;
uwsgi_param UWSGI_SCHEME $scheme;
}
location /static {
root /var/web2py/applications/init/;
}
}
}
Xuất phát từ web2py email list Với sự giúp đỡ từ this Linode gửi
2
Có một giải pháp ở đây: http://www.web2pyslices.com/slice/show/1495/updated-uwsgi-nginx-script-for-ubuntu-1110
Các vấn đề liên quan
- 1. Làm thế nào để gỡ lỗi các ứng dụng Web2py?
- 2. Làm cách nào để triển khai web2py trên PythonAnywhere?
- 3. Làm thế nào để chạy nginx + python (không có django)
- 4. Làm thế nào để kích hoạt xdebug với nginx?
- 5. Làm thế nào để kiểm tra ủy quyền nginx timeouts
- 6. Làm thế nào để chạy Nginx trên nhiều cổng
- 7. Làm thế nào để hiển thị lỗi web2py trực tiếp (tự động chuyển hướng đến vé)
- 8. phương pháp chèn web2py
- 9. ghi nhật ký ứng dụng web2py
- 10. Làm cách nào để sử dụng hàm PHP Mail() trong PHP-FPM? Trên Nginx?
- 11. Làm thế nào để sử dụng inotify?
- 12. Làm thế nào để sử dụng Parcel.readBooleanArray()?
- 13. Làm thế nào để sử dụng Resources.getFraction()?
- 14. Làm thế nào để sử dụng ReadWriteLock?
- 15. làm thế nào để sử dụng glCopyImage2D
- 16. Làm thế nào để sử dụng paramiko.RSAKey.from_private_key()?
- 17. Làm thế nào để sử dụng MonadRandom?
- 18. Làm thế nào để sử dụng SqlCacheDependency?
- 19. Làm thế nào để sử dụng sprof?
- 20. Làm thế nào để sử dụng SqlBulkCopyColumnMappingCollection?
- 21. Làm thế nào để sử dụng FileDialog?
- 22. Làm thế nào để sử dụng java.net.URI
- 23. Làm thế nào để sử dụng AutoMapper?
- 24. Làm thế nào để sử dụng Git?
- 25. Làm thế nào để sử dụng TDictionary?
- 26. Làm thế nào để sử dụng Ant?
- 27. Làm thế nào để sử dụng NSScanner?
- 28. Làm thế nào để sử dụng grails.plugin.location?
- 29. Làm thế nào để sử dụng bitmask?
- 30. Làm thế nào để sử dụng DataProtectionProvider?
nhớ rằng tập tin cấu hình này có một số con đường Remapping ... dường như giả định một ứng dụng init. – Massimo
wget -O init-deb.sh http://library.linode.com/assets/661-init-deb.sh – Unitech
@massimo: những gì cần được thay đổi để hỗ trợ nhiều ứng dụng? – hoju