学习记录方便以后快速搭建LAMP环境。
CentOS 7 和 CentOS 6 有一些东西还是有其别的,当运行出错了,就去百度一些对应的CentOS版本下的某些安装吧。
我这里是用CentOS 7 安装的。
//关闭防火墙
// CentOS6
service iptables stop
// CentOS7
systemctl stop firewalld
//安装apache
yum install httpd
//配置自启动
chkconfig --levels 235 httpd on
//启动apache,启动失败就吧ServerName的注释去掉在启动
service httpd start
//修改开启默认的端口号,先搜索一下httpd.conf再用vim打开它
[root@VM_0_6_centos etc]# find / -name httpd.conf
[root@VM_0_6_centos etc]# vim /etc/httpd/conf/httpd.conf
//搜索ServerName的位置 找到#ServerName www.example.com:80
底部命令搜索:/ServerName
搜索到后修改成:ServerName localhost:80
//重新启动apache
service httpd restart
//安装mysql CentOS7
yum install -y mariadb-server
// 2.启动maria DB服务:
systemctl start mariadb.service
// 3.将mariadb服务添加至开机自启动
systemctl enable mariadb.service
//重启MySQL
systemctl restart mariadb.service
//停止Mysql
systemctl stop mariadb.service #停止MariaDB
//修改mysql密码
use MySQL;
update user set password=password('123456') where user='root';
flush privileges;exit;
//登录不成功就重启一下mysql
//安装PHP 7.2.27 CentOS7
yum install epel-release -y
rpm -Uvh https://mirror.webtatic.com/yum/el7/webtatic-release.rpm
//安装扩展包 你可以选着性安装
yum -y install php72w php72w-cli php72w-fpm php72w-common php72w-devel php72w-embedded php72w-gd php72w-mbstring php72w-mysqlnd php72w-opcache php72w-pdo php72w-xml
//安装完成以后,启动服务
systemctl enable php-fpm.service
systemctl start php-fpm.service
//重新启动apache
apache service httpd restart
//重启mysql
systemctl restart mariadb.service