RELATEED CONSULTING
相关咨询
选择下列产品马上在线沟通
服务时间:8:30-17:00
你可能遇到了下面的问题
关闭右侧工具栏

新闻中心

这里有您想知道的互联网营销解决方案
Centos7.2系统上怎么用yum安装lamp环境

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

成都创新互联于2013年开始,先为陆港等服务建站,陆港等地企业,进行企业商务咨询服务。为陆港企业网站制作PC+手机+微官网三网同步一站式服务解决您的所有建站问题。

一、准备工作

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版本:

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

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


当前名称:Centos7.2系统上怎么用yum安装lamp环境
文章位置:http://sczitong.cn/article/gchdds.html