简介
LEMP是用来搭建动态网站的一组软件,首字母缩写分别表示Linux、Nginx(Engine-X)、MySQL和PHP。
本文将讲述如何在Ubuntu18.04上安装LEMP套件。当然,首先要安装Ubuntu18.04操作系统,接着按照以下方法完成其他组建的安装。
前言
以下演示将通过非管理员账号进行,即通过sudo
命令完成安装,如果是普通账号(非管理员)可继续往下看。
步骤一:安装Nginx网站服务器
$ sudo apt update
$ sudo apt install nginx
在Ubuntu18.04上,使用以上两条命令完成nginx安装就可以通过localhost
访问了,若访问失败,可能是已经安装了Apache等占用80端口的服务,或者是防火墙问题,若访问成功,应该如下图所示。
步骤二:安装MySQL数据库
$ sudo apt install mysql-server-5.7
执行该条命令安装MySQL
,但仍为能使用,需要进行配置。考虑到安全问题,这里将通过一个脚本程序来完成MySQL
的权限配置。
$ sudo mysql_secure_installation
执行该条命令,将会提示是否开启密码验证,如下所示,输入Y后按回车。
VALIDATE PASSWORD PLUGIN can be used to test passwords
and improve security. It checks the strength of password
and allows the users to set only those passwords which are
secure enough. Would you like to setup VALIDATE PASSWORD plugin?
Press y|Y for Yes, any other key for No:
然后,就会问设置密码的强度,可以根据提示按实际需要选择,这里选择0。
There are three levels of password validation policy:
LOW Length >= 8
MEDIUM Length >= 8, numeric, mixed case, and special characters
S