Django 快速部署CentOS,Nginx,uWsgi,Supervisor

安裝必用包

方式一: shell安裝

復(fù)制安裝包腳本到您的主機

$ vim django_deplyment.sh
$ chmod +x  django_deplyment.sh
$ ./django_deplyment.sh

方式二: 手動安裝

安裝python3
$ yum -y install python36
安裝Git
$ yum -y install git
安裝setuptools
$ yum -y install python36-setuptools
安裝pip

https://pypi.org/project/pip/
pip 18 下載地址

下載 
$ wget --no-check-certificate  https://files.pythonhosted.org/packages/45/ae/8a0ad77defb7cc903f09e551d88b443304a9bd6e6f124e75c0fbbf6de8f7/pip-18.1.tar.gz
解壓 
$ tar -zxvf pip-18.1.tar.gz
$ cd pip-18.1/
$ python36 setup.py build
$ python36 setup.py install
安裝gcc
$ yum -y install gcc
安裝 python36-devel
$ yum -y  install python36-devel.x86_64
安裝uwsgi
$ pip3 install uwsgi
安裝supervisor
$ yum -y install supervisor

配置supervisor
$ vim /etc/supervisord.conf
------在這個最后面添加Program-----
[include]
files = supervisord.d/*.ini
>>開始添加 (本行忽略)
[program: 您的項目名稱]
command=uwsgi --socket :8000 --chdir /項目地址/ -w 項目名稱.wsgi
autostart=true
autorestart=true
安裝nginx
$ yum -y install nginx

配置nginx
$ vim /etc/nginx/nginx.conf 
--------修要修改位置------
    server {
        listen       80 default_server; # 修改成您的端口
        listen       [::]:80 default_server; # 修改成您的端口
        server_name  您的ip地址; # 修改成您的地址
        root         /usr/share/nginx/html;
        # Load configuration files for the default server block.
        include /etc/nginx/default.d/*.conf;
      location /static {
                alias /項目地址/static;
        }
        location / {
                include uwsgi_params;
                uwsgi_pass 127.0.0.1:8000;
        }
       
    }
-------結(jié)束---------
$ nginx -t 檢查

啟動

$ nginx
$ supervisord
最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時請結(jié)合常識與多方信息審慎甄別。
平臺聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點,簡書系信息發(fā)布平臺,僅提供信息存儲服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

友情鏈接更多精彩內(nèi)容