如何在manjaro 20上安装lemp-凯发k8娱乐官方网址

manjaro 20 nibia上

步骤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-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

追加以下行并保存文件:

php
phpinfo();
?>

步骤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

恭喜你!您已经成功。感谢您使用本教程在manjaro 20系统中安装lemp()。有关其他帮助或有用信息,我们建议您检查nginx,mariadb和php官方网站。

原创文章,作者:校长,如若转载,请注明出处:https://www.yundongfang.com/yun39003.html

(0)
打赏 微信扫一扫不于多少! 微信扫一扫不于多少! 支付宝扫一扫礼轻情意重 支付宝扫一扫礼轻情意重
上一篇 2021年2月20日 下午5:42
下一篇 2021年2月20日 下午5:54

相关推荐

网站地图