系统 :腾讯云CentOS7。
1.首先将系统软件包更新到最新版本。
# yum -y update
2.安装Apache HTTP server
# yum -y install httpd
3.开启httpd服务,设置开机自启动,查看httpd服务状态
# systemctl start httpd
# systemctlenablehttpd
# systemctl status httpd

3.测试是否安装成功
我的演示系统需要通过外网ip去访问,如果是在本地安装只需要在url地址栏中输入127.0.0.1或者localhost

我们从MySQL Yum 仓库http://dev.mysql.com/downloads/repo/yum/下载适合电脑版本的rpm包。
1.查看系统版本
# uname -a

我们需要安装和该系统匹配的MySQL版本,演示系统为el7,所以选择MySQL版本是第一个。

2.下载并执行
# wget https://dev.mysql.com/get/mysql57-community-release-el7-11.noarch.rpm
# rpm -Uvh mysql57-community-release-el7-11.noarch.rpm

# yum -y install mysql-community-server
# service mysqld start

或者
# systemctl start mysqld

查看MySQL服务状态
# service mysqld status

或者
# systemctl status mysqld.service

设置开机启动
# systemctl enable mysqld
# systemctl daemon-reload

在MySQL的安装过程中完成了一下一些事情:
安装了mysql服务
生成SSL证书文件并存放在data目录
安装有效性密码验证插件并启用
本地超级用户root被创建,root用户的密码在日志文件中,使用下面的命令查看密码
# grep 'temporary password' /var/log/mysqld.log

连接MySQL

mysql> alter user 'root'@'localhost' identified by 'Your New Password';
或者
mysql> set password for 'root'@'localhost'=password('Your New Password');
PS: MySQL5.7默认安装了密码安全检查插件(validate_password),默认密码检查策略要求密码必须包含:大小写字母、数字和特殊符号,并且长度不能少于8位。否则会提示ERROR 1819 (HY000): Your password does not satisfy the current policy requirements错误,如下图所示:

我这边解决方式是采用修改密码策略
在/etc/my.cnf文件添加validate_password_policy配置,指定密码策略。
选择0(LOW),1(MEDIUM),2(STRONG)其中一种,选择2需要提供密码字典文件,validate_password_policy=0。如果不需要密码策略,添加my.cnf文件中添加如下配置禁用即可:validate_password = off

重新启动mysql服务使配置生效:
# systemctl restart mysqld
此时再去修改密码

默认只允许root帐户在本地登录,如果要在其它机器上连接MySQL,必须修改root允许远程连接,或者添加一个允许远程连接的帐户
打开Navicat,输入连接ip,会出现下面错误

解决方法
终端连接MySQL
# grant all privileges on *.* to 'root'@'%' identified by '123';

再次远程连接

修改/etc/my.cnf配置文件,在[mysqld]下添加编码配置,如下所示:
[mysqld]
character_set_server=utf8
init_connect='SET NAMES utf8'

# yum -y install epel-release

# rpm -Uvh http://rpms.famillecollet.com/enterprise/remi-release-7.rpm

# yum --enablerepo=remi-php72 -y install php
# php -v

# yum --enablerepo=remi-php72 -y install php-fpm php-xml php-soap php-xmlrpc php-mbstring php-json php-gd php-mcrypt
# systemctl start php-fpm
# systemctl restart httpd

在/var/www/html目录下创建info.php文件
# vi /var/www/html/info.php
代码块
<?php
phpinfo();
保存退出
在浏览器中输入网址ip/info.php

到这里CentOS下LAMP开发搭建完成。
网友评论