日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當(dāng)前位置: 首頁(yè) > 人文社科 > 生活经验 >内容正文

生活经验

xshell连接Linux、ngix部署

發(fā)布時(shí)間:2023/11/27 生活经验 42 豆豆
生活随笔 收集整理的這篇文章主要介紹了 xshell连接Linux、ngix部署 小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.

Linux端安裝sshd服務(wù)(openssh-server)

查看防火墻:ufw(Linux默認(rèn)安裝了)

再就是客戶端了。。

?

平時(shí)在測(cè)試環(huán)境下的項(xiàng)目不能承載高并發(fā),需要部署到web server上。
web server:
? ? apache(早期)
? ? ngix(更能承載高并發(fā)、輕量級(jí),底層是I/O多路復(fù)用epoll)

如何在生產(chǎn)上部署Django?

Django的部署可以有很多方式,采用nginx+uwsgi的方式是其中比較常見的一種方式。

?uwsgi介紹

uWSGI是一個(gè)Web服務(wù)器,它實(shí)現(xiàn)了WSGI協(xié)議、uwsgi、http等協(xié)議。Nginx中HttpUwsgiModule的作用是與uWSGI服務(wù)器進(jìn)行交換。

要注意 WSGI / uwsgi / uWSGI 這三個(gè)概念的區(qū)分。

  1. WSGI是一種Web服務(wù)器網(wǎng)關(guān)接口。它是一個(gè)Web服務(wù)器(如nginx,uWSGI等服務(wù)器)與web應(yīng)用(如用Flask框架寫的程序)通信的一種規(guī)范。
  2. uwsgi是一種線路協(xié)議而不是通信協(xié)議,在此常用于在uWSGI服務(wù)器與其他網(wǎng)絡(luò)服務(wù)器的數(shù)據(jù)通信。
  3. 而uWSGI是實(shí)現(xiàn)了uwsgi和WSGI兩種協(xié)議的Web服務(wù)器。
  4. uwsgi協(xié)議是一個(gè)uWSGI服務(wù)器自有的協(xié)議,它用于定義傳輸信息的類型(type of information),每一個(gè)uwsgi packet前4byte為傳輸信息類型描述,它與WSGI相比是兩樣?xùn)|西。

?uwsgi性能非常高

uWSGI的主要特點(diǎn)如下

  1. 超快的性能
  2. 低內(nèi)存占用(實(shí)測(cè)為apache2的mod_wsgi的一半左右)
  3. 多app管理(終于不用冥思苦想下個(gè)app用哪個(gè)端口比較好了-.-)
  4. 詳盡的日志功能(可以用來分析app性能和瓶頸)
  5. 高度可定制(內(nèi)存大小限制,服務(wù)一定次數(shù)后重啟等)

總而言之uwgi是個(gè)部署用的好東東,正如uWSGI作者所吹噓的:

If you are searching for a simple wsgi-only server, uWSGI is not for you, but if you are building a real (production-ready) app that need to be rock-solid, fast and easy to distribute/optimize for various load-average, you will pathetically and morbidly fall in love (we hope) with uWSGI.

Uwsgi 安裝使用

1 # Install the latest stable release:
2 pip install uwsgi
3 # ... or if you want to install the latest LTS (long term support) release,
4 pip install https://projects.unbit.it/downloads/uwsgi-lts.tar.gz
安裝uwsgi

基本測(cè)試

Create a file called?test.py:

# test.py
def application(env, start_response):start_response('200 OK', [('Content-Type','text/html')])return [b"Hello World"] # python3#return ["Hello World"] # python2

運(yùn)行

uwsgi --http :8000 --wsgi-file test.py

用uwsgi啟動(dòng)Django

uwsgi --http :8000 --module midware.wsgi

可以把參數(shù)寫到配置文件uwsgi.ini

[uwsgi]
http = :9000
# the local unix socket file than commnuincate to Nginx
socket = 127.0.0.1:8001
# the base directory (full path)
chdir = /home/ubuntu/midware
# Django's wsgi file
wsgi-file = midware/wsgi.py
# maximum number of worker processes
processes = 4
# thread numbers startched in each worker process
threads = 2
# monitor uwsgi status
stats = 127.0.0.1:9191
# clear environment on exit
vacuum = true

用uwsgi啟動(dòng)Django

ubuntu@ubuntu:~/midware$ uwsgi uwsgi.ini

?用uwsgitop監(jiān)控

安裝uwsgitop

sudo pip3 install uwsgitop

進(jìn)行監(jiān)控

uwsgitop  :9191   #9191是配置文件中的監(jiān)控進(jìn)行127.0.0.1:9191  

安裝Nginx

sudo apt-get install nginx
sudo /etc/init.d/nginx start    # start nginx
sudo /etc/init.d/nginx restart    # restart nginx

為你的項(xiàng)目生成Nginx配置文件

You will need the?uwsgi_params?file, which is available in the?nginx?directory of the uWSGI distribution, or from?https://github.com/nginx/nginx/blob/master/conf/uwsgi_params

Copy it into your project directory. In a moment we will tell?nginx?to refer to it.

Now create a file called mysite_nginx.conf, and put this in it:

