manjaro安装php,如何在Manjaro 20上安装LAMP

f6941a4633c421dc08d802742e7b72c9.png

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

sudo pacman-Syu

步骤2.安装Apache。

让我们使用以下命令安装Apache Web服务器:

sudo pacman-S apache

安装完成后,打开上存在的Apache配置文件,在以下行上搜索并注释:#LoadModule unique_id_module modules / mod_unique_id.so/etc/httpd/conf/httpd.conf

现在,我们可以使用以下命令来启用和启动apache服务器:

sudo systemctl enable httpd

sudo systemctl restart httpd

步骤3.安装MySQL。

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

sudo pacman-S mysql

完成后,请使用以下命令初始化MySQL数据目录:

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

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

sudo systemctl enable mysqld

sudo systemctl restart mysqld

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

$ sudo mysql_secure_installation

NOTE:RUNNING ALL PARTS OF THIS SCRIPT IS RECOMMENDED FOR ALLMariaDBSERVERS IN PRODUCTION USE!PLEASE READ EACH STEP CAREFULLY!

Inorder to loginto MariaDBto secure it,we'll need the current

password for the root user. If you've just installedMariaDB, andhaven'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]YEnabled 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 allofthe above steps,yourMariaDBinstallation should now be secure.

Thanks for using MariaDB!

步骤4.安装PHP。

要在Manjaro中安装PHP和PHP Apache模块,只需使用pacman以下命令:

sudo pacman-S php php-apache

安装后,我们需要配置出PHP。编辑文件:/etc/httpd/conf/httpd.conf:

sudo nano/etc/httpd/conf/httpd.conf

找到以下行并对其进行评论:

#LoadModule mpm_event_module modules/mod_mpm_event.so

另外,取消注释或添加以下行:

LoadModulempm_prefork_module modules/mod_mpm_prefork.so

然后,在配置文件的底部添加以下行:

LoadModulephp7_module modules/libphp7.soAddHandlerphp7-script phpIncludeconf/extra/php7_module.conf

现在保存文件并退出。重新启动apache服务器,以确保所有配置均正确加载:

sudo systemctl restart httpd

要测试PHP安装,请在以下位置创建一个文件并编写以下PHP代码:/srv/http/phpinfo.php

phpinfo();

?>

现在,通过访问localhost / phptest.php在浏览器中打开此文件,并检查在您的Manjaro Linux上是否安装了具有最新PHP版本的Apache服务器。

感谢您使用本教程在Manjaro 20系统中Apache,MariaDB和PHP)。有关其他帮助或有用信息,我们建议您检查Apache,MariaDB和PHP的官方网站。

本站有些内容来自互联网,如有侵权可联系我删除!:云东方 » 如何在Manjaro 20上安装LAMP

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值