首先声明下
此安装教程是lamp
转自:https://blog.csdn.net/a203778513/article/details/80890748
linux 系统
Apache 容器
mysql 数据库
php
一、安装Apache
1.安装
yum -y install httpd
2.开启apache服务
systemctl start httpd
3.设置apache服务开机启动
systemctl enable httpd
二、安装mysql
# 下载mysql源安装包
wget http://dev.mysql.com/get/mysql57-community-release-el7-8.noarch.rpm
# 安装mysql源
yum localinstall mysql57-community-release-el7-8.noarch.rpm
#检查mysql源是否安装成功
shell> yum repolist enabled | grep "mysql.*-community.*"
#安装MySQL,会出现下载慢的情况,正常情况,毕竟官网服务器下载的
yum install mysql-community-server
#启动MySQL服务
systemctl start mysqld
#修改root默认密码
mysql安装完成之后,在/var/log/mysqld.log文件中给root生成了一个默认密码。通过下面的方式找到root默认密码,然后登录mysql进行修改:
grep 'temporary password' /var/log/mysqld.log
#上面红圈就是您的默认密码!
#接着输入密码
mysql -uroot -p4!hdcksk.sA/
#修改密码
set password for 'root'@'localhost'=password('123456789sW!');
注意:mysql5.7默认安装了密码安全检查插件(validate_password),
默认密码检查策略要求密码必须包含:大小写字母、数字和特殊符号,
并且长度不能少于8位。否则会提示ERROR 1819 (HY000):
Your password does not satisfy the current policy requirements错误
三、安装PHP
1.安装
yum -y install php
2.重启apache服务
systemctl restart httpd 或者 systemctl restart httpd.service
3.将PHP和MySQL关联起来
yum -y install php-gd php-ldap php-odbcphp-pear php-xml php-xmlrpc php-mbstring php-snmp php-soap curl curl-devel libjpeg*php-imap php-pear php-mcrypt php-bcmath php-mhash libmcrypt php-devel
4.重启apache服务
systemctl restart httpd
5.权限控制
chown apache:apache -R /var/www/html
6.测试是否安装成功
cd /var/www/html
vi info.php #输入下面内容
<?php
phpinfo();
?>