点击下载字符界面版本Ubuntu16.04.7
点击下载图形界面版本Ubuntu16.04.7
安装参考:
字符界面——https://blog.csdn.net/a603423130/article/details/100127968
图形界面——https://blog.csdn.net/leoli95/article/details/82788138
要求:
参考:
操作:
配置下载源:
操作参考:
(11条消息) Ubuntu16.04更换下载源_林贻民的博客-CSDN博客_ubuntu更换下载源
阿里源:
ubuntu镜像-ubuntu下载地址-ubuntu安装教程-阿里巴巴开源镜像站 (aliyun.com)
cd /etc/apt
sudo mv sources.list sources.list.bak
sudo vi sources.list
sudo apt-get update
sudo apt-get install vim
ip link // 查看网卡名称
sudo vi /etc/network/interfaces
# interfaces(5) file used by ifup(8) and ifdown(8)
auto lo
iface lo inet loopback
# The promary network interface
auto enp0s3
iface enp0s3 inet dhcp
auto enp0s8
iface enp0s8 inet static
address 192.168.0.101
netmask 255.255.255.0
sudo systemctl restart networking.service
要求:
参考:https://www.cnblogs.com/neillee/p/7009621.html
操作:
sudo adduser exam
password:network
sudo chmod u+w /etc/sudoers
sudo vi /etc/sudoers // 修改见下图
sudo chmod u-w /etc/sudoers
sudo apt-get install openssh-server
在远程客户端cmd输入:
ssh [email protected]
要求:
参考:
ubuntu16.04下搭建bind9记录_w450093854的专栏-CSDN博客_ubuntu安装bind9
操作:
sudo apt install bind9
sudo vi /etc/bind/named.conf.local
// 正向解析
zone "example.com"{
type master;
file "/etc/bind/db.example.com";
};
// 反向解析
zone "0.168.192.in-addr.arpa"{
type master;
file "/etc/bind/db.192";
};
注意里面和外面的分号!
// 配置正向解析
sudo cp /etc/bind/db.local /etc/bind/db.example.com
sudo vi /etc/bind/db.example.com
named-checkzone example.com /etc/bind/db.example.com
// 反向解析
sudo cp /etc/bind/db.127 /etc/bind/db.192
sudo vi /etc/bind/db.192
named-checkzone 0.168.192 /etc/bind/db.192
sudo systemctl restart bind9
sudo systemctl status bind9
接着,更改Windows主机上虚拟机网卡的dns为192.168.0.101
。
要求:
操作:
sudo apt-get install nginx
sudo systemctl status nginx.service
// 准备数据
sudo mkdir -p /data/app1 /data/app2
sudo vi /data/app1/index.html
<h># hello app1.example.com
sudo vi /data/app2/index.html
<h># hello app2.example.com
cd /etc/nginx/sites-available/
sudo vi app1.example.com
server{
listen 80;
listen [::]:80;
root /data/app1;
index index.html;
server_name app1.example.com;
location / {
try_files $uri $uri/ =404;
}
}
sudo vi app2.example.com
server{
listen 80;
listen [::]:80;
root /data/app2;
index index.html;
server_name app2.example.com;
location / {
try_files $uri $uri/ =404;
}
}
cd /etc/nginx/sites-enabled
sudo ln -s /etc/nginx/sites-available/app1.example.com /etc/nginx/sites-enabled
sudo ln -s /etc/nginx/sites-available/app2.example.com /etc/nginx/sites-enabled
sudo nginx -t
sudo systemctl restart nginx.service
sudo systemctl status nginx.service
cd
nginx -V &> test
cat test // 查看是否安装了ssl加密模块
sudo rm test
cd /etc/nginx/
sudo mkdir ssl
cd ssl
sudo openssl genrsa -des3 -out server.key 4096
sudo openssl req -new -key server.key -out server.csr
sudo openssl rsa -in server.key -out server_nopass.key
sudo openssl x509 -req -days 365 -in server.csr -signkey server_nopass.key -out server.crt
// 配置证书
sudo vi /etc/nginx/sites-enabled/app1.example.com
server{
listen 443 ssl;
listen [::]:443;
root /data/app1;
index index.html;
server_name app1.example.com;
ssl_certificate /etc/nginx/ssl/server.crt;
ssl_certificate_key /etc/nginx/ssl/server_nopass.key;
location / {
try_files $uri $uri/ =404;
}
}
sudo vi /etc/nginx/sites-enabled/app2.example.com
server{
listen 443 ssl;
listen [::]:443;
root /data/app2;
index index.html;
server_name app2.example.com;
ssl_certificate /etc/nginx/ssl/server.crt;
ssl_certificate_key /etc/nginx/ssl/server_nopass.key;
location / {
try_files $uri $uri/ =404;
}
}
sudo nginx -t
sudo systemctl restart nginx.service
要求:
参考:https://www.digitalocean.com/community/tutorials/how-to-install-apache-tomcat-8-on-ubuntu-16-04
操作:
// 安装部署 Java 开发环境
sudo apt install default-jdk
// 下载 Tomcat 服务器
sudo groupadd tomcat
sudo useradd -s /bin/false -g tomcat -d /opt/tomcat tomcat
cd /tmp
#curl -Ok https://dlcdn.apache.org/tomcat/tomcat-8/v8.5.73/bin/apache-tomcat-8.5.73.tar.gz
#(Windows cmd 上执行)scp F:/linux/software/apache-tomcat-8.0.35.tar.gz [email protected]:/tmp
见[使用pscp实现Windows 和 Linux服务器间远程传递文件](https://blog.csdn.net/sgmcumt/article/details/79135395)
sudo mkdir /opt/tomcat
sudo tar xzvf apache-tomcat-8*tar.gz -C /opt/tomcat --strip-components=1
cd /opt/tomcat
sudo chgrp -R tomcat /opt/tomcat
sudo chmod -R g+r conf
sudo chmod g+x conf
sudo chown -R tomcat webapps/ work/ temp/ logs/
sudo update-java-alternatives -l
sudo vi /etc/systemd/system/tomcat.service
[Unit]
Description=Apache Tomcat Web Application Container
After=network.target
[Service]
Type=forking
Environment=JAVA_HOME=/usr/lib/jvm/java-1.8.0-openjdk-amd64/jre
Environment=CATALINA_PID=/opt/tomcat/temp/tomcat.pid
Environment=CATALINA_HOME=/opt/tomcat
Environment=CATALINA_BASE=/opt/tomcat
Environment='CATALINA_OPTS=-Xms512M -Xmx1024M -server -XX:+UseParallelGC'
Environment='JAVA_OPTS=-Djava.awt.headless=true -Djava.security.egd=file:/dev/./urandom'
ExecStart=/opt/tomcat/bin/startup.sh
ExecStop=/opt/tomcat/bin/shutdown.sh
User=tomcat
Group=tomcat
UMask=0007
RestartSec=10
Restart=always
[Install]
WantedBy=multi-user.target
sudo systemctl daemon-reload
sudo systemctl start tomcat
sudo systemctl status tomcat
#sudo ufw allow 8080
sudo vi /opt/tomcat/conf/server.xml
sudo systemctl restart tomcat
sudo systemctl status tomcat
sudo su
cd /opt/tomcat/webapps
mkdir java
cd java
sudo vi index.html
# JAVA
exit
sudo vi /etc/nginx/sites-available/java.example.com
server{
listen 443 ssl;
listen [::]:443;
server_name java.example.com;
ssl_certificate /etc/nginx/ssl/server.crt;
ssl_certificate_key /etc/nginx/ssl/server_nopass.key;
location / {
proxy_pass http://127.0.0.1:8080/java/;
index index.html;
try_files $uri $uri/ =404;
}
}
sudo ln -s /etc/nginx/sites-available/java.example.com /etc/nginx/sites-enabled/
sudo nginx -t
sudo systemctl restart nginx.service
sudo systemctl status nginx.service
要求:
操作:
// 更改主机名为zhugedou.work
hostname
sudo vi /etc/hostname
#example.com
sudo vi /etc/hosts
#example.com
reboot
hostname
// 配置DNS
sudo vi /etc/bind/db.example.com
named-checkzone example.com /etc/bind/db.example.com
sudo chmod -R 777 mail
// 安装配置postfix
sudo apt install mailutils
sudo systemctl status postfix
// 创建邮局账号
sudo adduser boss
passwd:123456
测试postfix是否可以发送邮件
在Windows主机上输入:
telnet mail.example.com smtp
在虚拟机中查看是否收到:
sudo vi /var/mail/exam
// 使用sendmail给[email protected]发邮件
sendmail -f [email protected] [email protected]
#hello world
#.
cat /var/mail/exam
// 安装配置dovecot
sudo apt-get install dovecot-common dovecot-imapd dovecot-pop3d
sudo vi /etc/dovecot/dovecot.conf
//修改允许登陆网段地址,全部允许
login_trusted_networks = 0.0.0.0/0
sudo vi /etc/dovecot/conf.d/10-auth.conf
disable_plaintext_auth = no
sudo systemctl restart dovecot.service
sudo systemctl status dovecot.service
测试dovecot
在Windows中输入:
telnet mail.example.com pop3
在Windows中输入:
telnet mail.example.com imap
在windows邮件客户端中测试:
因为上面用telnet命令发送时的data数据不完整,上图中有一封没有发信人的名字。我们可以尝试再发送一次:
这次我们可以看到发信人了:
登陆上boss账号进行查看:
我们的邮件服务系统搭建成功了!
要求:
操作:
sudo apt-get update
sudo apt-get install mysql-server mysql-client
mysql -u root -h localhost -padmin12345
create database swu;
show databases;
要求:
操作:
sudo ufw status
sudo ufw allow 22
sudo ufw allow 25
sudo ufw allow 80
sudo ufw allow 443
sudo ufw allow 110
sudo ufw allow 143
sudo ufw enable
sudo ufw status
要求:
操作:
添加硬盘:
然后开机
// 识别组件设备
lsblk -o NAME,SIZE,FSTYPE,TYPE,MOUNTPOINT
sudo apt-get install mdadm
// 创建阵列
sudo mdadm --create --verbose /dev/md0 --level=1 --raid-devices=2 /dev/sdb /dev/sdc
// 通过检查/proc/mdstat文件,可以确保成功创建RAID:
cat /proc/mdstat
// 在阵列上创建一个文件系统
sudo mkfs.ext4 -F /dev/md0
// 创建挂载点以连接新文件系统
sudo mkdir -p /mnt/md0
// 挂载文件系统
sudo mount /dev/md0 /mnt/md0
// 通过键入以下内容检查新空间是否可用
df -h -x devtmpfs -x tmpfs
// 使阵列在引导时自动重新组装
sudo mdadm --detail --scan | sudo tee -a /etc/mdadm/mdadm.conf
// 更新 initramfs 或初始 RAM 文件系统,以便阵列在早期引导过程中可用
sudo update-initramfs -u
// 将新的文件系统装载选项添加到`/etc/fstab`文件,以便在启动时自动装载:
echo '/dev/md0 /mnt/md0 ext4 defaults,nofail,discard 0 0' | sudo tee -a /etc/fstab
【1】伍老师网站