步骤 3. 安装 Mariadb
要安装最新版本的 MariaDB,只需按照我们之前的教程如何在 Ubuntu 18.04 LTS Bionic Beaver 上安装 MariaDB 10 Server
步骤 2. 安装 PHP
Ubuntu 18.04 LTS 附带了最新最好的 PHP 7.2 版。
要安装 PHP FPM 和几个最常见的 PHP 模块,执行:
$sudo apt install php-fpm php-opcache php-cli php-gd php-curl php-mysql
LEMP 是 Linux、Engine-X (Nginx) HTTP Server、MariaDB 或者 MySQL 数据库服务器和 PHP-FPM 脚本语言的首字母缩写词。
在本教程中,我们将提供有关如何在 Ubuntu 18.04 LTS 上设置 LEMP Stack 的分步说明。
准备工作
我们需要以具有 sudo 权限的用户身份登录才能安装 LEMP Stack 。
步骤 4.测试 LEMP 堆栈
创建一个简单的 PHP 信息页面来测试 LAMP Stack 安装,如下所示
$sudo bash -c "echo -e '<?php\nphpinfo();\n?>' > /var/www/html/phpinfo.php"
打开 Nginx 默认站点配置文件并取消注释 PHP 块,如下面的代码所示:
$vi /etc/nginx/sites-available/default [...] # pass PHP scripts to FastCGI server # location ~ \.php${ include snippets/fastcgi-php.conf; # # # With php-fpm (or other unix sockets): fastcgi_pass unix:/var/run/php/php7.2-fpm.sock; # # With php-cgi (or other tcp sockets): # fastcgi_pass 127.0.0.1:9000; }
使用以下命令重新启动 Nginx:
$systemctl restart nginx
现在,使用以下 URL 打开 Web 浏览器以安装新的 LEMP:http://YOUR_SERVER_DOMAIN_OR_IP_ADDRESS/phpinfo.php
步骤 1. 安装 Nginx
Nginx 在 Ubuntu 存储库中可用。
使用以下命令更新包索引并安装 Nginx:
$sudo apt update $sudo apt install nginx
使用以下命令在系统启动时启动并启用 Nginx
$sudo systemctl enable nginx $sudo systemctl start nginx
日期:2020-06-02 22:18:52 来源:oir作者:oir