Ubuntu18.04 Server版安裝及使用(圖文)
1 系統(tǒng)安裝操作步驟
OS Version:1804
鏡像下載:http://cdimage.ubuntu.com/releases/
1.1 選擇安裝語(yǔ)言:
1.2 安裝界面選擇第一項(xiàng)進(jìn)行系統(tǒng)安裝
1.3 選擇安裝過(guò)程中使用的語(yǔ)言,也是系統(tǒng)安裝完后使用的默認(rèn)語(yǔ)言
1.4 選擇地區(qū),這里先選擇最后一項(xiàng)other,然后回車(chē)再選擇Asia,最后選擇China
1.5 選擇語(yǔ)言環(huán)境
1.6 鍵盤(pán)布局檢查,選擇NO
1.7 選擇美式鍵盤(pán)
1.8 確認(rèn)使用美式鍵盤(pán)
1.9 配置主機(jī)名
1.10 創(chuàng)建一個(gè)普通用戶(hù)和為其設(shè)置密碼
1.11 確認(rèn)時(shí)區(qū)
1.12 選擇磁盤(pán)分區(qū)的方法,這里選手動(dòng)分區(qū)
1.13 選擇磁盤(pán)
1.14 確認(rèn)對(duì)磁盤(pán)分區(qū)
1.15 對(duì)磁盤(pán)分區(qū)
1.16 創(chuàng)建新分區(qū)
1.17 指定分區(qū)大小,這里將磁盤(pán)的全部大小劃分給該分區(qū)
1.18 選擇分區(qū)類(lèi)型,這里選主分區(qū)
1.19 分區(qū)完成
1.20 完成分區(qū)并寫(xiě)入數(shù)據(jù)
1.21 確認(rèn)寫(xiě)入磁盤(pán)
1.22 是否使用代理,這里不填
1.23 是否自動(dòng)更新,這里選擇默認(rèn),不自動(dòng)更新
1.24 選擇安裝組件,選擇對(duì)應(yīng)需要安裝的組件,然后按空格鍵,這里選擇OpenSSH Server
1.25 將GRUB引導(dǎo)加載程序安裝到主引導(dǎo)記錄
1.26 完成安裝,確認(rèn)重啟服務(wù)器
1.27 登錄系統(tǒng)
2 系統(tǒng)基礎(chǔ)配置
官方文檔:https://help.ubuntu.com/
2.1 更改主機(jī)名
# cat /etc/hostname hechunping
2.2 更改網(wǎng)卡名稱(chēng)為eth*
# sed -i '/GRUB_CMDLINE_LINUX=/s/"$/net.ifnames=0 biosdevname=0"/' /etc/default/grub # update-grub Sourcing file `/etc/default/grub' Generating grub configuration file ... Found linux image: /boot/vmlinuz-4.15.0-55-generic Found initrd image: /boot/initrd.img-4.15.0-55-generic done # reboot # sed -i 's/ens33/eth0/' /etc/netplan/01-netcfg.yaml
2.3 配置root遠(yuǎn)程登錄
# 默認(rèn)情況下,ubuntu不允許root⽤⼾遠(yuǎn)程ssh,如果有實(shí)際場(chǎng)景需要允許root⽤⼾遠(yuǎn)程ssh,則需要設(shè)置root密碼,并且編輯/etc/ssh/sshd_config⽂件修改如下: ~$ sudo vim /etc/ssh/sshd_config 32 #PermitRootLogin prohibit-password #默認(rèn)為禁⽌登錄 33 PermitRootLogin yes #改為允許登錄 57 #PasswordAuthentication yes 58 PasswordAuthentication yes #打開(kāi)密碼認(rèn)證,其實(shí)默認(rèn)就是允許通過(guò)密碼認(rèn)證登錄 ~$ sudo su - root #切換到root⽤⼾環(huán)境 ~# passwd #設(shè)置密碼 Enter new UNIX password: Retype new UNIX password: passwd: password updated successfully ~# systemctl restart sshd #重啟ssh服務(wù)并測(cè)試root⽤⼾遠(yuǎn)程ssh連接
2.4 網(wǎng)絡(luò)配置
官方文檔:https://netplan.io/ Ubuntu 從 17.10 開(kāi)始,已放棄在 /etc/network/interfaces ⾥固定IP的配置,⽽是改成 netplan ⽅式,配置⽂件是:/etc/netplan/01-netcfg.yaml # ubuntu 17.04及之前的靜態(tài)IP配置⽅式: ~# cat /etc/network/interfaces root@hechunping:~# cat /etc/network/interfaces # interfaces(5) file used by ifup(8) and ifdown(8) auto lo iface lo inet loopback auto eth0 #⽹卡⾃啟動(dòng),寫(xiě)⾃⼰要配置IP的實(shí)際⽹卡名稱(chēng) iface eth0 inet static #配置靜態(tài)IP,寫(xiě)⾃⼰要配置IP的實(shí)際⽹卡名稱(chēng) address 172.18.3.12 #IP地址 netmask 255.255.0.0 #掩碼 gateway 172.18.0.1 #⽹關(guān) dns-nameservers 223.6.6.6 #DNS dns-nameservers 223.5.5.5 #重啟⽹絡(luò)服務(wù) ~# /etc/init.d/networking restart ~# systemctl restart networking.service
2.4.1 單網(wǎng)卡靜態(tài)IP地址
root@hechunping:~# cat /etc/netplan/01-netcfg.yaml # This file describes the network interfaces available on your system # For more information, see netplan(5). network: version: 2 renderer: networkd ethernets: eth0: dhcp4: no addresses: [192.168.7.132/24] gateway4: 192.168.7.2 nameservers: addresses: [223.6.6.6] root@hechunping:~# netplan apply
2.4.2 配置多網(wǎng)卡靜態(tài)IP
# cat /etc/netplan/01-netcfg.yaml # This file describes the network interfaces available on your system # For more information, see netplan(5). network: version: 2 renderer: networkd ethernets: eth0: dhcp4: no addresses: [172.20.7.34/16] gateway4: 172.20.0.1 nameservers: addresses: [223.6.6.6] eth1: dhcp4: no addresses: [192.168.7.34/24] routes: - to: 172.20.0.0/16 via: 192.168.7.2 # netplan apply
2.4.3 單網(wǎng)卡橋接
# cat /etc/netplan/01-netcfg.yaml # This file describes the network interfaces available on your system # For more information, see netplan(5). network: version: 2 renderer: networkd ethernets: eth0: dhcp4: no bridges: br0: dhcp4: no addresses: [172.20.7.34/16] gateway4: 172.20.0.1 nameservers: addresses: [223.6.6.6] interfaces: - eth0 # netplan apply
2.4.4 多網(wǎng)卡橋接
將br0和br1分別橋接到eth0和eth1。 # cat /etc/netplan/01-netcfg.yaml # This file describes the network interfaces available on your system # For more information, see netplan(5). network: version: 2 renderer: networkd ethernets: eth0: dhcp4: no eth1: dhcp4: no bridges: br0: dhcp4: no addresses: [172.20.7.34/16] gateway4: 172.20.0.1 nameservers: addresses: [223.6.6.6] interfaces: - eth0 br1: dhcp4: no addresses: [192.168.7.34/24] routes: - to: 172.20.0.0/16 via: 192.168.7.2 interfaces: - eth1 root@hechunping:~# netplan apply
2.4.5 雙網(wǎng)卡綁定
需要提前安裝好bridge命令,兩塊網(wǎng)卡使用同一種網(wǎng)絡(luò)模式 # cat /etc/netplan/01-netcfg.yaml # This file describes the network interfaces available on your system # For more information, see netplan(5). network: version: 2 renderer: networkd ethernets: eth0: dhcp4: no eth1: dhcp4: no bonds: bond0: interfaces: - eth0 - eth1 addresses: [172.20.7.34/16] gateway4: 172.20.0.1 nameservers: addresses: [223.6.6.6,223.5.5.5] parameters: mode: active-backup mii-monitor-interval: 100 # poweroff # netplan apply
2.4.6 雙網(wǎng)卡綁定+橋接
⽹卡綁定⽤于提供⽹卡接⼝冗余以及⾼可⽤和端⼝聚合功能,橋接⽹卡再給需要橋接設(shè)備的服務(wù)使⽤。 # cat /etc/netplan/01-netcfg.yaml # This file describes the network interfaces available on your system # For more information, see netplan(5). network: version: 2 renderer: networkd ethernets: eth0: dhcp4: no eth1: dhcp4: no bonds: bond0: interfaces: - eth0 - eth1 parameters: mode: active-backup mii-monitor-interval: 100 bridges: br0: dhcp4: no addresses: [172.20.7.34/16] gateway4: 172.20.0.1 nameservers: addresses: [223.6.6.6,223.5.5.5] interfaces: - bond0 # netplan apply
2.4.7 內(nèi)外多網(wǎng)卡綁定
多⽹絡(luò)情況下實(shí)現(xiàn)⽹卡綁定。這里使用橋接(eth0,eth1)和NAT(eth2,eth3)兩種網(wǎng)絡(luò)模式 # cat /etc/netplan/01-netcfg.yaml # This file describes the network interfaces available on your system # For more information, see netplan(5). network: version: 2 renderer: networkd ethernets: eth0: dhcp4: no eth1: dhcp4: no eth2: dhcp4: no eth3: dhcp4: no bonds: bond0: interfaces: - eth0 - eth1 addresses: [172.20.7.34/16] gateway4: 172.20.0.1 nameservers: addresses: [223.6.6.6,223.5.5.5] parameters: mode: active-backup mii-monitor-interval: 100 bond1: interfaces: - eth2 - eth3 addresses: [192.168.7.34/24] parameters: mode: active-backup mii-monitor-interval: 100 routes: - to: 172.20.0.0/16 via: 192.168.7.2 # netplan apply
2.4.8 內(nèi)外多網(wǎng)卡綁定+橋接
# cat /etc/netplan/01-netcfg.yaml # This file describes the network interfaces available on your system # For more information, see netplan(5). network: version: 2 renderer: networkd ethernets: eth0: dhcp4: no eth1: dhcp4: no eth2: dhcp4: no eth3: dhcp4: no bonds: bond0: interfaces: - eth0 - eth1 parameters: mode: active-backup mii-monitor-interval: 100 bond1: interfaces: - eth2 - eth3 parameters: mode: active-backup mii-monitor-interval: 100 bridges: br0: dhcp4: no addresses: [172.20.7.34/16] gateway4: 172.20.0.1 nameservers: addresses: [223.6.6.6,223.5.5.5] interfaces: - bond0 br1: dhcp4: no addresses: [192.168.7.34/24] routes: - to: 172.20.0.0/16 via: 192.168.7.2 interfaces: - bond1 # netplan apply
3 軟件包管理
3.1 修改軟件倉(cāng)庫(kù)地址
阿⾥云倉(cāng)庫(kù)地址:https://developer.aliyun.com/mirror 中科⼤:http://mirrors.ustc.edu.cn/help/ubuntu.html 清華⼤學(xué):https://mirror.tuna.tsinghua.edu.cn/help/ubuntu/ 華為:https://mirrors.huaweicloud.com/ ###### 清華源配置 ###### Ubuntu 的軟件源配置文件是 /etc/apt/sources.list。將系統(tǒng)自帶的該文件做個(gè)備份,將該文件替換為下面內(nèi)容,即可使用 TUNA 的軟件源鏡像。 # cd /etc/apt/ # cp -p sources.list sources.list.bak # vim sources.list # 默認(rèn)注釋了源碼鏡像以提高 apt update 速度,如有需要可自行取消注釋 deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic main restricted universe multiverse # deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic main restricted universe multiverse deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-updates main restricted universe multiverse # deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-updates main restricted universe multiverse deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-backports main restricted universe multiverse # deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-backports main restricted universe multiverse deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-security main restricted universe multiverse # deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-security main restricted universe multiverse # 預(yù)發(fā)布軟件源,不建議啟用 # deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-proposed main restricted universe multiverse # deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-proposed main restricted universe multiverse # apt update #更新本地軟件包列表索引,修改了apt倉(cāng)庫(kù)后必須執(zhí)⾏ ###### 阿里源配置 ###### # sed -i 's/cn.archive.ubuntu/mirrors.aliyun/' /etc/apt/sources.list # apt update #更新本地軟件包列表索引,修改了apt倉(cāng)庫(kù)后必須執(zhí)⾏
3.2 apt工具使用
apt list #apt列出倉(cāng)庫(kù)軟件包,等于yum list apt search NAME #搜索安裝包 apt show apache2 #查看某個(gè)安裝包的詳細(xì)信息 apt install apache2 #在線(xiàn)安裝軟件包 apt remove apache2 #卸載單個(gè)軟件包但是保留配置⽂件 apt autoremove apache2 #刪除安裝包并解決依賴(lài)關(guān)系 apt update #更新本地軟件包列表索引,修改了apt倉(cāng)庫(kù)后必須執(zhí)⾏ apt purge apache2 #卸載單個(gè)軟件包刪除配置⽂件 apt upgrade #升級(jí)所有已安裝且可升級(jí)到新版本的軟件包 apt full-upgrade #升級(jí)整個(gè)系統(tǒng),必要時(shí)可以移除舊軟件包。 apt edit-sources #編輯source源⽂件 apt-cache madison nginx #查看倉(cāng)庫(kù)中軟件包有哪些版本可以安裝 apt install nginx=1.14.0-0ubuntu1.6 #安裝軟件包的時(shí)候指定安裝具體的版本
3.3 dpkg安裝包管理
rpm:RPM(Red Hat Package Manager),是基于Red hat的Linux Distribution的包管理系統(tǒng),同時(shí)也指rpm包本⾝,RPM⽤于rpm包的管理(諸如安裝、卸載、升級(jí)等) "dpkg "是"Debian Packager "的簡(jiǎn)寫(xiě),為 "Debian"專(zhuān)⻔開(kāi)發(fā)的套件管理系統(tǒng),⽅便軟件的安裝、更新及移除。所有源⾃“Debian”的“Linux ”發(fā)⾏版都使⽤ “dpkg”,例如 “Ubuntu”、“Knoppix ”等。 dpkg -i gitlab-ce_11.9.8-ce.0_amd64.deb #安裝某個(gè)軟件包 dpkg -r gitlab-ce #刪除某個(gè)軟件包保留配置⽂件 dpkg -r -P gitlab-ce #刪除某個(gè)軟件包不保留配置⽂件 dpkg -I gitlab-ce_11.9.8-ce.0_amd64.deb #查看軟件包信息 dpkg -c gitlab-ce_11.9.8-ce.0_amd64.deb #查看軟件包內(nèi)的⽂件及⽬錄內(nèi)容 dpkg -l #列出本機(jī)已經(jīng)安裝的所有軟件
3.4 設(shè)置oracle JDK環(huán)境
# pwd /usr/local/src 解壓⼆進(jìn)制⽂件并設(shè)置軟連接: # tar xf jdk-8u212-linux-x64.tar.gz # ln -sv /usr/local/src/jdk1.8.0_212 /usr/local/jdk 配置環(huán)境變量: # vim /etc/profile export JAVA_HOME=/usr/local/jdk export PATH=$JAVA_HOME/bin:$JAVA_HOME/jre/bin:$PATH export CLASSPATH=.$CLASSPATH:$JAVA_HOME/lib:$JAVA_HOME/jre/lib:$JAVA_HOME/lib/tools.jar 重新導(dǎo)⼊環(huán)境變量并驗(yàn)證: # source /etc/profile # java -version java version "1.8.0_212" Java(TM) SE Runtime Environment (build 1.8.0_212-b10) Java HotSpot(TM) 64-Bit Server VM (build 25.212-b10, mixed mode)
3.5 安裝OpenJDK
# apt install openjdk-8-jdk
3.6 安裝常⽤系統(tǒng)命令
# apt purge ufw lxd lxd-client lxcfs lxc-common # apt install iproute2 ntpdate tcpdump telnet traceroute nfs-kernel-server nfs-common lrzsz tree openssl libssl-dev libpcre3 libpcre3-dev zlib1g-dev ntpdate tcpdump telnet traceroute gcc openssh-server lrzsz tree openssl libssl-dev libpcre3 libpcre3-dev zlib1g-dev ntpdate tcpdump telnet traceroute iotop unzip zip
3.7 系統(tǒng)資源限制優(yōu)化
#cat /etc/security/limits.conf #root賬⼾的資源軟限制和硬限制 root soft core unlimited root hard core unlimited root soft nproc 1000000 root hard nproc 1000000 root soft nofile 1000000 root hard nofile 1000000 root soft memlock 32000 root hard memlock 32000 root soft msgqueue 8192000 root hard msgqueue 8192000 #其他賬⼾的資源軟限制和硬限制 * soft core unlimited * hard core unlimited * soft nproc 1000000 * hard nproc 1000000 * soft nofile 1000000 * hard nofile 1000000 * soft memlock 32000 * hard memlock 32000 * soft msgqueue 8192000 * hard msgqueue 8192000
3.8e 內(nèi)核參數(shù)優(yōu)化
# Controls source route verification net.ipv4.conf.default.rp_filter = 1 net.ipv4.ip_nonlocal_bind = 1 net.ipv4.ip_forward = 1 # Do not accept source routing net.ipv4.conf.default.accept_source_route = 0 # Controls the System Request debugging functionality of the kernel kernel.sysrq = 0 # Controls whether core dumps will append the PID to the core filename. # Useful for debugging multi-threaded applications. kernel.core_uses_pid = 1 # Controls the use of TCP syncookies net.ipv4.tcp_syncookies = 1 # Disable netfilter on bridges. net.bridge.bridge-nf-call-ip6tables = 0 net.bridge.bridge-nf-call-iptables = 0 net.bridge.bridge-nf-call-arptables = 0 # Controls the default maxmimum size of a mesage queue kernel.msgmnb = 65536 # # Controls the maximum size of a message, in bytes kernel.msgmax = 65536 # Controls the maximum shared segment size, in bytes kernel.shmmax = 68719476736 # # Controls the maximum number of shared memory segments, in pages kernel.shmall = 4294967296 # TCP kernel paramater net.ipv4.tcp_mem = 786432 1048576 1572864 net.ipv4.tcp_rmem = 4096 87380 4194304 net.ipv4.tcp_wmem = 4096 16384 4194304 net.ipv4.tcp_window_scaling = 1 net.ipv4.tcp_sack = 1 # socket buffer net.core.wmem_default = 8388608 net.core.rmem_default = 8388608 net.core.rmem_max = 16777216 net.core.wmem_max = 16777216 net.core.netdev_max_backlog = 262144 net.core.somaxconn = 20480 net.core.optmem_max = 81920 # TCP conn net.ipv4.tcp_max_syn_backlog = 262144 net.ipv4.tcp_syn_retries = 3 net.ipv4.tcp_retries1 = 3 net.ipv4.tcp_retries2 = 15 # tcp conn reuse net.ipv4.tcp_timestamps = 0 net.ipv4.tcp_tw_reuse = 0 net.ipv4.tcp_tw_recycle = 0 net.ipv4.tcp_fin_timeout = 1 net.ipv4.tcp_max_tw_buckets = 20000 net.ipv4.tcp_max_orphans = 3276800 net.ipv4.tcp_synack_retries = 1 net.ipv4.tcp_syncookies = 1 # keepalive conn net.ipv4.tcp_keepalive_time = 300 net.ipv4.tcp_keepalive_intvl = 30 net.ipv4.tcp_keepalive_probes = 3 net.ipv4.ip_local_port_range = 10001 65000 # swap vm.overcommit_memory = 0 vm.swappiness = 10 #net.ipv4.conf.eth1.rp_filter = 0 #net.ipv4.conf.lo.arp_ignore = 1 #net.ipv4.conf.lo.arp_announce = 2 #net.ipv4.conf.all.arp_ignore = 1 #net.ipv4.conf.all.arp_announce = 2
以上就是本文的全部?jī)?nèi)容,希望對(duì)大家的學(xué)習(xí)有所幫助,也希望大家多多支持我們。
上一篇:使用Apache ab進(jìn)行http性能測(cè)試
欄 目:Linux/apache
下一篇:怎樣給centos系統(tǒng)擴(kuò)展磁盤(pán)分區(qū)的實(shí)現(xiàn)方法
本文標(biāo)題:Ubuntu18.04 Server版安裝及使用(圖文)
本文地址:http://mengdiqiu.com.cn/a1/Linux_apache/10560.html
您可能感興趣的文章
- 01-10Ubuntu18.04 一鍵升級(jí)Python所有第三方包 及安裝python包的方法
- 01-10CentOS 8.0.1905 安裝 ZABBIX4.4版本 (已驗(yàn)證)
- 01-10Linux查看PCIe版本及速率的方法
- 01-10CentOS7升級(jí)內(nèi)核kernel5.0版本
- 01-10Nginx出現(xiàn)500 Internal Server Error 錯(cuò)誤的解決方案
- 01-10ubuntu18.04獲取root權(quán)限并用root用戶(hù)登錄的實(shí)現(xiàn)
- 01-10Ubuntu18.04更換國(guó)內(nèi)源的方法示例
- 01-10如何在ubuntu18.04中設(shè)置使用中文輸入法的使用
- 01-10Linux下如何查看版本信息的方法步驟
- 01-10Ubuntu18.04下將 磁盤(pán)掛載在某目錄下


