1.安裝python3.5可能使用的依賴
yum install openssl-devel bzip2-devel expat-devel gdbm-devel readline-devel sqlite-devel
或者
yum install zlib-devel bzip2-devel openssl-devel ncurses-devel sqlite-devel readline-devel tk-devel gcc make
wget https://www.python.org/ftp/python/3.5.1/Python-3.5.1.tgz
tar -zxvf Python-3.5.1.tgz
把python移到/usr/local下面
mv Python-3.5.1 /usr/local
刪除舊版本的python依賴
ll /usr/bin | grep python
rm -rf /usr/bin/python
進入python目錄
cd /usr/local/Python-3.5.1/
•配置
./configure
編譯
make
編譯,安裝
make install
刪除舊的軟鏈接,創建新的軟鏈接到最新的python
rm -rf /usr/bin/python
ln -s /usr/local/bin/python3.5 /usr/bin/python
python -V
2.把默認python改成了python3的版本后,yum無法使用
https://blog.csdn.net/u013214212/article/details/81540840
既然把默認python改成了python3的版本,那么這時候yum就出問題了,因為yum貌似不支持python3,開發了這個命令的老哥也不打算繼續寫支持python3的版本了,
所以,如果和python版本相關的文件就不要通過yum下載了,這里我們需要把yum默認的指向改為python2.7的版本,
分別是兩個文件,使用vi打開,輸入i進行修改,修改完之后按esc鍵,然后輸入":wq",這就完成了修改並保存
vi /usr/libexec/urlgrabber-ext-down

vi /usr/bin/yum

