云原生(nginx实验(4))

实验简介

1. PHP 源码编译实验

实验背景

PHP 是 Web 开发中常用的脚本语言,源码编译可按需定制功能模块、优化性能,相比系统包管理器安装更灵活。

实验目的

编译安装指定版本(8.3.30)的 PHP,配置 FPM 模式运行,适配 Nginx 的 PHP 解析需求,并配置系统服务和环境变量。

核心操作
  • 下载 PHP 源码包及依赖(如 oniguruma-devel);
  • 安装编译依赖(gcc、libxml2-devel 等);
  • 执行./configure指定安装路径、运行用户、启用 / 禁用模块(如启用 FPM、MySQL、GD 库等);
  • 编译安装后配置php-fpm.confwww.conf,修改监听端口为 0.0.0.0:9000;
  • 配置 systemd 服务管理 php-fpm,添加 PHP 环境变量。
验证方式

通过netstat查看 9000 端口监听状态,php -m查看已加载模块。

2. Nginx 整合 PHP 实验

实验背景

Nginx 本身无法解析 PHP,需通过 FastCGI 协议对接 PHP-FPM 实现 PHP 脚本解析。

实验目的

配置 Nginx 虚拟主机,实现对 PHP 脚本的解析,验证 PHP 页面可正常访问。

核心操作
  • 创建 PHP 网站根目录,编写测试页面(index.php包含phpinfo());
  • 编写 Nginx 虚拟主机配置文件php.conf,定义监听端口、域名、根目录;
  • 配置location ~ \.php$块,通过fastcgi_pass指向 PHP-FPM 的 9000 端口,引入fastcgi.conf
  • 重载 Nginx 配置。
验证方式

访问http://php.timinglee.orghttp://php.timinglee.org/index.php,查看 PHP 信息页面是否正常显示。

3. 利用 Memcache 实现 PHP 缓存加速实验

实验背景

Memcache 是高性能的分布式内存缓存系统,可缓存 PHP 动态页面 / 数据,减少数据库 / 计算开销。

实验目的

部署 Memcache 服务,让 PHP 支持 Memcache 扩展,验证缓存对 PHP 性能的提升。

核心操作
  • 安装 Memcached 服务,配置监听地址、最大连接数、缓存大小等参数;
  • 编译安装 PHP 的 Memcache 扩展,修改php.ini加载扩展并重启 php-fpm;
  • 编写 Memcache 管理页面(memcache.php),放入 PHP 网站根目录;
验证方式
  • netstat查看 Memcache 的 11211 端口监听状态,php -m确认 Memcache 扩展加载;
  • 浏览器访问memcache.php查看缓存状态,通过ab工具压测 PHP 页面,对比缓存前后性能。

4. Nginx+Memcache 实现高速缓存解实验

实验背景

仅 PHP 端使用 Memcache 需修改代码,通过 Nginx 模块(srcache-nginx-module/memc-nginx-module)可直接在 Nginx 层实现缓存,无需修改 PHP 代码。

实验目的

重新编译 Nginx 集成 Memcache 相关模块,在 Nginx 配置中实现 PHP 页面的缓存读取 / 写入,提升访问性能。

核心操作
  • 停止 Nginx,备份配置,重新编译 Nginx 并添加srcache/memc/echo模块;
  • 配置 Nginx 虚拟主机,定义/memc内部 location 对接 Memcache 服务;
  • 在 PHP 解析的location中,通过srcache_fetch(读取缓存)和srcache_store(写入缓存)关联/memc
  • 重载 Nginx 配置。
验证方式

通过ab工具(ab -n 10000 -c500)压测 PHP 页面,验证并发访问性能提升。

5. Nginx 四层负载均衡代理实验

实验背景

Nginx 除了七层 HTTP 负载均衡,还支持四层(TCP/UDP)负载均衡,可代理数据库、DNS 等基于传输层的服务。

实验目的

