讲师:行癫(庄曜)
公司:北京千锋教育云计算+网络安全教学部
1、准备一台云服务器
2、使用finalshell远程连接云服务器
3、操作之前重装服务器系统
1、安装LNMP架构【N:nginx M:mysql P:php】
安装数据库mysql【www.mysql.com】
下载安装工具
[root@qf-docker ~]# yum -y install wget
下载数据库yum仓库的安装包
[root@qf-docker ~]# wget https://dev.mysql.com/get/mysql80-community-release-el7-3.noarch.rpm
安装数据库的yum仓库
[root@qf-docker ~]# rpm -ivh mysql80-community-release-el7-3.noarch.rpm
修改数据库版本
[root@qf-docker ~]# yum -y install yum-utils
关闭8.0版本
[root@qf-docker ~]# yum-config-manager --disable mysql80-community
开启5.7版本
[root@qf-docker ~]# yum-config-manager --enable mysql57-community
安装数据库
[root@qf-docker ~]# yum -y install mysql mysql-server
安装nginx
[root@qf-docker ~]# yum -y install nginx
安装php
[root@qf-docker ~]# yum -y install php php-fpm php-mysql php-gd php-intl php-mcrypt php-mbstring php-xml php-dom
2、启动三大服务
[root@qf-docker ~]# systemctl start mysqld php-fpm nginx
3、三大服务做开机启动
[root@qf-docker ~]# systemctl enable mysqld php-fpm nginx
4、三大服务部署
数据库部署
[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-Z5nTCJc2-1584067296628)(assets/1582726153865.png)]
查看原始密码:
[root@qf-docker ~]# cat /var/log/mysqld.log | grep password
495168Z 1 [Note] A temporary password is generated for root@localhost: bo%lxfJtU5#p
修改数据库密码:
[root@qf-docker ~]# mysqladmin -u root -p'bo%lxfJtU5#p' password 'QianFeng@123'
登陆数据库,创建名为farm的数据库
[root@qf-docker ~]# mysql -u root -pQianFeng@123
mysql: [Warning] Using a password on the command line interface can be insecure.
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 3
Server version: 5.7.29 MySQL Community Server (GPL)
Copyright (c) 2000, 2020, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql> create database farm;
Query OK, 1 row affected (0.00 sec)
mysql> exit
Bye
nginx部署:
删除旧的配置文件:
[root@qf-docker ~]# rm -rf /etc/nginx/nginx.conf
生成新的配置文件
[root@qf-docker ~]# cp /etc/nginx/nginx.conf.default /etc/nginx/nginx.conf
修改配置文件:
[root@qf-docker ~]# vi /etc/nginx/nginx.conf
php服务部署:
[root@qf-docker ~]# sed -i 's/short_open_tag/c short_open_tag= On' /etc/php.ini
5、重新启动服务
[root@qf-docker ~]# systemctl restart nginx php-fpm
6、产品上线
1.上传
2.解压
[root@qf-docker ~]# yum -y install unzip
[root@qf-docker ~]# unzip farm-ucenter1.5.zip
3.创建网站发布目录
[root@qf-docker ~]# mkdir /farm
4.项目拷贝
[root@qf-docker ~]# cp -r upload/* /farm/
5.设置权限
[root@qf-docker ~]# chmod 777 /farm/* -R
7、数据库导入
[root@qf-docker ~]# mysql -u root -pQianFeng@123 farm < upload/qqfarm.sql
8、浏览器访问