Linux部署lamp(centos 7),照做就行

大家好,今天我们来分享一下Linux上部署lamp
lamp指的是Linux+Apache+MySQL数据库+php几者相结合的web框架结构

虽然我在这之前,就写过有关于这方面的博客,但是那个不详细

今天再写一下

测试服务器是否可以上网

[root@localhost ~]# ping www.baidu.com
PING www.a.shifen.com (180.101.49.11) 56(84) bytes of data.
64 bytes from 180.101.49.11 (180.101.49.11): icmp_seq=1 ttl=128 time=9.78 ms
64 bytes from 180.101.49.11 (180.101.49.11): icmp_seq=2 ttl=128 time=7.27 ms
64 bytes from 180.101.49.11 (180.101.49.11): icmp_seq=3 ttl=128 time=25.3 ms
64 bytes from 180.101.49.11 (180.101.49.11): icmp_seq=4 ttl=128 time=8.80 ms
^C
--- www.a.shifen.com ping statistics ---
4 packets transmitted, 4 received, 0% packet loss, time 4026ms
rtt min/avg/max/mdev = 7.270/12.813/25.389/7.315 ms
[root@localhost ~]# 

以上的结果没有问题

安装http服务

[root@localhost ~]# yum install  httpd -y
已加载插件:fastestmirror, langpacks
Loading mirror speeds from cached hostfile
 * base: mirrors.aliyun.com
 * centos-ceph-nautilus: mirrors.cn99.com
 * centos-nfs-ganesha28: mirrors.cn99.com
 * centos-openstack-train: mirrors.cn99.com
 * centos-qemu-ev: mirrors.ustc.edu.cn
 * extras: mirrors.aliyun.com
 * updates: mirrors.aliyun.com
base                                                                                                     | 3.6 kB  00:00:00     
centos-ceph-nautilus                                                                                     | 3.0 kB  00:00:00     
centos-nfs-ganesha28                                                                                     | 3.0 kB  00:00:00     
centos-openstack-train                                                                                   | 3.0 kB  00:00:00     
centos-qemu-ev                                                                                           | 3.0 kB  00:00:00     
docker-ce-stable                                                                                         | 3.5 kB  00:00:00     
docker-ce-test                                                                                           | 3.5 kB  00:00:00     
epel                                                                                                     | 4.7 kB  00:00:00     
extras                                   

开启http服务

[root@localhost ~]# systemctl  start  httpd

设置http服务为开机自启动

[root@localhost ~]# systemctl  enable  httpd
Created symlink from /etc/systemd/system/multi-user.target.wants/httpd.service to /usr/lib/systemd/system/httpd.service.
[root@localhost ~]# 

设置防火墙的策略

[root@localhost ~]# firewall-cmd --permanent --add-service=http
You're performing an operation over default zone ('public'),
but your connections/interfaces are in zone 'work' (see --get-active-zones)
You most likely need to use --zone=work option.

success

重启防火墙

[root@localhost ~]# systemctl restart firewalld

浏览器访问http服务(状态正常)

在这里插入图片描述
到这里,Apache服务器安装成功

接下来,我们来安装一下MySQL,我们在这里使用mariadb数据库,它们在功能和使用上是一样的

安装 mariadb 数据库

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

开启maridb数据库

[root@localhost ~]# systemctl  start  mariadb.service 

设置mariadb数据库的开机自启动

[root@localhost ~]# systemctl  enable  mariadb.service 
Created symlink from /etc/systemd/system/multi-user.target.wants/mariadb.service to /usr/lib/systemd/system/mariadb.service.
[root@localhost ~]# 

设置数据库密码

[root@localhost ~]# mysql_secure_installation

点击回车就可以了

在这里插入图片描述
设置密码

Set root password? [Y/n] y
New password: 
Re-enter new password: 
Password updated successfully!
Reloading privilege tables..
 ... Success!

是否删除匿名用户 yes

在这里插入图片描述

是否禁止远程登录

在这里插入图片描述

是否删除test数据库 yes
在这里插入图片描述

是否重新加载权限表
在这里插入图片描述
安装php 环境

[root@localhost ~]# yum install php php-mysql php-gd php-pear -y

编写一个PHP 的测试脚本

[root@localhost ~]# vim /var/www/html/testphp.php
<?php 
phpinfo();
?>

重启Apache

[root@localhost ~]# systemctl  restart  httpd.service 


浏览器上访问

http://192.168.1.12/testphp.php

这样的话,PHP环境就没有问题

在这里插入图片描述

安装一下依赖

[root@localhost ~]# yum install epel-release -y

安装phpmyadmin 这个软件

[root@localhost ~]# yum install phpmyadmin -y

编辑这个配置文件

vim /etc/httpd/conf.d/phpMyAdmin.conf

在配置文件当中加上这一块

<Directory /usr/share/phpMyAdmin/>

        Options none

        AllowOverride Limit

        Require all granted

</Directory>

截图:
如果你不知道将这一块放到哪里,就看上面的行数

在这里插入图片描述
编辑这个配置文件

[root@localhost ~]# vim /etc/phpMyAdmin/config.inc.php

这样改成http
在这里插入图片描述

从浏览器上访问phpmyadmin

在这里插入图片描述

root 是用户
密码: 123456 (这是设置的MySQL数据库密码)
在这里插入图片描述

成功进入

在这里插入图片描述
这样,我们就可以在浏览器上操作MySQL数据库了
这样会更加的方便

好了,有关于Linux部署lamp的环境,就到这里了,谢谢大家

  • 13
    点赞
  • 42
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 11
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

思诚代码块

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值