实现 MySQL(TCP)和 DNS(UDP)服务的四层负载均衡,验证请求可分发到不同后端节点。

核心操作
MySQL(TCP)部分
  • 部署两台 MariaDB 服务器,配置不同server-id,创建通用访问账号;
  • 在 Nginx 配置stream模块,定义upstream包含两台 MySQL 节点,配置server监听 3306 端口并代理到上游;
DNS(UDP)部分
  • 部署两台 BIND DNS 服务器,配置不同解析记录(同一域名指向不同 IP);
  • 在 Nginx 的stream配置中新增 UDP 上游和监听,配置proxy_responses等 UDP 相关参数;
  • 重载 Nginx 配置。
验证方式
  • 访问 Nginx 的 3306 端口,通过SELECT @@server_id验证 MySQL 请求分发到不同节点;
  • 通过dig命令访问 Nginx 的 53 端口,验证 DNS 解析结果交替指向不同后端 IP。

6. 编译安装 OpenResty 实验

实验背景

OpenResty 是基于 Nginx 的扩展平台,集成了 Lua 等模块,可实现更灵活的 Web 功能。

实验目的

编译安装 OpenResty,配置环境变量,验证基础访问功能。

核心操作
  • 下载 OpenResty 源码包,安装编译依赖(gcc、pcre-devel 等);
  • 创建 nginx 系统用户,执行./configure指定安装路径、用户、启用模块(SSL、stream 等);
  • 编译安装后配置环境变量,将 OpenResty 的 bin 目录加入 PATH;
  • 启动 OpenResty,编写测试首页并通过 curl 访问。
验证方式

openresty -v查看版本,ps -ef | grep nginx确认进程,curl访问服务器 IP 查看测试内容。

PHP的源码编译

下载源码包

复制代码
[root@Nginx ~]# wget https://www.php.net/distributions/php-8.3.30.tar.gz
[root@Nginx ~]# wget https://mirrors.aliyun.com/rockylinux/9.7/devel/x86_64/os/Packages/o/oniguruma-devel-6.9.6-1.el9.6.x86_64.rpm

解压

复制代码
[root@nginx ~]# tar zxf php-8.3.30.tar.gz
[root@nginx ~]# ls
anaconda-ks.cfg                nginx-1.28.1                              php-8.3.30
echo-nginx-module-0.64         nginx-1.28.1.tar.gz                       php-8.3.30.tar.gz
echo-nginx-module-0.64.tar.gz  oniguruma-devel-6.9.6-1.el9.6.x86_64.rpm
[root@nginx ~]# cd php-8.3.30

源码编译

复制代码
[root@nginx ~]# dnf install gcc systemd-devel-252-51.el9.x86_64 libxml2-devel.x86_64 sqlite-devel.x86_64  libcurl-devel.x86_64  libpng-devel.x86_64 oniguruma-devel-6.9.6-1.el9.6.x86_64.rpm -y
[root@nginx ~]# cd php-8.3.30/
[root@Nginx php-8.3.30]# ./configure \
--prefix=/usr/local/php \
--with-config-file-path=/usr/local/php/etc \
--enable-fpm \
--with-fpm-user=nginx \
--with-fpm-group=nginx \
--with-curl \
--with-iconv \
--with-mhash \
--with-zlib \
--with-openssl \
--enable-mysqlnd \
--with-mysqli \
--with-pdo-mysql \
--disable-debug \
--enable-sockets \
--enable-soap \
--enable-xml \
--enable-ftp \
--enable-gd \
--enable-exif \
--enable-mbstring \
--enable-bcmath \
--with-fpm-systemd
[root@nginx php-8.3.30]# make && make instsall

配置PHP