這樣我們就完成了新安裝的centos系統中的兩個python版本的全部流程。
在小黑框中輸入python2則調起python2,輸入python,則默認調起python3,pip2調起python2下的pip,pip調起python下的pip。
1.CentOS7安裝圖解
https://www.osyunwei.com/archives/7829.html
2.CentOS 7下安裝Python3.5
https://blog.csdn.net/sinat_14826983/article/details/80350543
yum update
yum install deltarpm -y
4.安裝依賴
yum install -y gcc
yum install gcc-c++
yum -y install zlib zlib-devel openssl openssl--devel pcre pcre-devel
yum install openssl-devel bzip2-devel expat-devel gdbm-devel readline-devel sqlite-devel
wget https://www.python.org/ftp/python/3.5.1/Python-3.5.1.tgz 或者 后面加上--no-check-certificate
tar -zxvf Python-3.5.1.tgz
把python移到/usr/local下面
mv Python-3.5.1 /usr/local
刪除舊版本的python依賴
ll /usr/bin | grep python
rm -rf /usr/bin/python
cd /usr/local/Python-3.5.1/
./configure
make -j6
make install
刪除舊的軟鏈接,創建新的軟鏈接到最新的python
rm -rf /usr/bin/python
ln -s /usr/local/bin/python3.5 /usr/bin/python
python -V
cd /opt
yum(yum命令報錯解決方案)
3.既然把默認python改成了python3的版本后,yum無法使用
https://blog.csdn.net/u013214212/article/details/81540840
既然把默認python改成了python3的版本,那么這時候yum就出問題了,因為yum貌似不支持python3,開發了這個命令的老哥也不打算繼續寫支持python3的版本了,
所以,如果和python版本相關的文件就不要通過yum下載了,這里我們需要把yum默認的指向改為python2.7的版本,
分別是兩個文件,使用vi打開,輸入i進行修改,修改完之后按esc鍵,然后輸入":wq",這就完成了修改並保存
vi /usr/libexec/urlgrabber-ext-down
vi /usr/bin/yum
wget -c https://nginx.org/download/nginx-1.12.0.tar.gz
tar -zxvf nginx-1.12.0.tar.gz
cd nginx-1.12.0/
./configure
make -j6
make install
pip3 install --upgrade pip
pip3 install -r requirements.txt
pip3 install uwsgi
pip3 install django==1.9.8 或 pip3 install django==1.11.1
pip3 install xadmin
pip3 install future
pip3 install django_crispy_forms
pip3 install django-formtools
pip3 install httplib2
pip3 install six
pip3 install django_import_export
pip3 install django-cors-headers
pip3 install django-pure-pagination
pip3 install requests
pip3 install pymysql
pip3 install apscheduler==2.1.2
yum install python-devel zlib-devel libjpeg-turbo-devel -y
pip3 install Pillow
#部署項目
mkdir /opt/script/
cp conf/my.http.flv.live.conf /usr/local/srs/conf/
cp conf/srs.conf /usr/local/srs/conf/
cp conf/touch.conf /usr/local/nginx/conf/
cp conf/touch.ini /opt/script/
rm /opt/touch/ -rf
cp touch/ /opt/ -rf
cp conf/run.sh /opt/
mkdir /mnt/disk/
mkdir /mnt/disk/nginx
mkdir /usr/local/nginx/html
mkdir /usr/local/nginx/html/images/
mkdir /mnt/disk/nginx/html/images/
cp touch/tmp/* /usr/local/nginx/html/images/
cp images/* /usr/local/nginx/html/images/
5.檢查依賴 pip freeze > requirements.txt
安裝依賴 pip3 install -r requirements.txt
pip3 install django==1.9.8 或 pip3 install django==1.11.1(centos7.6)
xadmin
future
django_crispy_forms
httplib2
six
django_import_export
Pillow
django-cors-headers
django-pure-pagination
django-formtools
requests
pymysql
apscheduler==2.1.2
centos7.4
pip3 install Django==1.11.1
pip3 install django-cors-headers==2.5.2
pip3 install django-crispy-forms==1.7.2
pip3 install django-formtools==2.1
pip3 install django_import_export
pip3 install django-pure-pagination==0.3.0
pip3 install future==0.17.1
pip3 install httplib2==0.9.2
pip3 install --upgrade pip
pip3 install Pillow==5.4.1
pip3 install PyMySQL==0.9.3
pip3 install requests==2.21.0
pip3 install six==1.12.0
pip3 install urllib3==1.24.1
pip3 install uWSGI==2.0.18
pip3 install xadmin==0.6.1
pip3 install xlrd==1.2.0
pip3 install xlwt==1.3.0
偶爾出現在centos7的問題,會出現ImportError: cannot import name MiddlewareMixin
解決方法 安裝 pip3 install Django==1.11.1
然而又出現下面 ImportError: cannot import name patterns
vim touch/extra_apps/DjangoUeditor/urls.py
# coding:utf-8
from django import VERSION
if VERSION[0:2] > (1, 3):
from django.conf.urls import patterns, url
else:
from django.conf.urls.defaults import patterns, url
from .views import get_ueditor_controller
urlpatterns = [
url(r'^controller/$', get_ueditor_controller)
]
改為:
# coding:utf-8
from django import VERSION
if VERSION[0:2] > (1, 3):
from django.conf.urls import url
else:
from django.conf.urls.defaults import url
from .views import get_ueditor_controller
urlpatterns = [
url(r'^controller/$', get_ueditor_controller)
]
6.可能遇到的問題
render_to_string() got an unexpected keyword argument 'context_instance'
https://blog.csdn.net/HeatDeath/article/details/70312915
context must be a dict rather than RequestContext.
就是context變為
{
"context":context
}
systemctl disable firewalld.service
7.啟動腳本
pkill -9 nginx
pkill -9 srs
pkill -9 uwsgi
cd /usr/local/nginx/
./sbin/nginx -c conf/touch.conf &
cd /usr/local/srs/
./objs/srs -c conf/my.http.flv.live.conf > /dev/null &
cd /opt/
uwsgi --ini script/touch.ini &
yum install -y git
srs官方文檔:https://github.com/ossrs/srs/wiki/v2_CN_SampleHttp
第一步,獲取SRS。詳細參考GIT獲取代碼
git clone https://github.com/ossrs/srs
cd srs/trunk
第二步,編譯SRS。詳細參考Build
./configure && make
編譯好后,make install
然后復制目錄
\cp -r ./objs/ /usr/local/srs/
\cp -r ./objs/nginx/ /usr/local/srs/objs/
創建軟鏈接
ln -sf /usr/local/srs/etc/init.d/srs /etc/init.d/srs
chkconfig --add srs
編譯好后,make install
然后復制目錄
\cp -r ./objs/ /usr/local/srs/
\cp -r ./objs/nginx/ /usr/local/srs/objs/
創建軟鏈接
ln -sf /usr/local/srs/etc/init.d/srs /etc/init.d/srs
chkconfig --add srs
8.配置腳本自啟動
1、賦予腳本可執行權限(/opt/script/run.sh是你的腳本路徑)
chmod +x /opt/script/run.sh
chmod +x /opt/run.sh
2 編輯 vim /etc/rc.d/rc.local文件,在末尾增加如下內容
/opt/script/run.sh
/opt/run.sh
3、在centos7中,/etc/rc.d/rc.local的權限被降低了,所以需要執行如下命令賦予其可執行權限
chmod +x /etc/rc.d/rc.local
9.安裝redis
yum install redis
service redis start 或 systemctl start redis.service
chkconfig redis on
reboot重啟,觀看效果。