閱讀排行
- 1C語(yǔ)言 while語(yǔ)句的用法詳解
- 2java 實(shí)現(xiàn)簡(jiǎn)單圣誕樹(shù)的示例代碼(圣誕
- 3利用C語(yǔ)言實(shí)現(xiàn)“百馬百擔(dān)”問(wèn)題方法
- 4C語(yǔ)言中計(jì)算正弦的相關(guān)函數(shù)總結(jié)
- 5c語(yǔ)言計(jì)算三角形面積代碼
- 6什么是 WSH(腳本宿主)的詳細(xì)解釋
- 7C++ 中隨機(jī)函數(shù)random函數(shù)的使用方法
- 8正則表達(dá)式匹配各種特殊字符
- 9C語(yǔ)言十進(jìn)制轉(zhuǎn)二進(jìn)制代碼實(shí)例
- 10C語(yǔ)言查找數(shù)組里數(shù)字重復(fù)次數(shù)的方法
本欄相關(guān)
- 04-02linux關(guān)閉串口命令 關(guān)閉linux端口命令
- 04-02linux文件命令重命名 linux重命名文件名
- 04-02linux中jobs命令 shell jobs命令
- 04-02linux命令注入過(guò)濾 linux 代碼注入
- 04-02linux依次執(zhí)行命令 linux命令的執(zhí)行過(guò)程
- 04-02linux命令注銷(xiāo)vnc linux命令行注銷(xiāo)用戶(hù)
- 04-02linux命令免輸入 linux配置免密登錄
- 04-02軟交換linux命令 軟交換網(wǎng)絡(luò)主要協(xié)議
- 04-02linux命令歷史記錄 linux查看歷史記錄的
- 04-02linux命令頁(yè)面 linux命令頁(yè)面中文
隨機(jī)閱讀
- 01-11Mac OSX 打開(kāi)原生自帶讀寫(xiě)NTFS功能(圖文
- 01-10C#中split用法實(shí)例總結(jié)
- 08-05dedecms(織夢(mèng))副欄目數(shù)量限制代碼修改
- 01-11ajax實(shí)現(xiàn)頁(yè)面的局部加載
- 01-10delphi制作wav文件的方法
- 08-05DEDE織夢(mèng)data目錄下的sessions文件夾有什
- 04-02jquery與jsp,用jquery
- 01-10使用C語(yǔ)言求解撲克牌的順子及n個(gè)骰子
- 01-10SublimeText編譯C開(kāi)發(fā)環(huán)境設(shè)置
- 08-05織夢(mèng)dedecms什么時(shí)候用欄目交叉功能?