LNMP是指Linux系统下(Nginx, MySQL(MariaDB), PHP)这种网站服务器架构。在Ubuntu上设置LNMP环境时,可以采取以下安全措施:
/etc/ssh/sshd_config 文件。Port 2222 。sudo systemctl restart sshd 。/etc/hosts.allow 和 /etc/hosts.deny 文件来限制允许登录的IP。/etc/ssh/sshd_config 文件中使用 allowusers 指令来指定允许登录的用户。sudo apt-get install ufw 。sudo ufw enable 。sudo ufw allow 22 /tcp 、 sudo ufw allow 80 /tcp 、 sudo ufw allow 443 /tcp 、 sudo ufw allow 3306 /tcp 。sudo ufw reload 。/etc/nginx/nginx.conf 或 /etc/nginx/sites-available/default 。sudo systemctl restart nginx 。/etc/php/7.x/fpm/php.ini (具体版本可能有所不同)。display_errors 为 On ,以便在开发过程中显示错误信息。error_reporting 为 E_ALL ,以报告所有错误。sudo systemctl restart php7.x-fpm 。mysql_secure_installation 脚本进行基本的安全设置,包括设置强密码、删除匿名用户、禁止远程root登录等。/etc/mysql/mysql.conf.d/mysqld.cnf ,将 bind-address 设置为 0.0.0.0 以允许远程连接,然后注释掉这一行。sudo systemctl restart mysql 。sudo apt-get install phpmyadmin 。/usr/share/phpmyadmin 目录。以上步骤提供了Ubuntu LNMP环境的基本安全设置,但请注意,安全是一个持续的过程,需要定期更新和审查安全措施。此外,具体的命令和配置可能会因Ubuntu版本的不同而有所差异,建议参考最新的官方文档进行操作。