在manjaro 20 nibia上
步骤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 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。
要在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
另外,取消注释或添加以下行:
loadmodule mpm_prefork_module modules/mod_mpm_prefork.so
然后,在配置文件的底部添加以下行:
loadmodule php7_module modules/libphp7.so addhandler php7-script php include conf/extra/php7_module.conf
现在保存文件并退出。重新启动apache服务器,以确保所有配置均正确加载:
sudo systemctl restart httpd
要测试php安装,请在以下位置创建一个文件并编写以下php代码:/srv/http/phpinfo.php
php
phpinfo();
?>
现在,通过访问localhost / phptest.php在浏览器中打开此文件,并检查在您的manjaro linux上是否安装了具有最新php版本的apache服务器。
感谢您使用本教程在manjaro 20系统中安装lamp(,和)。有关其他帮助或有用信息,我们建议您检查apache,mariadb和php的官方网站。
原创文章,作者:校长,如若转载,请注明出处:https://www.yundongfang.com/yun39048.html