Centos 搭建LAMP环境

1 安装 Apache

		yum install httpd
		service httpd  restart // 重启
		chkconfig httpd on  // 开机自动运行

访问ip 或者 curl http://localhost 查看是否生效
如果这时候发现无法访问公网ip, 云服务器后台的安全组。
1 、添加一条 入方向的规则
允许 自定义 TCP
80/80 地址段访问
0.0.0.0/0
apahce
1 2017-06-27 11:31:46
mysql 3306 设置同理
2、无法连接。有密钥 ,可以在密钥管理中删除密钥,也可以使用密钥连接。建议删除

2 安装 php 7

	//更新源
	rpm -Uvh https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
	rpm -Uvh https://mirror.webtatic.com/yum/el7/webtatic-release.rpm
	 // yum 安装
	 yum install php70w

如果发生Loaded plugins: fastestmirror Determining fastest mirrors 的错误问题
其大概意思是fastestmirror不能使用,fastestmirror是yum的一个加速插件
修改配置文件

	vi  /etc/yum/pluginconf.d/fastestmirror.conf   
	enabled=0  //把1改为0  
	verbose=0  
	socket_timeout=3  
	hostfilepath=/var/cache/yum/timedhosts.txt   
	maxhostfileage=10  
	maxthreads=15  
	#exclude=.gov, facebook

 	vi /etc/yum.conf
	cachedir=/var/cache/yum/$basearch/$releasever
	keepcache=0
	debuglevel=2
	logfile=/var/log/yum.log
	exactarch=1
	obsoletes=1
	gpgcheck=1
	plugins=1                 #将plugins的值修改为0
	installonly_limit=5

service httpd restart // 重启apache
vi /var/www/html/index.php

<?php phpinfo(); ?>

访问ip 查看phpinfo

3 安装mysql5.7

	// 更新源
	rpm -ivh http://dev.mysql.com/get/mysql57-community-release-el7-7.noarch.rpm
	//安装
	yum install mysql-community-server
	//启动
	service mysqld start
	// 开机启动
	systemctl start mysqld.service

Mysql5.7默认安装之后root是有密码的
为了加强安全性,MySQL5.7为root用户随机生成了一个密码,在error log中,关于error log的位置,如果安装的是RPM包,则默认是/var/log/mysqld.log。
只有启动过一次mysql才可以查看临时密码

	grep ‘temporary password’ /var/log/mysqld.log
	 
	 [Note] A temporary password is generated for root@localhost: y#tpUjEHy6Bs
	//临时密码就是 localhost: 之后的

3.1 修改密码

	mysql -uroot -p   // 使用默认密码登录 必须立刻修改密码 不然会报错
	You must reset your password using ALTER USER statement before executing this statement.
	//修改密码
	ALTER USER 'root'@'localhost' IDENTIFIED BY 'root123';

3.2 安装扩展

	yum install php70w-mysql
	service httpd  restart // 重启生效
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值