服务器之家:专注于服务器技术及软件下载分享
分类导航

Linux|Centos|Ubuntu|系统进程|Fedora|注册表|Bios|Solaris|Windows7|Windows10|Windows11|windows server|

服务器之家 - 服务器系统 - Centos - Centos7.2 系统上yum安装lamp环境

Centos7.2 系统上yum安装lamp环境

2021-11-23 17:21向北☆ Centos

这篇文章主要介绍了centos7.2 系统上yum安装lamp环境的相关资料,非常不错具有参考借鉴价值,需要的朋友可以参考下

一、准备工作

  1. 下载并安装centos7.2,配置好网络环境,确保centos能上网,可以获取到yum源。

     centos7.2的下载地址:http://pan.baidu.com/s/1ertjats 密码:wnby

centos7.2的网络配置:

?
1
vim /etc/sysconfig/network-scripts/ifcfg-eno16777736

参考以下网络配置:

?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
type=ethernet
bootproto=static
defroute=yes
peerdns=yes
peerroutes=yes
ipv4_failure_fatal=no
ipv6init=yes
ipv6_autoconf=yes
ipv6_defroute=yes
ipv6_peerdns=yes
ipv6_peerroutes=yes
ipv6_failure_fatal=no
name=eno16777736
uuid=a90b6241-89da-450a-9742-d5b186a17084
device=eno16777736
onboot=yes
ipaddr0=192.168.0.228
prefixo0=24
gateway0=192.168.0.1
dns1=192.168.0.1

    配置完毕后,使用 systemctl restart network.service 重启网络,然后 ping www.baidu.com 测试是否网络连接通畅。

  2. 配置防火墙,开启80、3306端口。centos 7.0默认使用的是firewall作为防火墙,这里改为iptables防火墙。      

?
1
2
3
4
5
6
7
8
#停止firewall服务
systemctl stop firewalld.service
#禁止firewall开机启动
systemctl disable firewalld.service
#安装
yum install iptables-services
#编辑防火墙配置文件
vi /etc/sysconfig/iptables

加入红色的两行代码,请注意位置一定要对应。

?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
# firewall configuration written by system-config-firewall
# manual customization of this file is not recommended.
*filter
:input accept [0:0]
:forward accept [0:0]
:output accept [0:0]
-a input -m state --state established,related -j accept
-a input -p icmp -j accept
-a input -i lo -j accept
-a input -m state --state new -m tcp -p tcp --dport 22 -j accept
-a input -m state --state new -m tcp -p tcp --dport 80 -j accept
-a input -m state --state new -m tcp -p tcp --dport 3306 -j accept
-a input -j reject --reject-with icmp-host-prohibited
-a forward -j reject --reject-with icmp-host-prohibited
commit
:wq! #保存退出
#最后重启防火墙使配置生效
systemctl restart iptables.service
#设置防火墙开机启动
systemctl enable iptables.service

  3. 关闭seinux  

?
1
2
3
4
5
6
7
8
#修改配置文件
vi /etc/selinux/config
#selinux=enforcing #注释掉
#selinuxtype=targeted #注释掉
selinux=disabled #增加
:wq! #保存退出
#使配置立即生效
setenforce 0

二、安装lamp环境。

  1. 安装apahce   

?
1
yum install httpd

可能会用到的:

?
1
2
3
4
systemctl start httpd.service #启动apache
systemctl stop httpd.service #停止apache
systemctl restart httpd.service #重启apache
systemctl enable httpd.service #设置apache开机启动

  重启服务, systemctl restart httpd.service

  输入localhost

  出现之后代表已经安装上去了。

Centos7.2 系统上yum安装lamp环境

  2. 安装mysql。

    由于yum源上没有mysql-server。所以必须去官网下载,这里 我们用wget命令,直接获取。    

?
1
2
3
# wget http://dev.mysql.com/get/mysql-community-release-el7-5.noarch.rpm
# rpm -ivh mysql-community-release-el7-5.noarch.rpm
# yum install mysql-community-server

安装完成后重启mysql, systemctl restarat mysqld.service

   初入安装 root用户没有密码:    

