一、搭建前的准备
- 更新系统软件yum:
yum update
二、安装nginx
- 安装nginx最新源
yum localinstall http://nginx.org/packages/centos/7/noarch/RPMS/nginx-release-centos-7-0.el7.ngx.noarch.rpm
yum repolist enabled | grep "nginx*"
- 安装nginx:
yum -y install nginx
- 启动nginx:
systemctl start nginx
- 设置nginx服务器开机自启动:
systemctl enable nginx.service
检查开机自动是否设置成功:systemctl list-dependencies | grep nginx
三、安装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
- 启动mysql:
systemctl start mysqld
检查mysql启动是否正常:systemctl status mysqld
或者ps -ef | grep mysql
- 设置mysqld服务开机自启动:
systemctl enable mysqld.service
检查mysqld开机自启动是否设置成功:systemctl list-dependencies | grep mysqld
- 修改MySQL密码(5.7以上)
<1> 查看密码:grep 'temporary password' /var/log/mysqld.log
<2> 登录MySql并修改root密码:
mysql -uroot -p
# 修改validate_password_policy参数的值
set global validate_password_policy=0;
# 修改密码的长度
set global validate_password_length=1;
ALTER USER 'root'@'localhost' IDENTIFIED BY 'new psd';
四、安装php7.2
- 安装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 php72w php72w-fpm php72w-mbstring php72w-common php72w-gd php72w-mcrypt php72w-mysql php72w-xml php72w-cli php72w-devel php72w-pecl-memcached php72w-pecl-redis php72w-opcache php72w-mysqlnd
- 验证php7.2.x和扩展是否安装成功
验证php是否安装成功:php -v
验证对应的扩展是否安装成功:php -m
- 启动php-fpm:
systemctl start php-fpm
检查启动是否成功:systemctl status php-fpm
- 设置开机自启动:
systemctl enable php-fpm.service
- 检查开机自启动是否设置成功
systemctl list-dependencies | grep php-fpm
ps -ef | grep php-fpm
备注:设置网站路径时,nginx一定要有路径下的全部权限
网友评论