【教程】Ubuntu20.04 + VirtualBox 各种软件环境安装
目錄
教程
添加用戶和用戶組
安裝SSH
apt換源
pip換源
升級Python
開啟遠程桌面(windows連接,desktop版ubuntu)
升級CMake3.22
安裝Samba
安裝Mosquitto MQTT
安裝EMQX MQTT
安裝Redis
安裝LAMP
安裝typecho
安裝g20
關閉搜索,節省內存
VirtualBox開啟雙屏
VirtualBox增加磁盤內存
清理apt無用源
安裝NVIDIA驅動
安裝mosquitto
安裝LAMP
安裝字體
安裝Conda
Conda換源
安裝x2go
報錯
Can't initialize GTK backend in function 'cvInitSystem'
ssh REMOTE HOST IDENTIFICATION HAS CHANGED
歡迎關注公眾號:小鋒學長生活大爆炸
教程
添加用戶和用戶組
添加用戶
sudo adduser <username>添加sudo權限
sudo usermod -G sudo <username>添加root權限
sudo vim /etc/sudoers修改添加:
# User privilege specification root ALL=(ALL) ALL <username> ALL=(ALL) ALL安裝SSH
sudo apt install openssh-server sudo systemctl status ssh如果ssh連不上桌面版Ubuntu,記得這里開一下:
apt換源
備份:
cp /etc/apt/sources.list /etc/apt/sources.list.bk修改:
sudo rm /etc/apt/sources.list sudo vim /etc/apt/sources.list注意根據不同版本:ubuntu | 鏡像站使用幫助 | 清華大學開源軟件鏡像站 | Tsinghua Open Source Mirror
填入:
# 默認注釋了源碼鏡像以提高 apt update 速度,如有需要可自行取消注釋 deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal main restricted universe multiverse # deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal main restricted universe multiverse deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal-updates main restricted universe multiverse # deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal-updates main restricted universe multiverse deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal-backports main restricted universe multiverse # deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal-backports main restricted universe multiverse deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal-security main restricted universe multiverse # deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal-security main restricted universe multiversepip換源
mkdir ~/.pip sudo vim ~/.pip/pip.conf輸入:
[global] index-url = https://pypi.tuna.tsinghua.edu.cn/simple升級Python
不推薦手動升級,容易出問題。還是上anaconda吧。
sudo apt update sudo apt install software-properties-common sudo apt install python3.7 sudo update-alternatives --install /usr/bin/python3 python3 /usr/bin/python3.6 1 sudo update-alternatives --install /usr/bin/python3 python3 /usr/bin/python3.7 2 sudo update-alternatives --config python3 # 選Python3.7那個 sudo apt-get remove python3-apt sudo apt-get install python3-apt開啟遠程桌面(windows連接,desktop版ubuntu)
安裝xdrp
sudo apt-get install xrdp一旦安裝完成,Xrdp 服務將會自動啟動。你可以輸入下面的命令,驗證它:
sudo systemctl status xrdp默認情況下,Xrdp 使用/etc/ssl/private/ssl-cert-snakeoil.key,它僅僅對“ssl-cert” 用戶組成語可讀。運行下面的命令,將xrdp用戶添加到這個用戶組:
sudo adduser xrdp ssl-cert重啟 Xrdp 服務,使得修改生效:
sudo systemctl restart xrdp?打開win10遠程連接,進行連接。這里的用戶名填寫你系統的用戶名,密碼填寫設置共享桌面的密碼
如果黑屏,可以先注銷原有的用戶登錄(也就是另一個地方已經登錄了這個用戶了,需要先注銷登錄)。
升級CMake3.22
?下載
wget https://cmake.org/files/v3.22/cmake-3.22.0-rc2-linux-x86_64.tar.gz解壓
tar zxvf CMake-3.22.0-rc2-linux-x86_64.tar.gz編譯安裝
cd CMake-3.22.0-rc2 cmake . make sudo make install更新
sudo update-alternatives --install /usr/bin/cmake cmake /usr/local/bin/cmake 1 --force查看
cmake --version?刪除安裝包
cd .. rm CMake-3.22.0-rc2-linux-x86_64.tar.gz rm -rf CMake-3.22.0-rc2/安裝Samba
安裝
sudo apt update sudo apt install samba samba-common創建一個用于分享的samba目錄(如果在/home就跳過這步)
mkdir /home/<username>/sambashare/給創建的這個目錄設置權限
sudo chmod 777 /home/<username>/sambashare/ -R添加用戶(下面的sxf是我的用戶名,之后會需要設置samba的密碼)。這里添加的用戶在 Linux 中必須存在。
sudo smbpasswd -a sxf配置samba的配置文件
sudo nano /etc/samba/smb.conf在配置文件smb.conf的最后添加下面的內容
[sambashare]comment = Samba on Ubuntupath = /home/<username>/sambashareread only = nobrowsable = yespublic = yesavailable = yeswritable = yesvalid users = sxfwrite list = sxfcreate mask = 0700directory mask = 0700force user = sxf重啟samba服務器
sudo service smbd restartWindows徽標+R 在彈出的運行窗口中輸入 \\ip? 即可訪問。輸入samba用戶名及密碼訪問即可看到共享,然后就可以在Linux系統與Windows系統直接進行文件共享了
安裝Mosquitto MQTT
sudo apt-add-repository ppa:mosquitto-dev/mosquitto-ppa sudo apt-get update sudo apt-get install mosquitto sudo apt-get install mosquitto-clients sudo apt clean安裝EMQX MQTT
wget https://www.emqx.com/zh/downloads/broker/v5.0-beta.2/emqx-5.0-beta.2-otp24.1.5-2-ubuntu18.04-amd64.debsudo dpkg -i emqx-5.0-beta.2-otp24.1.5-2-ubuntu18.04-amd64.debemqx start安裝Redis
sudo apt update sudo apt install redis-server -y sudo systemctl status redis-server遠程訪問:
1、服務器后臺控制臺放行6379端口。
2、修改配置文件。
sudo nano /etc/redis/redis.conf取消注釋: # bind 0.0.0.0 ::1 改為: bind 0.0.0.0sudo systemctl restart redis-server3、設置密碼。
sudo vi /etc/redis/redis.conf取消注釋: # requirepass foobared 并改為你的密碼: requirepass 123456sudo systemctl restart redis-server安裝LAMP
sudo apt install apache2 -y sudo apt install mysql-server mysql-client sudo apt-get install php sudo apt-get install libapache2-mod-php sudo apt-get install php-mysql# 設置mysql密碼: sudo mysql_secure_installation如果mysql報錯“'Access denied for user 'root'@'localhost'”,解決方法:
sudo mysql-- for MySQL ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY '你的密碼';安裝typecho
1、完成上面的LAMP安裝
2、進入apache目錄下
cd /var/www/html3、下載typecho安裝包并授權
官網:Typecho Official Site
cd /var/www/html git clone https://hub.fastgit.org/typecho/typecho.git sudo chmod 777 /var/www/html -R sudo mv typecho/* ./sudo apt install php-mbstring sudo /etc/init.d/apache2 restart4、數據庫增加一個typecho的database
mysql -uroot -pmysql> create database typecho;5、瀏覽器進入安裝頁面
http://你的服務器ip/install.php6、根據指引完成安裝即可
安裝g20
uoip/g2opy: Python binding of SLAM graph optimization framework g2o (github.com)
關閉搜索,節省內存
1、Settings -> Search,關閉搜索
2、執行
3、重啟
VirtualBox開啟雙屏
1、關閉虛擬機(如ubuntu)
2、打開虛擬機的“設置->顯示->監視器數量”,改為“2”
?3、啟動虛擬機
4、“啟用”顯示屏2
?5、雙屏開啟完成,分別拖到兩個物理顯示器即可
VirtualBox增加磁盤內存
0、查看磁盤使用情況:df -h
?1、關閉ubuntu,打開“管理 - 虛擬介質配置”。
?2、選中要增加的“鏡像vdi”,調整大小。
?3、打開ubuntu虛擬機,安裝分區管理軟件gparted。(因為上面只是增加了空間,并沒有分配)
sudo apt install gparted然后命令框輸入
gparted4、上圖中,灰色unallocated的左邊的如果沒有另外的分區,則可以跳過步驟5和8。
5、點擊右邊灰色unallocated的左邊的白色塊,右擊,選擇“swapoff”,然后刪除該swap分區。
6、選擇要待擴容的根分區,這里是“/dev/sda2”。將條拉滿(注意剩5G空間用于重建swap分區,不要的話也可以不留),再點確定。
7、跟上面一樣,再選擇待擴容的分區,這里是“/dev/sda5”。將條拉滿,再點確定。
8、這里可以重建swap分區(我就不建了,內存夠用)。創建完記得跟步驟5一樣點一下“swapon”。
?9、點擊“應用”,完成操作。
?10、再去看一下,發現修改成功了。
df -h清理apt無用源
對于如這種情況的:
sudo add-apt-repository --remove ppa:george-edison55/cmake-3.x或者
sudo apt install ppa-purge sudo ppa-purge [options] <ppa:ppaowner>[/ppaname] # 具體用法:https://askubuntu.com/questions/307/how-can-ppas-be-removed安裝NVIDIA驅動
虛擬機上裝不了cuda,可以考慮 docker版。
?安裝:
sudo apt-get install virtualbox-guest-dkms sudo ubuntu-drivers install sudo apt install nvidia-cuda-toolkit重啟虛擬機,驗證:
nvidia-smi lspci | grep -i nvidia安裝mosquitto
sudo apt-add-repository ppa:mosquitto-dev/mosquitto-ppa # 引入mosquitto倉庫 sudo apt-get update sudo apt-get install mosquitto -y # 安裝mosquitto包 sudo apt-get install mosquitto-clients -y # 安裝mosquitto客戶端 sudo service mosquitto status # 查詢mosquitto是否正確運行若需配置文件,請另外搜索(sudo vim /etc/mosquitto/mosquitto.conf)。
測試:
#打開一個終端,執行以下命令訂閱主題"mqtt" mosquitto_sub -h localhost -t "mqtt" -v#打開另外一個終端,發布消息到主題 “mqtt” mosquitto_pub -h localhost -t "mqtt" -m "Hello MQTT"#現在你會看到消息被顯示在前一個終端上了.#通過以下命令,可以定于到官放所有測試的mqtt信息,當然你發布的信息別人也能訂閱到 mosquitto_sub -h test.mosquitto.org -t "#" -v#也可以在官方mqtt服務下發布自己專屬的信息 mosquitto_sub -h test.mosquitto.org -t "myxyz123" -v#訂閱自己的信息 mosquitto_pub -h test.mosquitto.org -t "myxyz123" -m "hello mqtt"安裝LAMP
# Apache sudo apt update sudo apt upgrade -y sudo apt install apache2 -y sudo systemctl status apache2# MySQL sudo apt-get install mysql-server -y sudo systemctl status mysql # 如果安裝出錯,請參考:https://stackoverflow.com/questions/47075429/error-setting-up-mysql-table-mysql-plugin-doesnt-exist sudo service mysql start sudo mysql_secure_installation# 如果跟我一樣裝不成功,就換寶塔面板裝吧。。。。 sudo service mysql stop sudo apt-get --purge remove "mysql*" -y sudo rm -rf /etc/mysql/ sudo mysql_secure_installation # 設置密碼# PHP sudo apt install php libapache2-mod-php php-mysql -y sudo systemctl restart apache2 sudo apt-cache show php-gd # 安裝模塊,如php-gd,或全部php*安裝字體
1、下載免費字體:
免費字體下載_免費商用字體_免費字體網_自由字體官網自由字體是國內權威的免費字體網站,匯聚全網免費字體,提供可商用免費字體下載。所有免費字體的授權均經核對確認,個人及商用均可免費自由使用,有效規避字體版權風險。https://ziyouziti.com/
100font.com - 免費字體下載 - 免費商用字體下載網站100font.com是一個專業免費商用字體下載網站。專注于收集整理分享免費商用字體、免版權字體、沒有版權的字體、無版權的字體。免費字體下載、免費放心商用。https://www.100font.com/
2、移動字體文件
sudo cp *.ttf /usr/share/fonts3、建立字體緩存
fc-cache -f -v4、驗證
fc-list | grep "Hack"安裝Conda
精簡版,miniconda:Miniconda — conda documentation
原版,anaconda:Anaconda | Anaconda Distribution
下載完sh文件后,給執行權限并執行,如:
sudo chmod +x xxx.sh bash xxx.shConda換源
在這里:anaconda | 鏡像站使用幫助 | 清華大學開源軟件鏡像站 | Tsinghua Open Source Mirror
conda config --set show_channel_urls yes vim ~/.condarc填入:
channels:- defaults show_channel_urls: true default_channels:- https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main- https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/r- https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/msys2 custom_channels:conda-forge: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloudmsys2: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloudbioconda: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloudmenpo: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloudpytorch: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloudpytorch-lts: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloudsimpleitk: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud清除索引:
conda clean -i安裝x2go
sudo apt-get install x2goserver x2goserver-xsession -y sudo apt-get install xfce4 xfce4-goodies -y sudo systemctl restart x2goserver.service報錯
Can't initialize GTK backend in function 'cvInitSystem'
今天vscode上用OpenCV忽然報這個錯:
是cv::imshow這個函數無法執行顯示。
解決:
需要在命令窗口中執行才行。
ssh REMOTE HOST IDENTIFICATION HAS CHANGED
清除緩存即可
ssh-keygen -R "you server hostname or ip"總結
以上是生活随笔為你收集整理的【教程】Ubuntu20.04 + VirtualBox 各种软件环境安装的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: css font html里写,HTML
- 下一篇: 由海天瑞声支持,全球最大多领域英语开源数