安装ssh-server
先输入sudo apt install openssh-server
安装ssh-server
…报错了。
查了一下好像是文件夹上锁了之类的。
那要先输入
sudo rm /var/lib/dpkg/lock-frontend
sudo rm /var/cache/apt/archives/lock
sudo rm /var/lib/dpkg/lock
再输入一次sudo apt install openssh-server
输入sudo systemctl status ssh
查看是否ssh运行
查看ip ip a
连接方式就是 昵称@id 如[email protected]/24
可以在windows系统中下putty验证。
安装Apache
安装Apache2
输入sudo apt install apache2
调整防火墙
先查看防火墙配置文件:sudo ufw app list
Apache的三种配置文件:
Apache :此配置文件仅打开端口80(正常,未加密的Web流量)
Apache Full :此配置文件打开端口80(正常,未加密的Web流量)和端口443(TLS / SSL加密流量)
Apache Secure :此配置文件仅打开端口443(TLS / SSL加密流量)
允许Apache Full传入流量:sudo ufw allow 'Apache Full'
验证是否设置成功:sudo ufw status
若提示不活动,则输入sudo ufw enable
启动防火墙
然后再重新输入sudo ufw status
检查web服务器
检查服务是否在运行:sudo systemctl status apache2
通过键入hostname -I
查看ip地址
在浏览器中输入http://(ip地址)
如http://192.168.137.128/
验证
停止Web服务器:sudo systemctl stop apache2
启动Web服务器:sudo systemctl start apache2
安装mysql
输入sudo apt update
sudo apt install mysql-server
验证mysql是否运行:sudo systemctl status mysql
保护mysql
调用不带参数的脚本:sudo mysql_secure_installation
然后在登录上报错了…
ERROR 1698 (28000): Access denied for user 'root'@'localhost'
输入:sudo vim /etc/mysql/mysql.conf.d/mysqld.cnf
加入一句话skip-grant-tables
保存退出后再输入service mysql restart
,
输入:mysql -u root -p
看见填密码就回车。
执行use mysql
再执行
ALTER user 'root'@'localhost' IDENTIFIED BY '密码';
再执行flush privileges
如果出现ERROR 1290 (HY000): The MySQL server is running with the --skip-grant-tables option so it cannot execute this statement
先输入flush privileges
再执行update user set authentication_string=password("你的密码")
和flush privileges
就可以完成。