当前位置:首页 > Web开发 > 正文

使其在访问动态请求时交给LAMP架构的Apache服务进行处理

2024-03-31 Web开发

标签:

Nginx+Apache消息疏散部署 为什么需要部署Nginx+Apache消息疏散?

? 之前在讲解基于LNMP架构的Discuz论坛搭建(原文链接:https://blog.51cto.com/14557673/2461480)的时候对消息疏散有所提及,这边简述一下核心原因:

? 按照Nginx处事的特性,其擅优点理静态网站(图片文字视频等文件)访谒资源,而Apache擅长动态措置惩罚惩罚(例如:账号注册的交互)。

? 因此我们可以结合这两个处事特点与优势,部署实现网站处事的消息疏散。

部署Nginx+Apache消息疏散实例

? 尝试环境:两台Centos7虚拟机,一台为LAMP架构,另一台为nginx处事

? 首先我们需要搭建LAMP架构,此次我们使用yum直接进行搭建LAMP,具体法式如下:

在一台虚拟机上安置搭建LAMP架构:

===================LAMP简易版搭建==================
1.安置httpd
yum install -y httpd httpd-devel
systemctl start httpd.service

[[email protected] ~]# ifconfig ens33 ens33: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500 inet 192.168.68.144 netmask 255.255.255.0 broadcast 192.168.68.255 inet6 fe80::7330:498c:44ce:c5f7 prefixlen 64 scopeid 0x20<link> ether 00:0c:29:cc:52:c8 txqueuelen 1000 (Ethernet) RX packets 659954 bytes 964992071 (920.2 MiB) RX errors 0 dropped 0 overruns 0 frame 0 TX packets 339462 bytes 20930426 (19.9 MiB) TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0 [[email protected] ~]# yum install -y httpd httpd-devel [[email protected] ~]# systemctl start httpd.service [[email protected] ~]# netstat -antp | grep httpd tcp6 0 0 :::80 :::* LISTEN 57584/httpd

2.防火墙设置(也可以直接封锁)
firewall-cmd --permanent --zone=public --add-service=http
firewall-cmd --permanent --zone=public --add-service=https
firewall-cmd --reload

[[email protected] ~]# firewall-cmd --permanent --zone=public --add-service=http success [[email protected] ~]# firewall-cmd --permanent --zone=public --add-service=https success [[email protected] ~]# firewall-cmd --reload success

3.安置mariadb 数据库
yum install mariadb mariadb-server mariadb-libs mariadb-devel -y
mariadb 快速简单轻量的快捷数据库

[[email protected] ~]# yum install mariadb mariadb-server mariadb-libs mariadb-devel -y

4.启动处事
systemctl start mariadb

[[email protected] ~]# systemctl start mariadb.service [[email protected] ~]# netstat -antp | grep 3306 tcp 0 0 0.0.0.0:3306 0.0.0.0:* LISTEN 67480/mysqld

5.执行mysql安适配置向导命令
mysql_secure_installation

[[email protected] ~]# 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 you should just press enter here. Enter current password for root (enter for none): //没有暗码。直接回车 OK, successfully used password, moving on... Setting the root password ensures that nobody can log into the MariaDB root user without the proper authorisation. Set root password? [Y/n] y //设置root暗码本身输入 New password: Re-enter new password: Password updated successfully! Reloading privilege tables.. ... Success! By default, a MariaDB installation has an anonymous user, allowing anyone to log into MariaDB without having to have a user account created for them. This is intended only for testing, and to make the installation go a bit smoother. You should remove them before moving into a production environment. Remove anonymous users? [Y/n] n //选择是否移除匿名用户,本身选择 ... skipping. Normally, root should only be allowed to connect from ‘localhost‘. This ensures that someone cannot guess at the root password from the network. Disallow root login remotely? [Y/n] n //是否不允许root长途登录 ... skipping. By default, MariaDB comes with a database named ‘test‘ that anyone can access. This is also intended only for testing, and should be removed before moving into a production environment. Remove test database and access to it? [Y/n] n //是否移除测试数据库 ... skipping. Reloading the privilege tables will ensure that all changes made so far will take effect immediately. Reload privilege tables now? [Y/n] y //重载刷新 ... Success! Cleaning up... All done! If you‘ve completed all of the above steps, your MariaDB installation should now be secure. Thanks for using MariaDB!

6.安置PHP
yum -y install php

[[email protected] ~]# yum -y install php

7.安置PHP与mysql关联包
yum install php-mysql -y

[[email protected] ~]# yum install php-mysql -y

8.安置php插件
yum install -y php-gd php-ldap php-odbc php-pear php-xml php-xmlrpc php-mbstring php-snmp php-soap

[[email protected] ~]# yum install -y php-gd php-ldap php-odbc php-pear php-xml php-xmlrpc php-mbstring php-snmp php-soap

温馨提示: 本文由Jm博客推荐,转载请保留链接: https://www.jmwww.net/file/web/33062.html