zoukankan      html  css  js  c++  java
  • Centos 7配置LAMP

    因为安装zabbix需要LAMP环境,特记录如下。

    LAMP指的Linux(操作系统)、Apache HTTP 服务器,MySQL(有时也指MariaDB,数据库软件)和PHP(有时也是指Perl或Python)的第一个字母,一般用来建立web应用平台。所有组成产品均是开源软件,是国际上成熟的架构框架,很多流行的商业应用都是采取这个架构,和Java/J2EE架构相比,LAMP具有Web资源丰富、轻量、快速开发等特点,微软的.NET架构相比,LAMP具有通用、跨平台、高性能、低价格的 优势,因此LAMP无论是性能、质量还是价格都是企业搭建网站的首选平台。

    下面讨论如何在RHEL/CentOS/Scientific Linux 7上搭建LAMP环境.

    一、Install Apache

    Apache HTTP Server(简称Apache)是Apache软件基金会的一个开放源码的网页服务器,可以在大多数计算机操作系统中运行,由于其多平台和安全性被广泛使用,是最流行的Web服务器端软件之一。它快速、可靠并且可通过简单的API扩展,将Perl/Python等解释器编译到服务器中。

    在终端以root权限运行以下命令:

    yum install httpd -y

    启动Apache

    systemctl start httpd

    设置开机启动

    systemctl enable httpd

    firewall设置允许远程登录:

    firewall-cmd --permanent --add-service=http
    
    systemctl restart firewalld

    测试Apache

    浏览器访问 http://localhost/ or http://server-ip-address/

    clip_image001[8]

    二、Install MariaDB

            MariaDB数据库管理系统是MySQL的一个分支,主要由开源社区在维护,采用GPL授权许可 MariaDB的目的是完全兼容MySQL,包括API和命令行,使之能轻松成为MySQL的代替品。 MariaDB由MySQL的创始人Michael Widenius(英语:Michael Widenius)主导开发,他早前曾以10亿美元的价格,将自己创建的公司MySQL AB卖给了SUN,此后,随着SUN被甲骨文收购,MySQL的所有权也落入Oracle的手中。MariaDB名称来自Michael Widenius的女儿Maria的名字。

    安装MariaDB

    yum install mariadb-server mariadb -y

    启动MariaDB

    systemctl start mariadb

    设置开机启动

    systemctl enable mariadb

    设置root密码

    默认情况下,root密码为空。为防止未授权的访问,我们设置root密码

    mysql_secure_installation

    三、Install PHP

    PHP(外文名:PHP: Hypertext Preprocessor,中文名:“超文本预处理器”)是一种通用开源脚本语言,主要适用于Web开发领域。

    使用以下的命令安装php

    yum install php php-mysql php-gd php-pear -y

    测试PHP:

    在Apache文档根目录创建“testphp.php”

    vi /var/www/html/testphp.php

    编辑内容如下

    <?php 
    
    phpinfo();
    
    ?>

    重启 httpd 服务:

    systemctl restart httpd

    浏览器访问 http://server-ip-address/testphp.php. 将会显示php的版本信息.

    clip_image002[4]

    也可以使用如下命令安装所有php modules,重启httpd服务,查看http://server-ip-address/testphp.php可以看到所有安装的modules

    yum install php* -y

    四、Install phpMyAdmin (可选)

    phpMyAdmin 是一个以PHP为基础,以Web-Base方式架构在网站主机上的MySQL的数据库管理工具,让管理者可用Web接口管理MySQL数据库。由于phpMyAdmin跟其他PHP程式一样在网页服务器上执行,您可以在任何地方使用这些程式产生的HTML页面,也就是于远端管理MySQL数据库,方便的建立、修改、删除数据库及资料表。也可借由phpMyAdmin建立常用的php语法,方便编写网页时所需要的sql语法正确性。

    添加 EPEL repository   参照(Install EPEL Repository on RHEL/CentOS/Scientific Linux 7

    yum install epel-release

    安装 phpMyAdmin:

    yum install phpmyadmin -y

    配置phpMyAdmin

    默认,phpMyAdmin只能由本机访问。为了能够远程访问,编辑phpmyadmin.conf file:

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

    查找/<Directory> ,注释掉或删除如下内容

    <Directory /usr/share/phpMyAdmin/>

       AddDefaultCharset UTF-8

     

       <IfModule mod_authz_core.c>

         # Apache 2.4

         <RequireAny>

           Require ip 127.0.0.1

           Require ip ::1

         </RequireAny>

       </IfModule>

       <IfModule !mod_authz_core.c>

         # Apache 2.2

         Order Deny,Allow

         Deny from All

         Allow from 127.0.0.1

         Allow from ::1

       </IfModule>

    </Directory>

     

    <Directory /usr/share/phpMyAdmin/setup/>

       <IfModule mod_authz_core.c>

         # Apache 2.4

         <RequireAny>

           Require ip 127.0.0.1

           Require ip ::1

         </RequireAny>

       </IfModule>

       <IfModule !mod_authz_core.c>

         # Apache 2.2

         Order Deny,Allow

         Deny from All

         Allow from 127.0.0.1

         Allow from ::1

       </IfModule>

    </Directory>

    添加

    <Directory /usr/share/phpMyAdmin/>

            Options none

            AllowOverride Limit

            Require all granted

    </Directory>

    编辑“config.inc.php” 改变phpMyAdmin的authentication,修改“cookie” 为 “http”

    vi /etc/phpMyAdmin/config.inc.php

    Change ‘cookie’ to ‘http’.

    clip_image003[4]

    重启the Apache service:

    systemctl restart httpd

    访问 phpmyadmin 的控制台 http://server-ip-address/phpmyadmin/

    clip_image004[4]

    输入MySQL username and password,将重定向到PhpMyAdmin main web interface.

    clip_image005

    现在你可以通过phpMyAdmin web interface 管理你的MariaDB数据库了。

    至此LAMP环境搭建完毕

    参考:

    http://www.unixmen.com/install-lamp-server-apache-mariadb-php-centosrhelscientific-linux-7/

  • 相关阅读:
    结对第一次—疫情统计可视化(原型设计)
    软工实践寒假作业(2/2)
    test
    软工实践寒假作业(1/2)
    json的基本用法
    个人作业——软件工程实践总结&个人技术博客
    个人作业——软件评测
    结对第二次作业——某次疫情统计可视化的实现
    寒假作业(2/2)— 疫情统计
    软工实践寒假作业(1/2)
  • 原文地址:https://www.cnblogs.com/xqzt/p/5123748.html
Copyright © 2011-2022 走看看