要在Ubuntu上通过SSH安全地配置LAMP服务器,可以按照以下步骤进行操作:
sudo apt update
sudo apt install apache2 mysql-server php libapache2-mod-php php-mysql
sudo ufw allow https
sudo ufw allow 443
sudo systemctl enable apache2
sudo systemctl start apache2
sudo nano /etc/mysql/mysql.conf.d/mysqld.cnf
找到 bind-address
行并将其注释掉或将其值更改为 0.0.0.0
。
保存并关闭文件。
重启MySQL服务:
sudo systemctl restart mysql
sudo mysql -u root -p
CREATE USER 'newuser'@'%' IDENTIFIED BY 'password';
GRANT ALL PRIVILEGES ON *.* TO 'newuser'@'%';
FLUSH PRIVILEGES;
exit;
sudo apt install openssh-server
sudo nano /etc/ssh/sshd_config
PubkeyAuthentication yes
PasswordAuthentication no
保存并关闭文件。
重启SSH服务:
sudo systemctl restart ssh
ssh-keygen -t rsa -b 4096
/.ssh/authorized_keys
文件中。现在,你已经在Ubuntu系统上通过SSH安全地配置了LAMP服务器。请确保始终使用强密码和密钥对来保护你的服务器。