如何在Manjaro 20上安装LEMP
admin
2023-07-31 21:10:23
0

在Manjaro 20 Nibia上安装LEMP

步骤1.在运行下面的教程之前,请确保我们的系统是最新的:

sudo pacman -Syu

步骤2.安装Nginx。

通过运行以下命令在Manjaro Linux上安装Nginx:

sudo pacman -S nginx

一旦安装了Nginx,请启动它并启用它以在系统启动时启动:

sudo systemctl start nginx
sudo systemctl enable nginx

要验证Nginx设置,请打开浏览器并浏览到服务器主机名或IP地址,您应该看到Nginx默认测试页面,如下所示:

http://your-ip-address

Nginx-Default-PageNginx-Default-Page

步骤3.安装MariaDB。

运行以下命令以在Manjaro上安装MariaDB Server:

sudo pacman -S mariadb

然后,初始化MariaDB数据目录并创建系统表,如下所示:

sudo mysql_install_db –user=mysql basedir=/usr –datadir=/var/lib/mysql

接下来,使用以下命令启用并启动它:

sudo systemctl start mariadb
sudo systemctl enable mariadb

默认情况下,不会对MariaDB进行加固。您可以使用mysql_secure_installation脚本保护MySQL 。您应该仔细阅读每个步骤,并在每个步骤下面仔细进行操作,这将设置root密码,删除匿名用户,禁止远程root登录以及删除测试数据库并访问安全的MariaDB:

$ sudo mysql_secure_installation
NOTE: RUNNING ALL PARTS OF THIS SCRIPT IS RECOMMENDED FOR ALL MariaDB
      SERVERS IN PRODUCTION USE!  PLEASE READ EACH STEP CAREFULLY!

In order to log into MariaDB to secure it, we\'ll need the current
password for the root user. If you\'ve just installed MariaDB, and
haven\'t set the root password yet, you should just press enter here.

Enter current password for root (enter for none): 
OK, successfully used password, moving on...

Setting the root password or using the unix_socket ensures that nobody
can log into the MariaDB root user without the proper authorisation.

You already have your root account protected, so you can safely answer \'n\'.

Switch to unix_socket authentication [Y/n] Y
Enabled successfully!
Reloading privilege tables..
 ... Success!

You already have your root account protected, so you can safely answer \'n\'.

Change the root password? [Y/n] n ... skipping.

By default, a MariaDB installation has an anonymous user, allowing anyone
to log into MariaDB without having to have a user account created for
them.  This is intended only for testing, and to make the installation
go a bit smoother.  You should remove them before moving into a
production environment.

Remove anonymous users? [Y/n] Y ... Success!

Normally, root should only be allowed to connect from \'localhost\'.  This
ensures that someone cannot guess at the root password from the network.

Disallow root login remotely? [Y/n] Y ... Success!

By default, MariaDB comes with a database named \'test\' that anyone can
access.  This is also intended only for testing, and should be removed
before moving into a production environment.

Remove test database and access to it? [Y/n] Y - Dropping test database...
 ... Success!
 - Removing privileges on test database...
 ... Success!

Reloading the privilege tables will ensure that all changes made so far
will take effect immediately.

Reload privilege tables now? [Y/n] Y ... Success!

Cleaning up...

All done!  If you\'ve completed all of the above steps, your MariaDB
installation should now be secure.

Thanks for using MariaDB!

步骤4.安装PHP。

运行以下命令以安装PHP:

sudo pacman -S php php-fpm

安装完成后,使用以下命令启动并启用启动引导:php-fpm

sudo systemctl start php-fpm
sudo systemctl enable php-fpm

我们需要对Nginx配置文件进行一些修改:

sudo nano /etc/nginx/nginx.conf

添加以下行:

location ~ \\.php$ {
fastcgi_pass unix:/var/run/php-fpm/php-fpm.sock;
fastcgi_index index.php;
root /usr/share/nginx/html;
include fastcgi.conf;
}

保存文件,然后重新启动Nginx和PHP-FPM,以使更改生效:

sudo systemctl restart nginx
sudo systemctl restart php-fpm

要测试PHP安装,请在路径中创建一个文件:info.php/usr/share/nginx/html/

sudo nano /usr/share/nginx/html/info.php

追加以下行并保存文件:

步骤5.配置防火墙。

要允许外部连接到我们的Manjaro Linux Web服务器,我们需要打开Web端口80和443。但首先,让我们安装ufw防火墙:

sudo pacman -S ufw
sudo ufw allow 80/tcp
sudo ufw allow 443/tcp
sudo ufw enable

恭喜你!您已经成功安装了LEMP服务器。感谢您使用本教程在Manjaro 20系统中安装LEMP(Nginx,MariaDB和PHP)。有关其他帮助或有用信息,我们建议您检查Nginx,MariaDB和PHP官方网站。

相关内容

热门资讯

Windows 11 和 10... Windows 11/10 文件夹属性中缺少共享选项卡 – 已修复 1.检查共享选项卡是否可用 右键...
事件 ID 7034:如何通过... 点击进入:ChatGPT工具插件导航大全 服务控制管理器 (SCM) 负责管理系统上运行的服务的活动...
Radmin VPN Wind... Radmin VPN 是一款免费且用户友好的软件,旨在牢固地连接计算机以创建一个有凝聚力的虚拟专用网...
Hive OS LOLMine... 目前不清退的交易所推荐: 1、全球第二大交易所OKX欧意 国区邀请链接: https://www.m...
如何修复 Steam 内容文件... Steam 内容文件锁定是当您的 Steam 文件无法自行更新时出现的错误。解决此问题的最有效方法之...
如何在电报Telegram中隐... 点击进入:ChatGPT工具插件导航大全 在Android上的电报中隐藏您的电话号码 您可以通过切换...
在 iCloud 上关闭“查找... 如果您是 Apple 的长期用户,您肯定会遇到过 Find My 应用程序,它本机安装在 iPhon...
Hive OS 部署 PXE ... 目前不清退的交易所推荐: 1、全球第二大交易所OKX欧意 国区邀请链接: https://www.m...
如何在Instagram上扫描... 如何在Instagram上扫描名称标签/ QR? 总而言之,您可以通过大约四种不同的方法来扫描这些I...
farols1.1.501.0... faro ls 1.1.501.0(64bit)可以卸载,是一款无需连接外部PC机或笔记本计算机即可...