复制代码
[root@nginx php-8.3.30]# cd /usr/local/php/etc
[root@nginx etc]# cp -p php-fpm.conf.default  php-fpm.conf
[root@nginx etc]# vim php-fpm.conf
[global]
; Pid file
; Note: the default prefix is /usr/local/php/var
; Default Value: none
pid = run/php-fpm.pid
[root@nginx etc]# cd php-fpm.d/
[root@nginx php-fpm.d]# cp www.conf.default www.conf
[root@nginx php-fpm.d]# vim www.conf
41 listen = 0.0.0.0:9000
[root@nginx php-fpm.d]# cp /root/php-8.3.30/php.ini-production  /usr/local/php/etc/php.ini
[root@nginx php-fpm.d]# vim /usr/local/php/etc/php.ini
989 date.timezone = Asia/Shangha
[root@nginx ~]# cp /root/php-8.3.30/sapi/fpm/php-fpm.service /lib/systemd/system/
[root@nginx ~]# vim /lib/systemd/system/php-fpm.service
# Mounts the /usr, /boot, and /etc directories read-only for processes invoked by this unit.
#ProtectSystem=full		#注释此参数
[root@nginx ~]# systemctl daemon-reload
[root@nginx ~]# systemctl enable --now php-fpm
[root@nginx ~]# netstat -antlupe | grep php
tcp        0      0 0.0.0.0:9000            0.0.0.0:*               LISTEN      0          329917     165562/php-fpm: mas

为php设定环境变量

复制代码
[root@nginx ~]# vim ~/.bash_profile
export PATH=$PATH:/usr/local/nginx/sbin:/usr/local/php/sbin:/usr/local/php/bin
[root@nginx ~]# source   ~/.bash_profile
[root@nginx ~]# php -m

Nginx整合PHP

复制代码
[root@nginx conf.d]# mkdir  /webdir/timinglee.org/php/html -p
[root@nginx conf.d]# vim /webdir/timinglee.org/php/html/index.html
php.timinglee.org
[root@nginx conf.d]# vim /webdir/timinglee.org/php/html/index.php
<?php
  phpinfo();
?>
[root@nginx ~]# cd /usr/local/nginx/conf/conf.d/
[root@nginx conf.d]# vim php.conf
server {
  listen 80;
  server_name php.timinglee.org;
  root /webdir/timinglee.org/php/html;
  location ~ \.php$ {
    fastcgi_pass 127.0.0.1:9000;
    fastcgi_index index.php;
    include fastcgi.conf;
  }
}
[root@nginx conf.d]# nginx -s reload
#测试
http://php.timinglee.org
http://php.timinglee.org/index.php

利用memcache实现php的缓存加速

安装memcache

复制代码
[root@nginx ~]# dnf install memcached.x86_64 -y

配置memcache

复制代码
[root@nginx ~]# vim /etc/sysconfig/memcached
PORT="11211"
USER="memcached"
MAXCONN="1024"
CACHESIZE="64"
OPTIONS="-l 0.0.0.0,::1"
[root@nginx ~]# systemctl enable --now memcached.service
[root@nginx ~]# netstat -antlupe | grep memcache
tcp        0      0 0.0.0.0:11211           0.0.0.0:*               LISTEN      991        437305     166169/memcached
tcp6       0      0 ::1:11211               :::*                    LISTEN      991        437306     166169/memcached

升级php对于memcache的支持

复制代码
[root@nginx ~]# php -m	#查看php支持的插件
[root@nginx ~]# tar zxf memcache-8.2.tgz
[root@nginx ~]# cd memcache-8.2/
[root@nginx memcache-8.2]# dnf install autoconf -y
[root@nginx memcache-8.2]# phpize
[root@nginx memcache-8.2]# ./configure  && make && make install
[root@nginx memcache-8.2]# ls /usr/local/php/lib/php/extensions/no-debug-non-zts-20230831/
memcache.so  opcache.so
[root@nginx memcache-8.2]# vim /usr/local/php/etc/php.ini
939  extension=memcache
[root@nginx memcache-8.2]# systemctl restart php-fpm.service
[root@nginx memcache-8.2]# php -m  | grep memcache
memcache

