热门标签 | HotTags
当前位置:  开发笔记 > 编程语言 > 正文

Fedora23如何安装LAMP服务器

LAMP是开源系统上Web服务器的梦幻组合。LAMP是Linux、ApacheHTTP服务、MySQL/MariaDB数据库和PHP、Perl或Python的简称。下面教你如何在Fedora23服务器上安装LAMP组合。下面的教程默认使用192.168.1.102/24实例,请按照你的服务器做修改。安装ApacheApache是一

LAMP 是开源系统上 Web 服务器的梦幻组合。 LAMP 是 Linux、 Apache HTTP 服务、 MySQL/MariaDB 数据库和 PHP、 Perl 或 Python 的简称。

下面教你如何在 Fedora 23 服务器上安装 LAMP 组合。

下面的教程默认使用 192.168.1.102/24 实例,请按照你的服务器做修改。

安装 Apache

Apache 是一款开源的 web 服务框架。完全支持 CGI, SSL。

切换到 root 账户:

su

Fedora 23/22 输入以下命令来安装Apache:

dnf install httpd -y

Fedora 21 及更早的版本:

yum install httpd -y

启动httpd服务,以在每次系统启动服务:

systemctl enable httpd

使用以下命令来启动httpd服务:

systemctl start httpd

如果您遇到以下错误:


Job for httpd.service failed. See ‘systemctl status httpd.service’ and ‘journalctl -xn’ for details.

删除所有内容在/etc/hostname,并加上“localhost”。同时,在/etc/httpd/conf/httpd.conf文件中的“Servername”的值设定为“localhost”,并再次尝试启动httpd服务。
 并调整防火墙以允许httpd服务,从远程客户端访问。

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


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

重新启动firewalld服务:


firewall-cmd --reload

打开浏览器,输入服务器IP访问:

安装MariaDB

Fedora 23/22 用户安装命令:


dnf install mariadb mariadb-server -y

Fedora 21 及早前版本命令:


yum install mariadb mariadb-server -y

随系统自动启动命令:


systemctl enable mariadb

启动数据库服务器:

systemctl start mariadb

设置 MariaDB root 账户密码,默认情况下MySQL root用户的密码为空。因此,以防止未经授权的访问MySQL数据库,我们设置需要root用户密码:


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

Fedora 23/22 用户命令:

dnf install php -y

Fedora 21 及早期版本:

yum install php -y

测试PHP是否运行:

vi /var/www/html/testphp.php

输入以下内容:
phpinfo();
?>

重启 Http 服务:

systemctl restart httpd

浏览器输入看看:

安装PHP模块

搜索模块并安装:

Fedora 23/22 用户:

dnf search php

Fedora 22及早期版本:

yum search php

现在安装你所选择所需模块,例如php-mysql,使用以下命令:

Fedora 23/22 用户:


dnf install php-mysql -y

Fedora 22及早期版本:


yum install php-mysql -y

重启 HTTP 服务:

systemctl restart httpd

浏览器查看模块安装是否成功:

安装phpMyAdmin

phpmyadmin 用于管理数据库:
Fedora 23/22 用户:

dnf install phpmyadmin -y

Fedora 22及早期版本:

yum install phpmyadmin -y

缺省情况下,phpMyAdmin 只能从本地主机进行访问。若要从远程系统访问您的网络中,请执行下列操作步骤。

vi /etc/httpd/conf.d/phpMyAdmin.conf

查找并注释掉127.0.0.1 和请求 ip ::1 lines。然后添加一个额外的行要求所有授予略低于为注释行。

这是我的更改后的 phpMyAdmin.conf 文件。这些变化以粗体标记。
[...]
Alias /phpMyAdmin /usr/share/phpMyAdmin
Alias /phpmyadmin /usr/share/phpMyAdmin

  AddDefaultCharset UTF-8
 
    # Apache 2.4
   
#      Require ip 127.0.0.1
#      Require ip ::1
        Require all granted
   

 

 
    # Apache 2.2
    Order Deny,Allow
    Deny from All
    Allow from 127.0.0.1
    Allow from ::1
 



 
    # Apache 2.4
   
#      Require ip 127.0.0.1
#      Require ip ::1
        Require all granted
   

 

 
[...]

重要提示:不过让localhost以外的人访问数据库,应视为危险,除非通过SSL适当保护。做到这一点需要您自担风险。

保存并关闭文件。重新启动httpd服务。

systemctl restart httpd

OK,打开 phpmyadmin 测试一下:

好了,安装完毕!

下面关于LAMP相关的内容你可能也喜欢

LAMP平台安装Xcache和Memcached加速网站运行  http://www.linuxidc.com/Linux/2015-06/118835.htm 

CentOS 7下搭建LAMP平台环境  http://www.linuxidc.com/Linux/2015-06/118818.htm

