centos下yum搭建安装linux+apache+mysql+php环境的方法

2019-10-13 18:39:38王旭

一、脚本YUM源安装:

1.yum install wget                           #安装下载工具wget
2.wget http://www.atomicorp.com/installers/atomic    #下载atomic yum源,配置CentOS 6.5第三方yum源
3. sh  ./atomic                             #脚本执行
4. yum check-update                        #更新yum软件包

二、163yum源的安装

1.进入yum源配置目录

cd /etc/yum.repos.d

2.备份系统自带的yum源

mv CentOS-Base.repo CentOS-Base.repo.bk

3.下载163网易的yum源:

centos7.x:
wget http://mirrors.163.com/.help/CentOS7-Base-163.repo
centos6.x:
wget http://mirrors.163.com/.help/CentOS6-Base-163.repo

4.更新玩yum源后,执行下边命令更新yum配置,使操作立即生效

yum makecache

三、添加阿里yum更新源码:

1.安装wget:

yum install wget -y

2.备份你的原镜像文件,以免出错后可以恢复。

mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.backup

3.下载新的CentOS-Base.repo 到/etc/yum.repos.d/

CentOS 5:
wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-5.repo
CentOS 6:
wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-6.repo
CentOS 7:
wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo

4.然后重建缓存:

yum clean all
yum makecache

四、安装并配置MySQL

1. 执行yum命令安装MySQ

yum -y install mysql mysql-server

2 .把添加MySQL进开机启动项,并立即启动MySQL

chkconfig --levels 235 mysqld on  #重启自动启动服务
service mysqld start          #重新启动mysql服务

3.设置MySQL root帐号密码

mysql_secure_installation

  回车,根据提示输入Y

  输入2次密码,回车

  根据提示一路输入Y

  最后出现:Thanks for using MySQL!

  MySql密码设置完成,重新启动 MySQL

service mysqld start 
[root@localhost ~]# netstat -tulpn | grep -i mysql
tcp    0   0 0.0.0.0:3306     0.0.0.0:*     LISTEN   1723/mysqld

五、安装Apache

1. 使用yum命令安装Apache

yum –y install httpd

2.设置开机启动Apache

chkconfig --levels 235 httpd on

3.启动Apache

service httpd start

4. 现在直接在浏览器键入http://localhost或http://本机IP,应该会看到Apache的测试页面

### 安装apache 一些扩展###
root@localhost ~]# yum -y install httpd-manual mod_ssl mod_perl mod_auth_mysql