LAMP环境搭建(centos)

1. 安装apache

yum install -y httpd

开启
systemctl start httpd或者systemctl start httpd.service

开机启动
systemctl enable httpd.service

2.安装MYSQL 1.mysql安装准备:
CentOS7的yum源中默认是没有mysql的。为了解决这个问题,我们要先下载mysql的repo源。
(1).下载 mysql的repo
wget https://dev.mysql.com/get/mysql57-community-release-el7-11.noarch.rpm

(2)安装mysql源安装包
rpm -ivh mysql57-community-release-el7-11.noarch.rpm

安装这个包后,会获得两个mysql的yum repo源:/etc/yum.repos.d/mysql-community.repo,/etc/yum.repos.d/mysql-community-source.repo。
2.安装Mysql
yum -y install mysql-community-server

3.启动Mysql服务
systemctl start mysqld

4.设置开机启动
systemctl enable mysqld

5.查看mysql的root账号的密码
more/var/log/mysqld.log

6.登录mysql mysql -u root -p 修改密码
set password=password('Qwer.123456');

//修改root用户可远程登录
GRANT ALL PRIVILEGES ON *.* TO 'root'@'%'IDENTIFIED BY 'Qwer.123456' WITH GRANT OPTION;

//立即生效
flush privileges;

3.安装php 3.1 删除以前的php版本(跟上面删除mysql的命令是一样的) 先查看
rpm -qa | grep php

再删除
yum remove 文件名

3.2 配置yum源 事先确认yum源的链接是不是有效的。
yum install epel-release rpm -ivh http://rpms.famillecollet.com/enterprise/remi-release-7.rpm

3.3 确认安装的php版本
yum list --enablerepo=remi --enablerepo=remi-php56 | grep php

3.4 安装php5.6
yum install --enablerepo=remi --enablerepo=remi-php56 php php-opcache php-pecl-apcu php-devel php-mbstring php-mcrypt php-mysqlnd php-phpunit-PHPUnit php-pecl-xdebug php-pecl-xhprof php-pdo php-pear php-fpm php-cli php-xml php-bcmath php-process php-gd php-common

php-opcache及php-pecl-apcu会有效的提高php执行速度。
3.5 确认php版本
php -v

【LAMP环境搭建(centos)】安装成功
(默认根目录 /var/www/html/)
参考链接:https://yq.aliyun.com/articles/106387

    推荐阅读