CentOS 6.5系统安装配置LAMP(Apache+PHP5+MySQL)服务器环境 http://www.linuxidc.com/Linux/2014-12/111030.htm

Ubuntu 14.04 配置 LAMP+phpMyAdmin PHP(5.5.9)开发环境  http://www.linuxidc.com/Linux/2014-10/107924.htm

Ubuntu 14.10 下安装 LAMP 服务图文详解  http://www.linuxidc.com/Linux/2014-12/110082.htm

LAMP结合NFS构建小型博客站点  http://www.linuxidc.com/Linux/2015-08/121029.htm

更多Fedora相关信息见Fedora 专题页面 http://www.linuxidc.com/topicnews.aspx?tid=5

本文永久更新链接地址:http://www.linuxidc.com/Linux/2015-11/124968.htm


推荐阅读
  • Centos下安装memcached+memcached教程
    本文介绍了在Centos下安装memcached和使用memcached的教程,详细解释了memcached的工作原理,包括缓存数据和对象、减少数据库读取次数、提高网站速度等。同时,还对memcached的快速和高效率进行了解释,与传统的文件型数据库相比,memcached作为一个内存型数据库,具有更高的读取速度。 ... [详细]
  • 1.安装libeventyuminstalllibevent.x86_64libevent-devel.x86_64没有libevent编译memcached为出错checking ... [详细]
  • 阿里云主机实战应用之centos7上的防火墙设置
    最近公司又上了一台服务器,以前都是用centos6系统,这次选择使用了centos7系统的安装镜像,因为现在程序版本在centos7上一般php默认就是5.4以上的,mysql也 ... [详细]
  • CentOS 7部署KVM虚拟化环境之一架构介绍
    本文介绍了CentOS 7部署KVM虚拟化环境的架构,详细解释了虚拟化技术的概念和原理,包括全虚拟化和半虚拟化。同时介绍了虚拟机的概念和虚拟化软件的作用。 ... [详细]
  • 开发笔记:Memcached高性能内存对象缓存系统
    篇首语:本文由编程笔记#小编为大家整理,主要介绍了Memcached高性能内存对象缓存系统相关的知识,希望对你有一定的参考价值。一、Memcached概述 ... [详细]
  • 1.ATP方式安装在ubuntu系统的apt软件仓库中,默认存在MySQL数据库,所以直接使用apt命令就可以安装。使用命令:aptapt-getin ... [详细]
  • 篇首语:本文由编程笔记#小编为大家整理,主要介绍了CentOS7编译mysql8.0.12相关的知识,希望对你有一定的参考价值。步骤一:安装 ... [详细]
  • 如何部署Zabbix监控实现监测和报警机制
    这篇文章的知识点包括:Zabbix的安装部署、Zabbix监控的实现以及Zabbix报警机制的实现,阅读完整文相信大家对Zabbix监控的使用有了一定的认识。Zabb ... [详细]
  • 相对于内存来说,磁盘的容量是非常大的,所以Linux内核实现了一个叫 内存交换 的功能--把某些进程的一些暂时用不到的内存页保存到磁盘中,然后把物理内存页分配给更紧急的用户使用,当 ... [详细]
  • MYsql_linux mysql
    篇首语:本文由编程笔记#小编为大家整理,主要介绍了linuxmysql相关的知识,希望对你有一定的参考价值。一数据库安装查看:[[email pr ... [详细]
  • 1、MySQL标志说明MySQL的海豚标志的名字叫“sakila”,它是由MySQLAB的创始人从用户在“海豚命名”的竞赛中建议的大量的名字表中选出的。获胜的名字是由 ... [详细]
  • MySQL for OPS 08:MHA 高可用
    MySQL for OPS 08:MHA 高可用 ... [详细]
  • PHP设置MySQL字符集的方法及使用mysqli_set_charset函数
    本文介绍了PHP设置MySQL字符集的方法,详细介绍了使用mysqli_set_charset函数来规定与数据库服务器进行数据传送时要使用的字符集。通过示例代码演示了如何设置默认客户端字符集。 ... [详细]
  • 本文介绍了如何使用php限制数据库插入的条数并显示每次插入数据库之间的数据数目,以及避免重复提交的方法。同时还介绍了如何限制某一个数据库用户的并发连接数,以及设置数据库的连接数和连接超时时间的方法。最后提供了一些关于浏览器在线用户数和数据库连接数量比例的参考值。 ... [详细]
  • LVS实现负载均衡的原理LVS负载均衡负载均衡集群是LoadBalance集群。是一种将网络上的访问流量分布于各个节点,以降低服务器压力,更好的向客户端 ... [详细]
author-avatar
黄敬定241
这个家伙很懒,什么也没留下!
PHP1.CN | 中国最专业的PHP中文社区 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved | 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有