ubuntu16.04 配置爬蟲環境
MySQL
安裝
sudo apt-get install mysql-server(若安裝有誤,則update再安裝,記得設置root密碼)
配置
遠程訪問:1 進入/etc/mysql 找到my.cnf指向的倆個路徑,進入其中一個更改bind為0.0.0.0或者註釋掉;
2 進入mysql,通過命令grant all privileges on *.* to "user_name"@"user_ip" identified by "user_password"; 即賦予某用戶,在所有數據庫下的所有權限 (可更改)最後記得刷新flush privileges;
檢查mysql是否啟動:ps -ef | grep mysqld
mysql的啟動,重啟和停止:service mysql start,restart,stop 或者systemctl start,restart,stop mysql(系統不同操作不同)
mysql編碼問題(默認為latin1,以改為uft8為例改為):進入/etc/mysql下,進入my.cnf查看其中倆條路徑,進入conf.d 下進入mysql.cnf 添加 default-character-set =utf8,保 存退出
數據庫,表,字段的編碼見sql語句
Redis
安裝
sudo apt-get install redis-server
配置
遠程訪問:進入redis.conf文件中,如若要允許所有訪問 註釋掉bind 127.0.0.1(redis 3.2後,protected-mode no) 或者更改為bind 0.0.0.0 若指定多個ip可在bind後面· 添加
redis的啟動,重啟和停止:service redis start,restart,stop 或者systemctl start,restart,stop redis(系統不同操作不同)
pycharm
去pycharm官網安裝linux版本,解壓,在 pycharm.sh路徑中通過./pycharm.sh啟動pycharm(綁定pycharm在啟動欄,一勞永逸)
python
Ubuntu自帶python2.7和python3.5,以python3為例
安裝pip sudo apt-get install python3-pip
升級pip sudo pip3 install --upgrade pip
ubuntu下pip很方便,安裝包很少出現依賴問題,最多出現timeout
豆瓣源 http://pypi.douban.com/simple
具體使用 pip3 install -i http://pypi.douban.com/simple this_package
docker
安裝
sudo apt-get install docker
sudo apt-get install docker.io
配置共享文件:sudo docker run -tiv 主機path:docker path image_id /bin/bash
防火墻
可安裝ufw
sudo apt-get install ufw
ufw stauts 顯示防火墻狀態
ufw enable 開啟防火墻
ufw disable 關閉
ufw allow 80 允許外部80端口訪問
ufw delete allow 80 禁止。。。。。。
ufw allow from 127.12.1.1 允許這個ip下所有端口的訪問%
ufw deny smtp 禁止 外部smtp訪問
ubuntu16.04 配置爬蟲環境