测试性能

复制代码
[root@nginx memcache-8.2]# vim memcache.php
define('ADMIN_USERNAME','admin');   // Admin Username
define('ADMIN_PASSWORD','lee');     // Admin Password
$MEMCACHE_SERVERS[] = '172.25.254.100:11211'; // add more as an array
#$MEMCACHE_SERVERS[] = 'mymemcache-server2:11211'; // add more as an array
[root@nginx memcache-8.2]# cp -p memcache.php  /webdir/timinglee.org/php/html/
[root@ginx memcache-8.2]# cp -p example.php /webdir/timinglee.org/php/html/

#测试
http://php.timinglee.org/memcache.php			#数据页面,在浏览器中可以直接访问
[root@nginx memcache-8.2]# ab -n 1000 -c 300  php.timinglee.org/example.php

nginx+memcache实现高速缓存解

重新编译nginx

复制代码
[root@nginx ~]# systemctl stop nginx.service
[root@nginx ~]# cp /usr/local/nginx/conf/    /mnt/ -r
[root@nginx ~]# rm -fr /usr/local/nginx/
[root@nginx ~]# rm -rf nginx-1.29.4 nginx-1.28.1
[root@nginx ~]# tar zxf nginx-1.28.1.tar.gz
[root@nginx ~]# cd nginx-1.28.1/
[root@nginx ~]# tar zxf srcache-nginx-module-0.33.tar.gz
[root@nginx ~]# tar zxf memc-nginx-module-0.20.tar.gz
[root@nginx ~]# cd nginx-1.28.1/
[root@nginx nginx-1.28.1]# ./configure  --prefix=/usr/local/nginx --user=nginx --group=nginx --with-http_ssl_module --with-http_v2_module --with-http_realip_module --with-http_stub_status_module --with-http_gzip_static_module --with-pcre --with-stream --with-stream_ssl_module --with-stream_realip_module --add-module=/root/echo-nginx-module-0.64  --add-module=/root/memc-nginx-module-0.20 --add-module=/root/srcache-nginx-module-0.33
[root@nginx nginx-1.28.1]# make && make install
[root@nginx ~]# cd /usr/local/nginx/conf
[root@nginx conf]# rm -fr nginx.conf
[root@nginx conf]# cp /mnt/conf/nginx.conf /mnt/conf/conf.d/ . -r
[root@nginx conf]# systemctl start nginx.service

整合memcache

复制代码
[root@nginx conf]# vim /usr/local/nginx/conf/conf.d/php.conf
upstream memcache {
   server 127.0.0.1:11211;
   keepalive 512;
}
server {
    listen 80;
    server_name php.timinglee.org;
    root /webdir/timinglee.org/php/html;
    index index.php index.html;

    location /memc {
        internal;
        memc_connect_timeout 100ms;
        memc_send_timeout 100ms;
        memc_read_timeout 100ms;
        set $memc_key $query_string;
        set $memc_exptime 300;
        memc_pass memcache;
    }
    location ~ \.php$ {
        set $key $uri$args;
        srcache_fetch GET /memc $key;
        srcache_store PUT /memc $key;
        fastcgi_pass 127.0.0.1:9000;
        fastcgi_index index.php;
        include fastcgi.conf;
  }
}
[root@nginx conf]# nginx  -s reload

#测试
[root@nginx conf]# ab -n 10000 -c500 http://php.timinglee.org/example.php

Nginx的四层负载均衡代理

实验环境(Mysql)

复制代码
[root@RS1 ~]# dnf install mariadb-server -y
[root@RS2 ~]#  dnf install mariadb-server -y
[root@RS1 ~]# vim /etc/my.cnf.d/mariadb-server.cnf
server-id=10
[root@RS2 ~]# vim /etc/my.cnf.d/mariadb-server.cnf
server-id=20
[root@RS1 ~]# systemctl enable --now mariadb
[root@RS2 ~]# systemctl enable --now mariadb
[root@RS1 ~]# mysql
Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MariaDB connection id is 3
Server version: 10.5.27-MariaDB MariaDB Server

Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

