#: subject: (How to Install LEMP (Linux, Nginx, MariaDB, PHP) on Fedora 30 Server) #: via: (www.linuxtechi.com/install-lem…) #: author: (Pradeep Kumar www.linuxtechi.com/author/prad…)php
在这篇文章中,咱们将看看如何在 Fedora 30 Server 上安装 LEMP 。LEMP 表明:html
我假设 Fedora 30 已经安装在你的电脑系统上。mysql
LEMP 是一组强大的软件设置集合,它安装在一个 Linux 服务器上以帮助使用流行的开发平台来构建网站,LEMP 是 LAMP 的一个变种,在其中不是 Apache ,而是使用 EngineX(Nginx),此外,使用 MariaDB 代替 MySQL。这篇入门指南是一个安装 Nginx、Maria DB 和 PHP 的独立指南的做品集合。linux
让咱们看看如何在 Fedora 30 Server 上安装 Nginx 和 PHP 以及 PHP FPM。nginx
在系统上安装 Nginx 的第一步是切换到 root 用户。使用下面的命令:git
root@linuxtechi ~]$ sudo -i
[sudo] password for pkumar:
[root@linuxtechi ~]#
复制代码
使用下面的 dnf
命令安装 Nginx:github
[root@linuxtechi ~]# dnf install nginx php php-fpm php-common -y
复制代码
PHP 的默认安装仅自带基本模块和最须要的模块,若是你须要额外的模块,像 PHP 支持的 GD、XML、命令行接口、Zend OPCache 功能等等,你老是可以选择你的软件包,并一次性安装全部的东西。查看下面的示例命令:redis
[root@linuxtechi ~]# sudo dnf install php-opcache php-pecl-apcu php-cli php-pear php-pdo php-pecl-mongodb php-pecl-redis php-pecl-memcache php-pecl-memcached php-gd php-mbstring php-mcrypt php-xml -y
复制代码
使用下面的命令来开始并启用 Nginx 服务:sql
[root@linuxtechi ~]# systemctl start nginx && systemctl enable nginx
Created symlink /etc/systemd/system/multi-user.target.wants/nginx.service → /usr/lib/systemd/system/nginx.service.
[root@linuxtechi ~]#
复制代码
使用下面的命令来开始并启用 PHP-FPM 服务:mongodb
[root@linuxtechi ~]# systemctl start php-fpm && systemctl enable php-fpm
Created symlink /etc/systemd/system/multi-user.target.wants/php-fpm.service → /usr/lib/systemd/system/php-fpm.service.
[root@linuxtechi ~]#
复制代码
注意:假使操做系统防火墙是启用的,并运行在你的 Fedora 30 系统上,那么使用下面的命令来准许 80 和 443 端口:
[root@linuxtechi ~]# firewall-cmd --permanent --add-service=http
success
[root@linuxtechi ~]#
[root@linuxtechi ~]# firewall-cmd --permanent --add-service=https
success
[root@linuxtechi ~]# firewall-cmd --reload
success
[root@linuxtechi ~]#
复制代码
打开网页浏览器,输入下面的 URL: http:// 。
上面的屏幕证明 Nginx 已经成功地安装。
如今,让咱们核实 PHP 安装,使用下面的命令建立一个测试 php 页(info.php
):
[root@linuxtechi ~]# echo "<?php phpinfo(); ?>" > /usr/share/nginx/html/info.php
[root@linuxtechi ~]#
复制代码
在网页浏览器中输入下面的 URL, http:///info.php
上面的页面验证 PHP 7.3.5 已经被成功地安装。如今,让咱们安装 MariaDB 数据库服务器。
MariaDB 是 MySQL 数据库的一个极好的替代品,由于它的工做方式与 MySQL 很是相似,而且兼容性也与 MySQL 一致。让咱们看看在 Fedora 30 Server 上安装 MariaDB 的步骤。
在系统上安装 MariaDB 的第一步是切换到 root 用户,或者你可使用有 root 权限的本地用户。使用下面的命令:
[root@linuxtechi ~]# sudo -i
[root@linuxtechi ~]#
复制代码
在 Fedora 30 Server 上使用下面的命令来安装 MariaDB:
[root@linuxtechi ~]# dnf install mariadb-server -y
复制代码
在步骤 2 中成功地安装 MariaDB 后,接下来的步骤是开启 MariaDB 服务。使用下面的命令:
[root@linuxtechi ~]# systemctl start mariadb.service ; systemctl enable mariadb.service
复制代码
当咱们安装 MariaDB 服务器时,由于默认状况下没有 root 密码,在数据库中也会建立匿名用户。所以,要保护安装好的 MariaDB,运行下面的 mysql_secure_installation
命令:
[root@linuxtechi ~]# mysql_secure_installation
复制代码
接下来你将被提示一些问题,仅回答下面展现的问题:
在你安装后,你老是可以测试是否 MariaDB 被成功地安装在 Fedora 30 Server 上。使用下面的命令:
[root@linuxtechi ~]# mysql -u root -p
Enter password:
复制代码
接下来,你将被提示一个密码。输入在保护安装好的 MariaDB 期间你设置的密码,接下来你能够看到 MariaDB 欢迎屏幕。
Welcome to the MariaDB monitor. Commands end with ; or \g.
Your MariaDB connection id is 17
Server version: 10.3.12-MariaDB MariaDB Server
Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
MariaDB [(none)]>
复制代码
最后,咱们已经在你的 Fedora 30 Server 上成功地完成安装 LEMP(Linux、Nginx、MariaDB 和 PHP)的全部工做。请在下面的反馈部分发布你的评论和建议,咱们将尽快在后面回应。
via: www.linuxtechi.com/install-lem…
做者:Pradeep Kumar 选题:lujun9972 译者:robsean 校对:wxy