Centos7配置LAMP环境

**

CentOS 7配置LAMP

**

LAMP是指一组通常一起使用来运行动态网站或者服务器的自由软件名称首字母缩写:
Linux,操作系统
Apache,网页服务器
MariaDB或MySQL,数据库管理系统(或者数据库服务器)
PHP、Perl或Python,脚本语言
一般用来建立web应用平台。

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

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

 yum install httpd -y 

设置开机自启动

systemctl start httpd
systemctl enable httpd

firewall设置允许远程登录:

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

浏览器登陆测试apache:
http://192.168.159.131
在这里插入图片描述

  1. MariaDB数据库管理系统

安装MariaDB:

yum install mariadb-server mariadb -y

设置开机自启动:

systemctl start mariadb
systemctl enable maraiadb

设置数据库密码:

mysql_secure_installation
  1. PHP

安装php:

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

在Apache文档根目录创建“testphp.php”测试PHP:

vi /var/www/html/testphp.php
	<?php 
	 phpinfo(); 
	 ?>

重启 httpd 服务:

systemctl restart httpd

网页登陆,验证php是否成功:
在这里插入图片描述

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

安装epel:

yum install epel-release

安装phpMYadmin:

yum install phpmyadmin -y

配置phpMyAdmin远程访问,编辑phpmyadmin.conf file:

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

删除如下内容:

<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

修改 ‘cookie’ 为 ‘http’:


`$cfg['Servers'][$i]['auth_type']     = 'http';    // Authentication method (config, http or cookie based)?

重启 Apache 服务:

systemctl restart httpd

.登陆浏览器验证http://192.168.159.131/phpmyadmin

在这里插入图片描述

登陆成功:

在这里插入图片描述

  1. 如果遇见如下报错:
    “You don’t have permission to access /index.html on this server.”

设置链接,可解决问题:

ln -s /usr/share/phpMyAdmin /var/www/html/phpmyadmin

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值