MariaDB [(none)]> CREATE USER lee@'%' IDENTIFIED BY 'lee';
Query OK, 0 rows affected (0.001 sec)

MariaDB [(none)]> GRANT ALL ON *.* TO lee@'%';
Query OK, 0 rows affected (0.001 sec)

MariaDB [(none)]>qiut
[root@RS2 ~]# mysql
Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MariaDB connection id is 3
Server version: 10.5.27-MariaDB MariaDB Server

Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

MariaDB [(none)]>  CREATE USER lee@'%' IDENTIFIED BY 'lee';
Query OK, 0 rows affected (0.001 sec)

MariaDB [(none)]> GRANT ALL ON *.* TO lee@'%';
Query OK, 0 rows affected (0.001 sec)

实验环境(dns)

复制代码
[root@RS1 ~]# dnf install bind -y
[root@RS2 ~]# dnf install bind -y
[root@RS1 ~]# vim /etc/named.conf
[root@RS2 ~]# vim /etc/named.conf
options {
//      listen-on port 53 { 127.0.0.1; };
//      listen-on-v6 port 53 { ::1; };
        directory       "/var/named";
        dump-file       "/var/named/data/cache_dump.db";
        statistics-file "/var/named/data/named_stats.txt";
        memstatistics-file "/var/named/data/named_mem_stats.txt";
        secroots-file   "/var/named/data/named.secroots";
        recursing-file  "/var/named/data/named.recursing";
//      allow-query     { localhost; };
        dnssec-validation no;

[root@RS1 ~]# vim /etc/named.rfc1912.zones
[root@RS2 ~]# vim /etc/named.rfc1912.zones

zone "timinglee.org" IN {
        type master;
        file "timinglee.org.zone";
        allow-update { none; };
};
[root@RS1 ~]# cd /var/named/
[root@RS2 ~]# cd /var/named/
[root@RS1 named]# cp -p named.localhost  timinglee.org.zone
[root@RS2 named]# cp -p named.localhost  timinglee.org.zone
[root@RS1 named]# vim timinglee.org.zone
$TTL 1D
@       IN SOA  dns.timingle.org. rname.invalid. (
                                        0       ; serial
                                        1D      ; refresh
                                        1H      ; retry
                                        1W      ; expire
                                        3H )    ; minimum
        NS      dns.timinglee.org.
dns     A       172.25.254.10

[root@RS2 named]# vim timinglee.org.zone
$TTL 1D
@       IN SOA  dns.timingle.org. rname.invalid. (
                                        0       ; serial
                                        1D      ; refresh
                                        1H      ; retry
                                        1W      ; expire
                                        3H )    ; minimum
        NS      dns.timinglee.org.
dns     A       172.25.254.20
[root@RS2 named]# systemctl enable --now named

#测试
[root@RS1 named]# dig dns.timinglee.org @172.25.254.10
; <<>> DiG 9.16.23-RH <<>> dns.timinglee.org @172.25.254.10
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 24486
;; flags: qr aa rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 0, ADDITIONAL: 1

;; OPT PSEUDOSECTION:
; EDNS: version: 0, flags:; udp: 1232
; COOKIE: 4bb88849cac36aa4010000006982fef4676bf81574ab80b7 (good)
;; QUESTION SECTION:
;dns.timinglee.org.             IN      A

;; ANSWER SECTION:
dns.timinglee.org.      86400   IN      A       172.25.254.10

;; Query time: 3 msec
;; SERVER: 172.25.254.10#53(172.25.254.10)
;; WHEN: Wed Feb 04 16:10:28 CST 2026
;; MSG SIZE  rcvd: 90

[root@RS1 named]# dig dns.timinglee.org @172.25.254.20

; <<>> DiG 9.16.23-RH <<>> dns.timinglee.org @172.25.254.20
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 42456
;; flags: qr aa rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 0, ADDITIONAL: 1

;; OPT PSEUDOSECTION:
; EDNS: version: 0, flags:; udp: 1232
; COOKIE: 7c088d4822b8f1c1010000006982fef9047f3812bdaf7c0e (good)
;; QUESTION SECTION:
;dns.timinglee.org.             IN      A

;; ANSWER SECTION:
dns.timinglee.org.      86400   IN      A       172.25.254.20

;; Query time: 1 msec
;; SERVER: 172.25.254.20#53(172.25.254.20)
;; WHEN: Wed Feb 04 16:10:33 CST 2026
;; MSG SIZE  rcvd: 90

tcp四层负载

复制代码
[root@nginx conf]# mkdir  /usr/local/nginx/conf/tcp -p
[root@nginx conf]# mkdir  /usr/local/nginx/conf/udp -p
[root@nginx conf]# vim /usr/local/nginx/conf/nginx.conf
include "/usr/local/nginx/conf/tcp/*.conf";
[root@nginx conf]# vim /usr/local/nginx/conf/tcp/mariadb.conf
stream {
  upstream mysql_server {
    server 172.25.254.10:3306  max_fails=3 fail_timeout=30s;
    server 172.25.254.20:3306  max_fails=3 fail_timeout=30s;
  }

  server {
    listen 172.25.254.100:3306;
    proxy_pass mysql_server;
    proxy_connect_timeout 30s;
    proxy_timeout 300s;
  }

}
[root@Nginx conf]# nginx  -s reload

#检测
[root@nginx ~]# mysql -ulee -plee -h172.25.254.100
Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MariaDB connection id is 4
Server version: 10.5.27-MariaDB MariaDB Server

Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

MariaDB [(none)]> SELECT @@server_id;
+-------------+
| @@server_id |
+-------------+
|          10 |
+-------------+
1 row in set (0.001 sec)

MariaDB [(none)]> quit
Bye
[root@nginx ~]# mysql -ulee -plee -h172.25.254.100
Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MariaDB connection id is 4
Server version: 10.5.27-MariaDB MariaDB Server

Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

MariaDB [(none)]> SELECT @@server_id;
+-------------+
| @@server_id |
+-------------+
|          20 |
+-------------+
1 row in set (0.001 sec)

udp四层负载

复制代码
[root@nginx ~]# vim /usr/local/nginx/conf/tcp/mariadb.conf
stream {
  upstream mysql_server {
    server 172.25.254.10:3306  max_fails=3 fail_timeout=30s;
    server 172.25.254.20:3306  max_fails=3 fail_timeout=30s;
  }

  upstream dns_server{
    server 172.25.254.10:53 max_fails=3 fail_timeout=30s;
    server 172.25.254.20:53 max_fails=3 fail_timeout=30s;
  }

  server {
    listen 172.25.254.100:3306;
    proxy_pass mysql_server;
    proxy_connect_timeout 30s;
    proxy_timeout 300s;
  }

  server {
        listen 172.25.254.100:53 udp;
        proxy_pass dns_server;
        proxy_timeout 1s;
        proxy_responses 1;
        error_log logs/dns.log;
    }
}
[root@nginx ~]# nginx  -s reload

#测试
[root@nginx ~]# dig dns.timinglee.org @172.25.254.100

; <<>> DiG 9.16.23-RH <<>> dns.timinglee.org @172.25.254.100
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 32224
;; flags: qr aa rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 0, ADDITIONAL: 1

;; OPT PSEUDOSECTION:
; EDNS: version: 0, flags:; udp: 1232
; COOKIE: 9ac742ccc566d4450100000069830452db8dce1f1b224c9f (good)
;; QUESTION SECTION:
;dns.timinglee.org.             IN      A

;; ANSWER SECTION:
dns.timinglee.org.      86400   IN      A       172.25.254.10

;; Query time: 2 msec
;; SERVER: 172.25.254.100#53(172.25.254.100)
;; WHEN: Wed Feb 04 16:33:22 CST 2026
;; MSG SIZE  rcvd: 90

[root@Nginx ~]# dig dns.timinglee.org @172.25.254.100

; <<>> DiG 9.16.23-RH <<>> dns.timinglee.org @172.25.254.100
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 2259
;; flags: qr aa rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 0, ADDITIONAL: 1

;; OPT PSEUDOSECTION:
; EDNS: version: 0, flags:; udp: 1232
; COOKIE: 7f9ffa4884c0b685010000006983045565fd892fc72c5514 (good)
;; QUESTION SECTION:
;dns.timinglee.org.             IN      A

;; ANSWER SECTION:
dns.timinglee.org.      86400   IN      A       172.25.254.20

;; Query time: 2 msec
;; SERVER: 172.25.254.100#53(172.25.254.100)
;; WHEN: Wed Feb 04 16:33:25 CST 2026
;; MSG SIZE  rcvd: 90

编译安装 openresty

复制代码
[root@nginx src]#wget https://openresty.org/download/openresty-1.27.1.2.tar.gz
[root@nginx ~]#dnf -yq install gcc pcre-devel openssl-devel perl zlib-devel
[root@nginx ~]#useradd -r -s /sbin/nologin nginx
[root@nginx ~]#tar zxf openresty-1.27.1.2
[root@webserver ~]# cd openresty-1.27.1.2/
[root@nginx openresty-1.17.8.2]#./configure \
--prefix=/apps/openresty \
--user=nginx --group=nginx \
--with-http_ssl_module \
--with-http_v2_module \
--with-http_stub_status_module \
--with-http_gzip_static_module 
--with-pcre --with-stream \
--with-stream_ssl_module \
--with-stream_realip_module
[root@nginx openresty-1.17.8.2]#gmake && gmake install
[root@webserver openresty]# vim ~/.bash_profile
export PATH=$PATH:/usr/local/openresty/bin
[root@webserver openresty]# source  ~/.bash_profile
[root@nginx openresty-1.17.8.2]#openresty -v
nginx version: openresty/1.17.8.2
[root@nginx openresty-1.17.8.2]#openresty 
[root@nginx openresty-1.17.8.2]#ps -ef |grep nginx
[root@webserver openresty]# echo hello test > /usr/local/openresty/nginx/html/index.html
[root@webserver openresty]# curl  172.25.254.200
hello test
相关推荐
Avan_菜菜16 小时前
FRP 内网穿透完整实战:从 HTTP 映射到 HTTPS 自签代理
运维·nginx·https
阿里云云原生1 天前
告别冗长链路!Kafka × Table Bucket 实现开放表格式零 ETL 实时入湖
云原生·kafka
SelectDB2 天前
Litefuse 开源并推出单进程轻量模式,25 秒就能跑起来的 Agent 可观测与评估平台
运维·后端·自动化运维
SelectDB2 天前
秒级弹性、最高降本 70%:SelectDB Serverless 如何重塑云数仓资源效率
大数据·后端·云原生
XIAOHEZIcode3 天前
Linux系统鼠标偏移常见原因以及修复方案
linux·运维·游戏
用户0328472220704 天前
如何搭建本地yum源(上)
运维
秋播4 天前
国内本地WSL2编译rancher源码
云原生
ping某5 天前
为什么 Nginx 明明监听了 80,转发后端时却用了 4xxxx 端口?
后端·nginx
小猿姐6 天前
MySQL Top 10 热点问题 AI 运维实战:从内核诊断到云原生运维
mysql·云原生·aiops
阿里云云原生7 天前
深入内核:拆解 OpenTelemetry eBPF 探针如何优雅地“透视”多语言微服务?
云原生