Nginx动静分离介绍
-
Nginx的静态处理能力很强,但是动态处理能力不足,因此,在企业中常用动静分离技术;
-
静态页面交给Nginx处理,动态页面交给PHP-FPM模块或Apache处理;
-
在Nginx的配置中,是通过location配置段配合正则匹,配实现静态与动态页面的不同处理方式。
搭建LAMP架构
为方便实验直接用yum安装,不用手工编译安装。用两台虚拟机,分别搭建LAMP架构和Nginx服务。
1.安装Apache服务
[root@localhost ~]# yum install httpd httpd-devel -y
.........//省略安装过程
[root@localhost ~]#
2.开启服务,配置Firewalld防火墙
[root@localhost ~]# systemctl start httpd.service //开启服务
[root@localhost ~]#
[root@localhost ~]# firewall-cmd --permanent --zone=public --add-service=http //放通http服务
success
[root@localhost ~]# firewall-cmd --permanent --zone=public --add-service=https //放通https服务
success
[root@localhost ~]# firewall-cmd --reload //重载防火墙
success
[root@localhost ~]#
3.安装mariadb数据库
MariaDB数据库管理系统是MySQL的一个分支,主要由开源社区在维护,采用GPL授权许可 MariaDB的目的是完全兼容MySQL,包括API和命令行,使之能轻松成为MySQL的代替品。
[root@localhost ~]# yum install mariadb mariadb-server mariadb-libs mariadb-devel -y
...........//省略安装过程
[root@localhost ~]#
4.开启数据库服务
[root@localhost ~]# systemctl start mariadb.service
[root@localhost ~]#
5.进行数据库设置
[root@localhost ~]# mysql_secure_installation //对数据库进行设置
NOTE: RUNNING ALL PARTS OF THIS SCRIPT IS RECOMMENDED FOR ALL MariaDB
SERVERS IN PRODUCTION USE! PLEASE READ EACH STEP CAREFULLY!
In order to log into MariaDB to secure it, we'll need the current
password for the root user. If you've just installed MariaDB, and
you haven't set the root password yet, the password will be blank,
so