LAMP 套件是一种流行的开源 Web 开发平台,可用于运行和部署动态网站和基于 Web 的应用程序。通常,LAMP 套件由 Apache Web 服务器、MariaDB/MySQL 数据库、PHP/Python/Perl 程序设计(脚本)语言组成。 LAMP 是 Linux,MariaDB/MYSQL,PHP/Python/Perl 的缩写。 本教程描述了如何在 Ubuntu 18.04 LTS 服务器中安装 Apache、MySQL、PHP(LAMP 套件)。
就本教程而言,我们将使用以下 Ubuntu 测试。
操作系统:Ubuntu 18.04.1 LTS Server Edition
IP 地址 :192.168.225.22/24
1. 安装 Apache Web 服务器
首先,利用下面命令更新 Ubuntu 服务器:
1 2 3
$ sudo apt update $ sudo apt upgrade
然后,安装 Apache Web 服务器(命令如下):
1 2
$ sudo apt install apache2
检查 Apache Web 服务器是否已经运行:
1 2
$ sudo systemctl status apache2
输出结果大概是这样的:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
● apache2.service - The Apache HTTP Server Loaded: loaded (/lib/systemd/system/apache2.service;enabled; vendor preset: en Drop-In: /lib/systemd/system/apache2.service.d └─apache2-systemd.conf Active: active (running) since Tue 2019-02-0510:48:03 UTC;1min 5s ago Main PID: 2025 (apache2) Tasks:55 (limit: 2320) CGroup: /system.slice/apache2.service ├─2025/usr/sbin/apache2 -k start ├─2027/usr/sbin/apache2 -k start └─2028/usr/sbin/apache2 -k start
Feb 0510:48:02 ubuntuserver systemd[1]: Starting The Apache HTTP Server... Feb 0510:48:03 ubuntuserver apachectl[2003]: AH00558: apache2: Could not reliably Feb 0510:48:03 ubuntuserver systemd[1]: Started The Apache HTTP Server.
VALIDATEPASSWORD PLUGIN can be used to test passwords and improve security. It checks the strength ofpassword and allows the users tosetonly those passwords which are secure enough. Would you liketo setup VALIDATEPASSWORD plugin?
Remove anonymous users? (Press y|Y for Yes, any other key for No) : y Success.
Normally, root should only be allowed to connect from 'localhost'. This ensures that someone cannot guess at the root password fromthe network.
Disallow root login remotely? (Press y|Y for Yes, any other key for No) : y Success.
By default, MySQL comes witha database named 'test' that anyone can access. This is also intended only for testing, and should be removed before moving intoa production environment.
Remove test database and access toit? (Press y|Y for Yes, any other key for No) : y - Dropping test database... Success.
- Removing privileges ontestdatabase... Success.
Reloading the privilege tables will ensure that all changes made so far will take effect immediately.
Reload privilege tables now? (Press y|Y for Yes, any other key for No) : y Success.
All done!
以上就是为 MySQL root 用户设置密码。
2.2 更改 MySQL 超级用户的身份验证方法
默认情况下,Ubuntu 系统的 MySQL root 用户为 MySQL 5.7 版本及更新的版本使用插件 auth_socket 设置身份验证。尽管它增强了安全性,但是当你使用任何外部程序(例如 phpMyAdmin)访问数据库服务器时,也会变得更困难。要解决此问题,你需要将身份验证方法从 auth_socket 更改为 mysql_native_password。为此,请使用以下命令登录到你的 MySQL 提示符下:
1 2
$ sudo mysql
在 MySQL 提示符下运行以下命令,找到所有 MySQL 当前用户帐户的身份验证方法:
1 2
SELECTuser,authentication_string,plugin,host FROM mysql.user;