?
1
2
3
4
5
6
7
[root@yl-web yl]# mysql -u root
#设置msyql密码为 123456
mysql> set password for 'root'@'localhost' =password('123456');
#远程连接设置,所有以root账号连接的远程用户,设其密码为 123456
mysql> grant all privileges on *.* to root@'%'identified by '123456';
#更新权限
mysql>flush privileges;

  3. 安装php 

?
1
2
3
4
5
6
yum install php
#安装php组件,使php支持mysql
yum install php-mysql php-gd libjpeg* php-ldap php-odbc php-pear php-xml php-xmlrpc php-mbstring php-bcmath php-mhash
#重启对应服务
systemctl restart mysqld.service
systemctl restart httpd.service

以上 安装 apahce 、mysql 、php 安装完毕。

查看安装环境版本:cd /var/www/html ,新建index.php文件,输入:

?
1
2
<?php
phpinfo();

最终查看为:php版本:

Centos7.2 系统上yum安装lamp环境

参考链接:http://www.centoscn.com/centosserver/www/2016/0331/6964.html

以上所述是小编给大家介绍的centos7.2 系统上yum安装lamp环境,希望对大家有所帮助,如果大家有任何疑问请给我留言,小编会及时回复大家的。在此也非常感谢大家对服务器之家网站的支持!

原文链接:http://www.cnblogs.com/wgq123/archive/2016/11/04/6028718.html

延伸 · 阅读

精彩推荐
  • Centos在CentOS系统上安装Docker的教程

    在CentOS系统上安装Docker的教程

    这篇文章主要介绍了在CentOS系统上安装Docker的教程,Docker是当下人气最为火热的容器类虚拟软件,需要的朋友可以参考下 ...

    开源中文社区3952019-09-17
  • CentosCentOS系统下软件包的制作方法和过程详解

    CentOS系统下软件包的制作方法和过程详解

    今天小编将为大家带来的是CentOS系统下软件包的制作方法和过程详解;希望对大家会有帮助,有需要的朋友一起去看看吧...

    CentOS之家4802019-05-30
  • CentosCentOS7 阿里云的yum源使用详解

    CentOS7 阿里云的yum源使用详解

    这篇文章主要介绍了CentOS7 阿里云的yum源使用详解的相关资料,这里对备份yum源,添加EPEL源,和缓存清理,进行了介绍,需要的朋友可以参考下...

    天王9312020-12-28
  • CentosCentOS 最新版本git的安装教程

    CentOS 最新版本git的安装教程

    本文主要给大家介绍了CentOS 最新版本git的安装教程,非常不错,具有参考借鉴价值,感兴趣的朋友一起看看吧...

    CentOS教程网9252021-11-29
  • CentosCentOS6.2网卡设置

    CentOS6.2网卡设置

    如果你想让服务器可以更新、让网友访问你的LINUX服务器,那一定要设置LINUX网上给网卡绑定一个IP,下面我们就介绍CentOS6.2网卡设置IP的方法。...

    CentOS教程网10092021-10-03
  • Centoscentos 7中添加一个新用户并授权的步骤详解

    centos 7中添加一个新用户并授权的步骤详解

    这篇文章主要给大家介绍了关于在centos 7中添加一个新用户并授权的步骤,文中将实现的步骤介绍的非常详细,通过文中介绍的步骤可以轻松的创建一个新...

    Ryan.Miao9832022-02-12
  • CentosCentOS上SVN服务器端程序的安装与使用教程

    CentOS上SVN服务器端程序的安装与使用教程

    SVN是一款高人气的软件项目版本控制系统,由于其在Windows的客户端的简易操作,在Git的浪潮中仍然保有很多的用户数量,这里我们就来看一下CentOS上SVN服务器端...

    cnblogs3902019-07-16
  • Centos使用Xshell连接Centos 6.6服务器操作图文教程

    使用Xshell连接Centos 6.6服务器操作图文教程

    这篇文章主要介绍了使用Xshell连接Centos 6.6服务器操作图文教程,本文用详细的操作步骤讲解了如何使用Xshell连接Centos服务器,需要的朋友可以参考下 ...

    脚本之家4032019-09-18