centos安装web服务器 LAMP(Linux Apache MySQL PHP)

centos7上搭建http服务器,yum搭建LAMP环境,linux下搭建PHP+apache+mysql环境

首先更新源(要安装新版本的LAMP,这里使用第三方yum源):

CentOs 6.x
    rpm -Uvh http://mirror.webtatic.com/yum/el6/latest.rpm
CentOs 7.x  
    rpm -Uvh https://mirror.webtatic.com/yum/el7/epel-release.rpm
    rpm -Uvh https://mirror.webtatic.com/yum/el7/webtatic-release.rpm

演示服务器linux系统版本(阿里云新服务器)

cat /etc/issue
#或者
cat /etc/redhat-release

CentOS release 6.8 (Final)

安装对应版本的源

yum install epel-release

Complete!

#安装httpd(apache)
yum -y install httpd
#启动服务
service httpd start
#将httpd加入启动项中 开启自启动
chkconfig httpd on


#重启apache
service httpd restart
#停止apache
service httpd stop

如果是阿里云的服务器记得打开80端口,在安全组配置 - 配置规则 - 添加安全组规则 协议类型选择 HTTP (80)

安装指定版本的php5.6、mysql

yum -y install php56w-devel php56w.x86_64 php56w-cli.x86_64 php56w-common.x86_64 php56w-gd.x86_64 php56w-ldap.x86_64 php56w-mbstring.x86_64 php56w-mcrypt.x86_64 php56w-mysql.x86_64  php56w-pdo.x86_64 php56w-pear.noarch php56w-pecl-igbinary.x86_64 php56w-pecl-redis.x86_64 php56w-bcmath.x86_64 php56w-fpm.x86_64

Complete!

如果需要先卸载低版本再安装Mysql5.7版本 查看这个地址  >>   Linux 卸载安装Mysql(图文卸载安装方法)

#mysql5.7

#下载centos6的 mysql rpm包

wget https://dev.mysql.com/get/mysql57-community-release-el6-9.noarch.rpm

yum -y install wget

继续

yum localinstall -y mysql57-community-release-el6-9.noarch.rpm
yum -y install mysql-community-server --nogpgcheck

Complete!

如果是centos7

wget http://repo.mysql.com/mysql57-community-release-el7-8.noarch.rpm

rpm -ivh mysql57-community-release-el7-8.noarch.rpm

yum -y install mysql-server

systemctl enable mysqld.service

systemctl start mysqld.service

#设置mysql自启动
chkconfig mysqld on
#启动mysql
service mysqld start
#查找Mysql5.7 默认密码
grep 'temporary password' /var/log/mysqld.log
#登录Mysql
mysql -uroot -p

Mysql 相关操作

-- 设置密码为TLEwOIF:Y|>G@H1 '' 引号中间输入自定义密码

ALTER USER 'root'@'localhost' IDENTIFIED BY 'TLEwOIF:Y|>G@H1';

-- 开启远程连接(外网访问)

use mysql;
update user set host = '%' where user = 'root'; 

-- 刷新权限

FLUSH PRIVILEGES;

-- 检测远程连接开启状态

select user,host from user;

注:开启远程访问 一般情况下,外网的服务器需要开启3306端口,(阿里云)在安全组配置 - 配置规则 - 添加安全组规则 协议类型选择 MySQL (3306)

#重启Mysql

service mysqld restart

#停止Mysql

service mysqld stop

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值