/把python3.6安裝到 /user/local目錄
.
/configure --prefix=
/usr/local
make
make altinstall
更改/user/bin/python鏈結
ln -s /usr/local/bin/python3.
6/usr/bin/python3
如果:linux伺服器報錯:ln: failed to create symbolic link 『/usr/bin/python』: file exists
重新輸入:ln -sf /usr/local/bin/python3.
7/usr/bin/python3
1. 安裝
sudo yum install mariadb-server
//linux 檢視程序:ps aux | grep mysql
2. 啟動, 重啟
sudo systemctl start mariadb
sudo systemctl restart mariadb
//進入mqsql互動環境:mysql -uroot
3. 設定bind-ip
vim /etc/my.cnf
//之後按i進去配置
在 [mysqld]:
下面加一行
bind-address = 0.0.0.0
4. 設定外部ip可以訪問
先進入mysql互動環境才能執行下面命令:
grant all privileges on *
.* to 'root'@'%' identified by '123456' with grant option;
grant all privileges on *
.* to 'root'@'localhost' identified by '123456' with grant option;
flush privileges /
/重新整理許可權 必須要執行
5. 設定阿里雲的對外埠
6. 安裝mysqlclient出問題
centos 7:
yum install python-devel mariadb-devel -y
ubuntu:
sudo apt-get install libmysqlclient-dev
然後:pip install mysqlclient
7.安裝redis
yum install redis
service redis start
//sudo systemctl start redis 啟動
//sudo systemctl restart redis 重啟
https:/
編輯.bashrc檔案 /
/vim ~/
.bashrc
export workon_home=$home
/.virtualenvs
/如果不在此目錄 可以sudo find /
source ~/
.bashrc
新建虛擬環境
mkvirtualenv -p python3 mxonline
進入虛擬環境
workon mxonline
檔案上傳後:
安裝pip包
我們可以通過 pip freeze > requirements.txt 將本地的虛擬環境安裝包相信資訊匯出來
然後將requirements.txt檔案上傳到伺服器之後執行:
pip install -r requirements.txt
安裝依賴包
pip install uwsgi
uwsgi --http :8000 --module mxonline.wsgi
新建uc_nginx.conf
# the upstream component nginx needs to connect to
upstream django
# configuration of the server
server
location /static
# finally, send all non-media requests to the django server.
location /
}
sudo ln -s 你的目錄/mxonline/conf/nginx/uc_nginx.conf /etc/nginx/conf.d/
在django的setting檔案中,新增下面一行內容:
static_root = os.path.join(base_dir,
"static/"
)執行命令
python manage.py collectstatic
sudo /usr/sbin/nginx
新建uwsgi.ini 配置檔案, 內容如下:
# mysite_uwsgi.ini file
[uwsgi]
# django-related settings
# the base directory (full path)
chdir = /home/bobby/projects/mxonline
# django's wsgi file
module = mxonline.wsgi
# the virtualenv (full path)
# process-related settings
# master
master = true
# maximum number of worker processes
processes = 10
# the socket (use the full path to be safe
socket = 127.0.0.1:8000
# chmod-socket = 664
# clear environment on exit
vacuum = true
virtualenv = /home/bobby/
.virtualenvs/mxonline
logto = /tmp/mylog.log
注: chdir: 表示需要操作的目錄,也就是專案的目錄
module: wsgi檔案的路徑
processes: 程序數
virtualenv:虛擬環境的目錄
workon mxonline
uwsgi -i 你的目錄/mxonline/conf/uwsgi.ini &
Django部署問題
1.專案settings.py中須有如下設定 base dir os.path.dirname os.path.dirname os.path.abspath file debug true allowed hosts 靜態檔案路徑 static url static static root os....
Django 環境部署
命令列輸入 python m venv 11 env windows系統 啟用虛擬環境 11 env scripts activate停止使用虛擬環境 deactivate安裝django pip install djangodjango中建立專案 django admin.py startproj...
部署django應用
django開發時只需要python就能完成,利用其自帶的開發服務,可以方便在開發環境執行起應用,但部署於生產時則需要一些額外的操作。首先是配置的修改,settings.py裡有些最小配置需要修改 static root os.path.join os.getcwd static allowed h...