lnmp搭建详细过程

安装版本简介

  • centos7、php7、mysql5.7、nginx1.14.2


更新yum

yum update

yum安装nginx
安装nginx最新源文件

yum localinstall http://nginx.org/packages/centos/7/noarch/RPMS/nginx-release-centos-7-0.el7.ngx.noarch.rpm

查看nginx源文件

yum repolist enabled | grep "nginx*"

安装nginx

yum -y install nginx

启动nginx

systemctl start nginx.service

设置nginx开启启动

systemctl enable nginx.service

检查nginx是否已经设置为开机启动

systemctl list-dependencies | grep nginx

浏览器上输入公网ip,检查是否安装成功

yum安装mysql5.7
安装mysql源文件

yum -y localinstall http://dev.mysql.com/get/mysql57-community-release-el7-7.noarch.rpm

查看源文件

yum repolist enabled | grep "mysql.*-community.*"

安装mysql

yum -y install mysql-community-server install mysql-community-devel (devel和server参考mysql安装基础点)

启动mysql

systemctl start mysqld

检查mysql启动是否正常

systemclt status mysqld.service

设置mysql服务开启启动

systemctl enable mysqld.service

检查设置开启启动是否成功

systemctl list-dependencies | grep mysqld

mysql5.7以后的争强了安全机制, 所以使用yum安装,启动会系统会自动生成一个随机的密码,修改mysql密码
修改密码要求:mysql文档规定,密码必须包括大小写字母数字加特殊符号>8位
查看mysql随机密码

grep "temporary password" /var/log/mysqld.log

yum安装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-fpm
yum -y install php71w-mbstring php71w-common php71w-gd php71w-mcrypt
yum -y install php71w-mysql php71w-xml php71w-cli php71w-devel
yum -y install php71w-pecl-memcached php71w-pecl-redis php71w-opcache

验证php是否安装成功

php -v

扩展是否安装成功

php -m 

启动php-fpm

systemctl start php-fpm.service

检查启动是否成功

systemctl status php-fpm.service

设置开启自启动

systemctl enable php-fpm.service

检查开机自启动是否设置成功

systemctl list-dependencies | grep php-fpm
ps -ef | grep php-fpm

nginx与php-fpm关联

添加新评论