在Fedora 23上安装LAMP堆栈

台灯 是Web服务解决方案堆栈的典型模型,以原始四个开源组件的名称的缩写形式命名。 Linux操作系统Apache HTTP服务器MySQL的/ MariaDB的 关系数据库管理系统 PHP编程语言。的 台灯 这些组件几乎可以互换,并且不仅限于原始选择。作为解决方案堆栈, 台灯 适用于 建立动态网站和Web应用程序。在本教程中,让我们看看 如何在Fedora 23服务器上安装LAMP堆栈

在Fedora 23服务器上安装LAMP

首先使用以下命令验证系统是否为最新版本:

# sudo dnf update -y

Fedora 23更新包

您现在可以安装Apache。

在Fedora 23上安装Apache服务器

阿帕奇 开源多平台 Web服务器。提供各种Web服务器功能,例如CGI,SSL,虚拟域等。安装Apache 执行以下命令:

# dnf install httpd

按Y,然后按Enter。 [y/N]“安装。使用以下命令启动Apache:

# systemctl start httpd.service

启用httpd服务,并在每次重新启动时自动启动。

# systemctl enable httpd

另外,调整防火墙以允许远程客户端可以访问httpd服务。

# firewall-cmd --permanent --add-service=http
# firewall-cmd --permanent --add-service=https

重新启动防火墙服务。

# firewall-cmd --reload

通过在浏览器中键入http://ip.add.re.ss来验证是否已安装Apache。

Fedora 23默认Apache页面Fedora 23默认Apache页面

在Fedora 23上安装MariaDB

玛丽亚数据库 它是MySQL的直接替代品。坚固,可扩展且可靠 SQL服务器 它包括许多增强功能。

使用以下命令进行安装:

# dnf install mariadb mariadb-server -y

使用以下命令在启动时启用mariadb服务:

# systemctl enable mariadb

启动mariadb服务 使用命令:

# systemctl start mariadb

默认情况下,mysql root用户的密码为空。因此,请为root用户设置密码,以防止未经授权访问mysql数据库。

# 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
you haven't set the root password yet, the password will be blank,
so you should just press enter here.
Enter current password for root (enter for none): 
OK, successfully used password, moving on...
Setting the root password ensures that nobody can log into the MariaDB
root user without the proper authorisation.
You already have a root password set, so you can safely answer 'n'.
Change the root password? [Y/n] y     ## Enter 'y' and press enter ##
New password:               ## Enter password ##
Re-enter new password:      ## Re-enter password ##
Password updated successfully!
Reloading privilege tables..
 ... Success!
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]    ## Press Enter ##
 ... 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] ## Press Enter ##
 ... 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] ## Press Enter ##
 - Dropping test database...
ERROR 1008 (HY000) at line 1: Can't drop database 'test'; database doesn't exist
 ... Failed!  Not critical, keep moving...
 - 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] ## Press Enter ##
 ... 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!

安装PHP

默认情况下 Apache服务器 因为它需要安装PHP,所以它仅支持HTML语言,不支持PHP。要安装PHP,请按照下列步骤操作:在终端中输入以下行,然后按Enter。该命令包括 玛丽亚数据库

# dnf install php php-mysql -y

安装PHP后,您需要重新启动apache服务。为此,请在终端中输入以下内容:

# systemctl restart httpd.service

您可以使用以下命令在以下HTML目录中创建测试PHP文件来验证您的PHP安装:

# vi /var/www/html/info.php

添加以下行:

保存文件。返回浏览器并输入:

http://ip.add.re.ss/info.php

检查PHP信息检查PHP信息

就是这样开始使用 Fedora 23灯泡堆栈

Sidebar