CentOS 7.3搭建LAMP
服务器
CentOS Linux release 7.3.1611 (Core) x64
安装
Apache2.4
[root]# yum install httpd
[root]# systemctl enable httpd.service
加入开机启动 [root]# systemctl start httpd
启动Apache [root]# systemctl status httpd
查看状态
PHP7
添加RPM源 [root]# rpm -Uvh https://mirror.webtatic.com/yum/el7/webtatic-release.rpm
[root]# rpm -Uvh https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
安装php以及常用扩展
[root]# yum install php70w php70w-common php70w-fpm php70w-opcache php70w-gd php70w-mysqlnd php70w-mbstring php70w-pecl-redis php70w-pecl-memcached php70w-devel
安装mysql之前先安装
wget
这个工具,命令yum install wget
Mysql 5.7[也可以使用MariaDB]
添加RPM源 [root]# wget http://dev.mysql.com/get/mysql57-community-release-el7-8.noarch.rpm
安装源 -ivh
显示安装进度 [root]# rpm -ivh mysql57-community-release-el7-8.noarch.rpm
安装Mysql [root]# yum install mysql-server
[root]# systemctl start mysqld
.启动mysql服务 [root]# systemctl status mysqld
查看MySQL的启动状态
.开机启动 [root]# systemctl enable mysqld
[root]# systemctl daemon-reload
修改Mysql生成的随机密码 [root]# grep 'temporary password' /var/log/mysqld.log
[root]# mysql -uroot -p
新密码须包含数字、大小写字母和特殊字符,否则通不过安全策略 mysql > ALTER USER 'root'@'localhost' IDENTIFIED BY 'newPassWord!';
配置默认编码
/etc/my.cnf
[mysqld]
character_set_server=utf8
init_connect='SET NAMES utf8'
允许root用户远程连接Mysql mysql > Grant all on *.* to 'root'@'%' identified by 'password' with grant option;
mysql > flush privileges;//一定要刷新
Mysql忘记密码
修改/etc/my.cnf
在[mysqld]
下添加一行 skip-grant-tables
[root]# service mysqld restart
[root]# mysql
mysql> update mysql.user set authentication_string=password('newpassword') where user='root' and Host = 'localhost';
mysql> flush privileges;
为了安全,将/etc/my.cnf的修改恢复,重新启动mysql
设置新密码 mysql>update user set authentication_string=password('password') where user='root';
Mysql5.7密码字段已更改
原来的密码字段password
变更成authentication_string