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

发布时间:2022-05-07 15:58:10 作者:iii
来源:亿速云 阅读:144

这篇文章主要介绍“Centos7.2系统上怎么用yum安装lamp环境”的相关知识,小编通过实际案例向大家展示操作过程,操作方法简单快捷,实用性强,希望这篇“Centos7.2系统上怎么用yum安装lamp环境”文章能帮助大家解决问题。

一、准备工作

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

centos7.2的网络配置:

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

参考以下网络配置:

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防火墙。      

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

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

# 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  

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

二、安装lamp环境。

  1. 安装apahce   

yum install httpd

可能会用到的:

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命令,直接获取。    

# 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用户没有密码:    

[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 

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文件,输入:

<?php
phpinfo();

最终查看为:php版本:

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

关于“Centos7.2系统上怎么用yum安装lamp环境”的内容就介绍到这里了,感谢大家的阅读。如果想了解更多行业相关的知识,可以关注亿速云行业资讯频道,小编每天都会为大家更新不同的知识点。

推荐阅读:
  1. CentOS7.2 上 Nginx PHP Mariadb 环境搭建
  2. yum安装LAMP

免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。

centos yum lamp

上一篇:CentOS7怎么修改服务器系统时间

下一篇:CentOS7安装MySQL5.6遇到的问题有哪些

相关阅读

您好,登录后才能下订单哦!

密码登录
登录注册
其他方式登录
点击 登录注册 即表示同意《亿速云用户服务条款》