Centos搭建LAMP环境+phpmyadmin

1.安装epel

rpm --import /etc/pki/rpm-gpg/RPM-GPG-KEY*
yum -y install epel-release

2.安装MySQL/MariaDB

yum -y install mariadb-server mariadb //yum 安装MariaDB

systemctl start mariadb.service  //启动
systemctl enable mariadb.service //设置为开机启动模式

mysql_secure_installation //MySQL账号设置

[root@server1 ~]# mysql_secure_installation
.......

Enter current password for root (enter for none): <--ENTER
OK, successfully used password, moving on...

Set root password? [Y/n]  <--ENTER
New password: 输入你的密码
Re-enter new password: 再次输入你的密码
Password updated successfully!
Reloading privilege tables..
 ... Success!

Remove anonymous users? [Y/n] <--ENTER //删除匿名用户
 ... Success!

Disallow root login remotely? [Y/n] <--ENTER  //禁止远程登陆
 ... Success!

Remove test database and access to it? [Y/n] <--ENTER //删除测试数据库并访问它
 - Dropping test database...
 ... Success!
 - Removing privileges on test database...
 ... Success!

Reload privilege tables now? [Y/n] <--ENTER //是否现在加载权限表
 ... Success!

Thanks for using MariaDB!

3.安装 Apache并打开防火墙端口

yum -y install httpd

systemctl start httpd.service
systemctl enable httpd.service

firewall-cmd --permanent --zone=public --add-service=http 
firewall-cmd --permanent --zone=public --add-service=https
firewall-cmd --reload

4.安装PHP

yum -y install php
systemctl restart httpd.service
vi /var/www/html/info.php  //在次目录下新建一个info.php文件

<?php phpinfo(); ?>       //info.php文件里要写的内容 可通过访问 127.0.0.1/info.php 查看php的配置信息

5.安装PHP对MySQL的支持包

yum search php
yum -y install php-mysql
yum -y install php-gd php-ldap php-odbc php-pear php-xml php-xmlrpc php-mbstring php-snmp php-soap curl curl-devel
systemctl restart httpd.service

6.安装phpMyAdmin

yum install phpMyAdmin

vi /etc/httpd/conf.d/phpMyAdmin.conf //打开phpMyAdmin.conf文件并作如下修改
----------------------------------------------------------------------------
//在phpMyAdmin.conf文件中将下列代码注释掉,结果如下
#<Directory /usr/share/phpMyAdmin/>
#   <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>
---------------------------------------------------------------------

vi /etc/phpMyAdmin/config.inc.php  //打开config.inc.php文件,并作如下修改 
----------------------------------------------------------------------------------
//一般默认为cookie 将其改为 http
$cfg['Servers'][$i]['auth_type']     = 'http';    // Authentication method (config, http
--------------------------------------------------------------------------------------
systemctl restart  httpd.service //最后重启服务

7.最后登录http://127.0.0.1/phpmyadmin/可通过网页查看数据库

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值