做網(wǎng)站收入長沙正規(guī)競價(jià)優(yōu)化推薦
文章目錄
- 1. 下載常用軟件包
- 2. 更新yum源
- 3. vim編輯器配置
- 4. 安裝C語言和C++的靜態(tài)庫(換root)
- 5. git
- 6. sudo給普通用戶提權(quán)
- 7. 更新git版本(centos默認(rèn)安裝1.8.x,我們更新到2.x)
- 8. getch
- 9. json
- 10. 升級(jí)gcc版本
- 11. 跨系統(tǒng)數(shù)據(jù)傳輸
- 12.解決報(bào)錯(cuò)【g++: internal compiler error: Killed (program cc1plus)Please submit a full bug report,with preprocessed source if appropriate.】
- 13.ProtoBuf 的安裝
- 14. docker的安裝
- 15. cgroup的相關(guān)命令
- 16. nginx 安裝
1. 下載常用軟件包
yum install -y tree
yum install -y nano
yum install -y man man-pages
yum install -y zip unzip
yum install -y gcc-c++ libstdc++-devel
2. 更新yum源
cd /etc/yum.repos.d
mv CentOS-Base.repo backup_CentOS-Base.repo
wget http://mirrors.163.com/.help/CentOS7-Base-163.repo
mv CentOS7-Base-163.repo CentOS-Base.repo
yum clean all
yum makecache
3. vim編輯器配置
- 每個(gè)用戶都需要單獨(dú)配置,登入需要用戶
cd
curl -sLf https://gitee.com/HGtz2222/VimForCpp/raw/master/install.sh -o ./install.sh && bash ./install.sh
(需要輸入root的密碼)
source ~/.bashrc // 按照”提示“輸入指令
4. 安裝C語言和C++的靜態(tài)庫(換root)
yum install glibc-static -y libstdc++-static
5. git
git --version(有的話就不用裝了)
yum install -y git
6. sudo給普通用戶提權(quán)
yum install sudo
vim /etc/sudoers
/**
* ## Allows people in group wheel to run all commands
* %wheel ALL=(ALL) ALL
* tsq ALL=(ALL) ALL #這里就需要添加的地方
**/
// :wq! 強(qiáng)制退出
// 切換成普通用戶后 sudo vim/etc/sudoers 能正常查看則成功
7. 更新git版本(centos默認(rèn)安裝1.8.x,我們更新到2.x)
sudo yum -y remove git
sudo yum -y remove git-*
sudo yum -y install https://packages.endpointdev.com/rhel/7/os/x86_64/endpoint-repo.x86_64.rpm
sudo yum -y install git
git version
8. getch
yum install -y ncurses ncurses-devel
9. json
yum makecache fast
yum -y install jsoncpp-devel
10. 升級(jí)gcc版本
sudo yum install -y centos-release-scl-rh centos-release-scl
sudo yum install -y devtoolset-7-gcc devtoolset-7-gcc-c++
source /opt/rh/devtoolset-7/enable
echo "source /opt/rh/devtoolset-7/enable" >> ~/.bashrc
11. 跨系統(tǒng)數(shù)據(jù)傳輸
sudo yum install -y lrzsz
12.解決報(bào)錯(cuò)【g++: internal compiler error: Killed (program cc1plus)Please submit a full bug report,with preprocessed source if appropriate.】
- 原因:內(nèi)存滿了
- 方式:交換分區(qū)
【設(shè)置并啟用分區(qū)】
- 查看內(nèi)存狀態(tài),下面的Swap也就是虛擬內(nèi)存全為0
free -m
- 該命令表示在opt分區(qū)建立名為swap,大小為1G的虛擬內(nèi)存文件
sudo dd if=/dev/zero of=/opt/swap bs=1024 count=1024000
- 修改swap目錄的權(quán)限(可能權(quán)限不同,看報(bào)錯(cuò)提示)
sudo chmod 600 /opt/swap
- 設(shè)置swap為分區(qū)
mkswap /opt/swap
- 激活swap,啟用分區(qū)交換文件
swapon /opt/swap
【關(guān)停分區(qū)】
- 停止swap分區(qū)
swapoff /opt/swap
- 其次刪除掉swap文件
swapoff /opt/swap
13.ProtoBuf 的安裝
- 安裝依賴庫
sudo yum install -y autoconf automake libtool curl make gcc_c++ unzip
- 下載編譯器
wget https://github.com/protocolbuffers/protobuf/releases/download/v21.9/protobuf-all-21.9.zip
- 執(zhí)行 autogen.sh(如果下的是all的需要這一步,單獨(dú)的語言不需要這一步)
./ autogen.sh
- 修改安裝目錄,統(tǒng)一安裝在 /usr/local/protobuf 下(直接運(yùn)行./configure更方便,不過 lib和bin就會(huì)是分散的)
./configure --prefix=/usr/local/protobuf
- 執(zhí)行,前兩個(gè)花費(fèi)15min左右
make
make check
sudo make install
13.2解決報(bào)錯(cuò) make check:FAIL: protobuf-test
增大虛擬機(jī)內(nèi)存 or 分區(qū)設(shè)置
14. docker的安裝
【配置倉庫】
- 安裝config-manager命令,配置倉庫的工具所在工具包
sudo yum install -y yum-utils
- 配置repo
sudo yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo
- 把/etc/yum.repos.d/docker-ce.repo里的gpgkey替換成國內(nèi)鏡像源(中科大)
sudo sed -i 's@//download.docker.com@//mirrors.ustc.edu.cn/docker-ce@g' /etc/yum.repos.d/docker-ce.repo
【安裝docker】
sudo yum install -y docker-ce docker-ce-cli containerd.io dockerbuildx-plugin docker-compose-plugin
【驗(yàn)證】
- 配置加載
sudo systemctl daemon-reload
- 啟動(dòng)服務(wù)
sudo systemctl start docker
- 開啟啟動(dòng)(視需求添加)
sudo systemctl enable docker
- 查看服務(wù)狀態(tài)
sudo systemctl status docker
- 運(yùn)行docker
sudo docker run hello-world
15. cgroup的相關(guān)命令
- pidstat命令
sodu yum install sysstat -y
- stress命令
yum install stress -y
16. nginx 安裝
- centos 配置 nginx 源
rpm -Uvh http://nginx.org/packages/centos/7/noarch/RPMS/nginx-release-centos-7-0.el7.ngx.noarch.rpm
- 查看yum源
ll /etc/yum.repos.d
- 配置源后建議構(gòu)建緩存,加速下載
yum makecache
- 下載
yum install -y nginx
- 查看是否啟動(dòng)
ps -ef |grep nginx
- 沒有啟動(dòng)的話直接使用命令
nginx
- 檢查版本
nginx -v