CentOS 7.4 yum安装LAMP环境

时间:2023-03-09 13:25:45
CentOS 7.4 yum安装LAMP环境

配置防火墙,开启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 -m state --state NEW -m tcp -p tcp --dport 8080 -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

  主机访问虚拟机ip

  CentOS 7.4 yum安装LAMP环境

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

然后安装musql,但是yum源上面没有mysql,只有用wget去mysql官网去下载,先查看和安装wget

一:安装

1、查看是否安装:

           rpm -qa|grep "wget"

如果已安装会显示wget相关信息

2、安装wget:

           yum -y install wget

当看到Complete!表示成功安装完成!

# wget http://dev.mysql.com/get/mysql-community-release-el(ps:小写L)7-5.noarch.rpm

# rpm -ivh mysql-community-release-el7-5.noarch.rpm

# yum install mysql-community-server

网络不好的情况下,过程有点漫长~。安装完成后重启mysql,  systemctl restarat mysqld.service

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

[root@linuxidc-web linuxidc]# 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; 
安装PHP
由于yum源里面没有php7,所以由另一篇博客记录php7的安装过程
http://www.cnblogs.com/pcyy/p/8567962.html