要在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服務器。請確保始終使用強密碼和密鑰對來保護你的服務器。