前言
本文主要介绍的是基于centos7进行yum安装lnmp(linux+nginx+php7.1+mysql5.7)的相关教程,文中将一步步介绍的非常详细,下面话不多说了,来一起看看详细的介绍吧。
步骤如下:
yum的安装
yum update
yum安装nginx
安装nginx最新源
yum localinstall http://nginx.org/packages/centos/7/noarch/RPMS/nginx-release-centos-7-0.el7.ngx.noarch.rpmyum repolist enabled | grep "nginx*"
安装nginx
yum -y install nginx
启动nginx
service nginx start
设置nginx服务器开机自启动
systemctl enable nginx.service
检查开机自动是否设置成功
systemctl list-dependencies | grep nginx
浏览器中输入公网ip,检测是否安装成功
http://00.00.00.00/
使用yum安装mysql5.7
安装mysql源
yum -y localinstall http://dev.mysql.com/get/mysql57-community-release-el7-7.noarch.rpmyum repolist enabled | grep "mysql.*-community.*"
安装mysql
yum -y install mysql-community-server install mysql-community-devel
启动mysql
service mysqld start
检查mysql启动是否正常
service mysqld status 或者 ps -ef | grep mysql
设置mysqld服务开机自启动
systemctl enable mysqld.service
检查mysqld开机自启动是否设置成功
systemctl list-dependencies | grep mysqld
mysql5.7以后的争强了安全机制, 所以使用yum安装,启动会系统会自动生成一个随机的密码,修改mysql密码
查看mysql的随机密码
grep 'temporary password' /var/log/mysqld.log
使用查询得到的随机密码在终端登录
mysql -u root -p 更改密码(mysql文档规定,密码必须包括大小写字母数字加特殊符号>8位)ALTER USER 'root'@'localhost' IDENTIFIED BY 'Yourpassword';
退出mysql客户端,用刚才修改的密码登录确保密码修改成功
exit;mysql -u root -p
安装php7.1
安装php源
rpm -Uvh https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm rpm -Uvh https://mirror.webtatic.com/yum/el7/webtatic-release.rpm
检查源是否安装成功
yum repolist enabled | grep "webtatic*"
安装php扩展源
yum -y install php71w php71w-fpmyum -y install php71w-mbstring php71w-common php71w-gd php71w-mcryptyum -y install php71w-mysql php71w-xml php71w-cli php71w-develyum -y install php71w-pecl-memcached php71w-pecl-redis php71w-opcache