# uwsgi_params   #把這個(gè)文件從/etc/nginx/拷貝到項(xiàng)目midware下。
[uwsgi] http = :9000 # the local unix socket file than commnuincate to Nginx socket = 127.0.0.1:8001 # the base directory (full path) chdir = /home/ubuntu/midware # Django's wsgi file wsgi-file = midware/wsgi.py #每個(gè)Django項(xiàng)目都會(huì)有一個(gè)名為wsgi.py的文件。 # maximum number of worker processes processes = 4 # thread numbers startched in each worker process threads = 2 # monitor uwsgi status stats = 127.0.0.1:9191 #uwsgitop監(jiān)控的就是它 # clear environment on exit vacuum = true
文件mysite_nginx.conf
# 放到/etc/nginx/sites-enabled下,或者放到項(xiàng)目midware下,然后鏈接到/etc/nginx/sites-enabled(建立短鏈接ln -s mysite_nginx.conf /etc/nginx/sites-enabled/)# mysite_nginx.conf# the upstream component nginx needs to connect to
upstream django {# server unix:///path/to/your/mysite/mysite.sock; # for a file socketserver 127.0.0.1:8001; # for a web port socket (we'll use this first)    #uwsgi.ini中的the local unix socket(socket = 127.0.0.1:8001)
}# configuration of the server
server {# the port your site will be served onlisten      8000;      #用戶訪問的端口# the domain name it will serve forserver_name .example.com; # substitute your machine's IP address or FQDN    #服務(wù)器名稱charset     utf-8;# max upload sizeclient_max_body_size 75M;   # adjust to taste   #用戶請(qǐng)求最大為75M# Django medialocation /media  {alias /path/to/your/mysite/media;  # your Django project's media files - amend as required}location /static {alias /home/ubuntu/midware/static; # your Django project's static files - amend as required   #靜態(tài)文件路徑}# Finally, send all non-media requests to the Django server.location / {uwsgi_pass  django;include     /home/ubuntu/midware/uwsgi_params; # the uwsgi_params file you installed    #把這個(gè)文件放到項(xiàng)目目錄,或者/etc/nginx/sites-enabled/uwsgi_params}
}

啟動(dòng)uwsgi、重啟Nginx

...

Deploying static files

Before running?nginx, you have to collect all Django static files in the static folder. First of all you have to edit mysite/settings.py adding:

# 文件settings.py
DEBUG = False #生成環(huán)境中不能用DEBUG模式


STATIC_ROOT = os.path.join(BASE_DIR, "all_tatic_files")
?#把所有靜態(tài)文件放到一個(gè)文件夾下,注意不要與"static"重名,否則會(huì)被覆蓋。

?

?最后執(zhí)行

python manage.py collectstatic   #合并靜態(tài)文件

不要忘了,修改mysite_nginx.conf中的靜態(tài)文件配置

 啟動(dòng)uwsgi、重啟Nginx

?

轉(zhuǎn)載于:https://www.cnblogs.com/yangxiaoling/p/6831530.html

總結(jié)

以上是生活随笔為你收集整理的xshell连接Linux、ngix部署的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網(wǎng)站內(nèi)容還不錯(cuò),歡迎將生活随笔推薦給好友。

主站蜘蛛池模板: 阿v免费在线观看 | 久久久久久久性 | 国产小视频在线 | 黄色免费网站在线观看 | 中文在线字幕 | 日韩一级二级 | 欧美xo影院 | 精品无码久久久久久久久成人 | 精品一区二区在线免费观看 | 国产日韩精品在线 | av秋霞| 日本久久不卡 | 我们2018在线观看免费版高清 | 国产精品高潮呻吟久久 | 国产1区2区 | 激情av中文字幕 | 日批在线观看 | 欧美午夜视频 | 天天干天天插天天操 | 国产裸体美女永久免费无遮挡 | 图片区偷拍区小说区 | exo妈妈mv在线播放免费 | 日韩精品一区在线 | 亚洲精品小视频在线观看 | 黄色大全免费看 | 日韩欧美在线一区 | 色综合av综合无码综合网站 | 性久久久久久久久久 | 国内精久久久久久久久久人 | 黄色理论片 | 天天摸天天添 | 瑟瑟久久 | 亚洲国产高清国产精品 | 成人av在线一区二区 | 麻豆影视免费观看 | 国产精品3 | 亚洲av无码一区二区三区性色 | 日本精品久久久久久久 | 91精品久久久久久久久 | 免费中文av | 国产精品美女在线观看 | 韩国av一区二区 | 视频国产精品 | 日日骚网| 男人和女人日b视频 | 亚洲综合网址 | 精品国产免费人成在线观看 | 国产这里有精品 | 亚洲精品无人区 | 99xav | 无码人妻一区二区三区线 | 亚洲一区二区三区欧美 | 亚洲欧美日韩中文在线 | 亚洲欧美一级 | 一本色道久久综合亚洲二区三区 | 日韩精品成人一区二区在线 | 中日一级片 | 日日摸日日干 | 日韩在线精品强乱中文字幕 | 色婷婷www | 色av资源| 欧美一区二区在线视频 | 熟女人妻aⅴ一区二区三区60路 | 一级毛片基地 | 国产伦理一区二区三区 | 欧色av | 久久久免费高清视频 | 人妻大战黑人白浆狂泄 | 成人欧美一区二区三区黑人动态图 | 国产精品久久亚洲 | 精品国产99久久久久久 | 久久久久毛片 | 成人免费高清视频 | 国产18在线 | av免费在线观 | 欧洲视频在线观看 | 久久久久国产一区 | 精品久久久久一区二区国产 | 久久香蕉影视 | 日韩精品一区在线视频 | 色狗网站 | 久久精品二区 | 亚洲欧美一区二区三区情侣bbw | 国内免费毛片 | 国产欧美精品一区二区在线播放 | 国产精品 欧美精品 | 国产一区二区在线观看免费 | 91精品国产综合久久久久久久 | 一个人在线观看www软件 | 一道本在线观看 | 特a级黄色片 | 精品人妻一区二区三区久久夜夜嗨 | 九一在线观看免费高清视频 | 一区二区国产在线观看 | 国产乱码视频 | 京香julia在线观看 | 美女污污网站 | 亚洲国产精品免费 | 啪啪视屏 |