如果使用默認的python 首先安裝程序需要的包
apt-get install python-dev
apt-get install python-pip
apt-get install net-tools
apt-get install lsof
安裝數據庫
apt-get install mysql-server
apt-get install mysql-client
apt-get install libmysqlclient-dev
更新pip版本
pip install --upgrade pip
apt-get install openssh-server
apt-get install nginx
pip install uwsgi
修改Django項目的配置文件
DEBUG = False
ALLOWED_HOSTS = ["*"]
在django的setting文件中,添加下面一行內容:
STATIC_ROOT = os.path.join(BASE_DIR, "static")
然後運行(收集admin後臺的靜態文件,如果不收集,將來訪問linux的blog的admin將沒有樣式):
Python manage.py collectstatic
上傳好項目之後
python3 manage.py runserver
確定項目能跑起來
進入項目目錄 新建uwsgi.ini文件 touch uwsgi.ini,修改配置文件 注意socket端口一定要和nginx配置中的端口保持一致
/etc/nginx/conf.d/下創建項目配置文件xxx.conf,編輯配置文件,之一uwsgi_pass要和uwsgi.ini中的端口一致,配置完成後執行service nginx restart重啓nginx服務
進入項目uwsgi所在目錄,執行uwsgi --ini xxx.ini 啓動項目
其中遇到了一個錯誤
no request plugin is loaded, you will not be able to manage requests.
you may need to install the package for your language of choice, or simply load it with --plugin.
查閱之後下載了 uwsgi-plugin-python
apt-get install uwsgi-plugin-python
但是並沒有什麼用。然後找了半天將其中的python改爲python3 成功!
默認下載的是uwsgi-plugin-python2版本的
我用的是自帶的python3.5
吶 就醬