搭建lamp(linux+apache+mysql+php)_centos7 yum安装配置Lamp(Linux+Apache+MySql+Php)

1.安装apache

[root@localhost ~]# yum install httpd

根据提示,输入Y安装即可成功安装

systemctl start httpd.service #启动apache

systemctl stop httpd.service #停止apache

systemctl restart httpd.service #重启apache

systemctl enable httpd.service #设置apache开机启动

2.安装mariadb(MySQL)

[root@localhost ~]# yum install mariadb mariadb-server

询问是否要安装,输入Y即可自动安装,直到安装完成

systemctl start mariadb.service #启动MariaDB

systemctl stop mariadb.service #停止MariaDB

systemctl restart mariadb.service #重启MariaDB

systemctl enable mariadb.service #设置开机启动

3.修改mysql密码,安装后默认为空

修改mysql密码为root:

[root@localhost ~]# mysql -u root

MariaDB [(none)]> set password for 'root'@'localhost'=password('root');

再次登录mysql,验证密码 root

[root@localhost ~]# mysql -u root -p

Enter password:

Welcome to the MariaDB monitor. Commands end with ; or \g.

Your MariaDB connection id is 6

Server version: 5.5.50-MariaDB MariaDB Server

Copyright (c) 2000, 2016, Oracle, MariaDB Corporation Ab and others.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

MariaDB [(none)]>

mysql授权远程连接(navicat等):

MariaDB [(none)]> grant all on *.* to root identified by 'root';

Query OK, 0 rows affected (0.00 sec)

4.安装PHP以及组件,使PHP支持 MariaDB

yum install php php-mysql php-gd libjpeg* php-ldap php-odbc php-pear php-xml php-xmlrpc php-mbstring php-bcmath php-mhash

选择以上安装包进行安装,根据提示输入Y回车

#重启MariaDB

systemctl restart mariadb.service

#重启apache

systemctl restart httpd.service

5.访问测试

[root@localhost ~]# cd /var/www/html

[root@localhost html]# vi index.php

#输入下面内容

phpinfo();

?>

按Esc键 输入

:wq!

#保存退出

在客户端浏览器输入服务器IP地址,可以看到如下图所示相关的配置信息!

956d8351665772a7042d7e3744ab8fd4.png

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

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值