一、允許遠程連接 sudo apt-get install ssh #安裝遠程ssh服務 service ssh start #啟動遠程ssh連接服務 二、更換更新源 1)備份原文件 sudo cp /etc/apt/sources.list /etc/apt/sources.list.bak 2) ...
一、允許遠程連接
sudo apt-get install ssh #安裝遠程ssh服務
service ssh start #啟動遠程ssh連接服務
二、更換更新源
1)備份原文件
sudo cp /etc/apt/sources.list /etc/apt/sources.list.bak
2)編輯更新源,替換成國內的地址
sudo gedit /etc/apt/sources.list
阿裡雲源
# deb cdrom:[Ubuntu 16.04 LTS _Xenial Xerus_ - Release amd64 (20160420.1)]/ xenial main restricted
deb-src http://archive.ubuntu.com/ubuntu xenial main restricted #Added by software-properties
deb http://mirrors.aliyun.com/ubuntu/ xenial main restricted
deb-src http://mirrors.aliyun.com/ubuntu/ xenial main restricted multiverse universe #Added by software-properties
deb http://mirrors.aliyun.com/ubuntu/ xenial-updates main restricted
deb-src http://mirrors.aliyun.com/ubuntu/ xenial-updates main restricted multiverse universe #Added by software-properties
deb http://mirrors.aliyun.com/ubuntu/ xenial universe
deb http://mirrors.aliyun.com/ubuntu/ xenial-updates universe
deb http://mirrors.aliyun.com/ubuntu/ xenial multiverse
deb http://mirrors.aliyun.com/ubuntu/ xenial-updates multiverse
deb http://mirrors.aliyun.com/ubuntu/ xenial-backports main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ xenial-backports main restricted universe multiverse #Added by software-properties
deb http://archive.canonical.com/ubuntu xenial partner
deb-src http://archive.canonical.com/ubuntu xenial partner
deb http://mirrors.aliyun.com/ubuntu/ xenial-security main restricted
deb-src http://mirrors.aliyun.com/ubuntu/ xenial-security main restricted multiverse universe #Added by software-properties
deb http://mirrors.aliyun.com/ubuntu/ xenial-security universe
deb http://mirrors.aliyun.com/ubuntu/ xenial-security multiverse
3)讓更新源生效
sudo apt-get update
三、安裝mysql並允許遠程連接
1、安裝上服務
sudo apt-get install mysql-server
sudo apt-get install mysql-client
sudo apt-get install libmysqlclient-dev
2、修改mysql配置文件,將bind-address=127.0.0.1註釋掉
sudo /etc/mysql/mysql.conf.d/mysqld.cnf
a、進入mysql
mysql -u root -p
b、修改許可權
grant all privileges on *.* to 'root'@'%' identified by 'root' with grant option;
c、刷新訪問許可權
flush privileges;
d、重啟mysql服務
sudo /etc/init.d/mysql restart
四、安裝vim編輯器
sudo apt-get install vim
五、安裝java環境
sudo add-apt-repository ppa:webupd8team/java
sudo apt-get update
sudo apt-get install oracle-java8-installer
java -version
sudo apt-get install oracle-java8-set-default
sudo echo JAVA_HOME="/usr/lib/jvm/java-8-oracle"
source /etc/environment
六、安裝虛擬環境下的各種插件
1、安裝虛擬環境
安裝pip和pip3: sudo apt-get install python-pip sudo apt-get install python3-pip
1) sudo pip install virtualenv
2) sudo pip install virtualenvwrapper
3) mkdir ~/.virtualenvs
4) sudo vim ~/.bashrc
末尾增加以下兩行
export WORKON_HOME=$HOME/.virtualenvs # 所有虛擬環境存儲的目錄
source /usr/local/bin/virtualenvwrapper.sh
5) source ~/.bashrc
6) sudo chmod 777 /home/yufeng/.virtualenvs
7) 創建py2或py3的虛擬環境
mkvirtualenv -p /usr/bin/python3 env_name
mkvirtualenv -p /usr/bin/python2 env_name
8) 運行虛擬環境
workon env_name
workon + 兩次tab鍵可以顯示所有的虛擬環境
9) 退出虛擬環境
deactivate
10) 刪除虛擬環境
rmvirtualenv env_name
2、安裝paramiko [ssh的方式管理遠程伺服器]
sudo pip3 install pycrypto
sudo pip install paramiko
3、安裝django1.8.2
sudo pip3 install django==1.8.2
4、安裝分散式爬蟲
sudo pip install scrapy
5、科學計算和數學工作基礎包
sudo pip3 install numpy
6、封裝了微信API的python擴展庫
sudo pip3 install itchat
7、關係型資料庫 sqlAlchemy
sudo pip3 install SQLAlchemy
8、網路模塊方面(協程、多進程)
sudo pip3 install Greenlet
sudo pip3 install Gevent
9、RabbitMQ隊列(消息分發、過濾發送等)
sudo pip3 install pika
10、非同步框架jinja2
sudo pip3 install aiohttp
sudo pip3 install aiomysql
sudo pip3 install jinja2
11、安裝非關係型資料庫redis
特征:記憶體級讀寫,宕機可能丟失數據,運用於主從 和 訂閱
1)redis官網下載redis-3.2.5.tar.gz
2)解壓到指定目錄下
tar zxvf redis-3.2.5.tar.gz
sudo mv -r redis-3.2.5/* /usr/local/redis/
3)生成
cd /usr/local/redis/
sudo make
4)測試
sudo make test
5)將redis的命令安裝到/usr/bin/目錄
sudo make install
6)配置redis配置文件
sudo vim /usr/local/redis/redis.conf
"daemonize yes #以守護進程運行"
"dbfilename dump.rdb"
"dir /var/lib/redis"
"bind 127.0.0.1" #註釋掉此行,以便其他伺服器連接
"bind 192.168.0.131" #綁定本地機器的實際IP地址
7)複製配置文件到/etc/redis/下
sudo cp /usr/local/redis/redis.conf /etc/redis/
8)配置文件方式啟動
sudo redis-server /etc/redis/redis.conf
9)啟動客戶端
redis-cli -h 192.168.0.131
10)停止redis服務
ps ajx|grep redis
sudo kill -9 redis的進程id
12、安裝celery非同步發送請求
sudo pip3 install celery==3.1.25
sudo pip3 install celery-with-redis==3.0
sudo pip3 install django-celery==3.1.17
sudo pip3 install itsdangerous # 用於生成郵件激活的token
sudo pip3 install django_redis==4.4.2
pip install mutagen
pip install requests
與django的結合,django用celery來處理非同步的任務,將django項目拷貝到celery伺服器當中,再在django項目目錄下開啟celery服務:
celery -A celery_tasks.tasks worker -l info
13、安裝富文本
sudo pip3 install django-tinymce==2.6.0
14、文件上傳伺服器搭建fastdfs以及nginx安裝
安裝成功後啟動:
sudo service fdfs_trackerd start
sudo service fdfs_storaged start
或者以下兩個命令:
sudo /etc/init.d/fdfs_trackerd start
sudo /etc/init.d/fdfs_storaged start
nginx啟動:sudo /usr/local/nginx/sbin/nginx
nginx重啟:sudo /usr/local/nginx/sbin/nginx -s reload
1)各項資料
libfastcommon-master.zip
fastdfs-master.zip
nginx-1.8.1.tar.gz
fdfs_client-py-master.zip
fastdfs-nginx-module-master.zip
2)進入到libfastcommon-master目錄中
執行./make.sh
執行 sudo ./make.sh install
3)進入到fastdfs-master目錄中
執行./make.sh
執行 sudo ./make.sh install
4)配置跟蹤伺服器tracker
sudo cp /etc/fdfs/tracker.conf.sample /etc/fdfs/tracker.conf
mkdir -p /home/python/fastdfs/tracker
sudo vim /etc/fdfs/tracker.conf
"base_path=/home/python/fastdfs/tracker"
5)配置存儲伺服器storage
sudo cp /etc/fdfs/storage.conf.sample /etc/fdfs/storage.conf
mkdir -p /home/python/fastdfs/storage
sudo vim /etc/fdfs/storage.conf
“base_path=/home/python/fastdfs/storage”
“store_path0=/home/python/fastdfs/storage”
“tracker_server=自己ubuntu虛擬機的ip地址:22122”
6)啟動tracker和storage
sudo /etc/init.d/fdfs_trackerd start
sudo /etc/init.d/fdfs_storaged start
7)測試是否安裝成功
sudo cp /etc/fdfs/client.conf.sample /etc/fdfs/client.conf
sudo vim /etc/fdfs/client.conf
“base_path=/home/python/fastdfs/tracker”
“tracker_server=自己ubuntu虛擬機的ip地址:22122”
fdfs_upload_file /etc/fdfs/client.conf 213.jpg # 本地的某張圖片
若返回類似group1/M00/00/00/wKgAg1qxQKqAdXu1AACI7goZ_PA832.jpg這樣的,則表示上傳成功。
8)安裝nginx
sudo apt-get update
sudo apt-get install libpcre3 libpcre3-dev
sudo apt-get install openssl libssl-dev
進入nginx-1.8.1目錄
------fastdfs-nginx-module-master解壓後的目錄的絕對路徑/src
sudo ./configure --prefix=/usr/local/nginx/ --add-module=/mnt/hgfs/F/linuxsoft/FastDFS/teacher/fastdfs-nginx-module-master/src
sudo make
sudo make install
------fastdfs-nginx-module-master解壓後的目錄中src下的mod_fastdfs.conf
sudo cp /mnt/hgfs/F/linuxsoft/FastDFS/teacher/fastdfs-nginx-module-master/src/mod_fastdfs.conf /etc/fdfs/mod_fastdfs.conf
sudo vim /etc/fdfs/mod_fastdfs.conf
"connect_timeout=10"
“tracker_server=自己ubuntu虛擬機的ip地址:22122”
url_have_group_name=true
store_path0=/home/python/fastdfs/storage
-------解壓縮的fastdfs-master/ conf目錄中的
sudo cp /mnt/hgfs/F/linuxsoft/FastDFS/teacher/fastdfs-master/conf/http.conf /etc/fdfs/http.conf
sudo cp /mnt/hgfs/F/linuxsoft/FastDFS/teacher/fastdfs-master/conf/mime.types /etc/fdfs/mime.types
sudo vim /usr/local/nginx/conf/nginx.conf
server {
listen 8888;
server_name localhost;
location ~/group[0-9]/ {
ngx_fastdfs_module;
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
}
sudo /usr/local/nginx/sbin/nginx
測試:瀏覽器輸入地址:http://192.168.0.131:8888/group1/M00/00/00/wKgAg1qxQKqAdXu1AACI7goZ_PA832.jpg,若看到剛纔上傳的圖片則表示nginx安裝成功。
15、安裝全文檢索
# 全文檢索框架
pip install django-haystack==2.4.0 #對應django1.8.2
# 全文檢索引擎
pip install whoosh
# 中文分詞框架
pip install jieba