我是靠谱客的博主 懦弱鲜花,最近开发中收集的这篇文章主要介绍LNMT集群架构发布Jforum论坛一、实验服务器分配二、安装实验必备服务三、安装 Jforum 论坛四、使用 Nginx 进行动静分离与负载均衡,觉得挺不错的,现在分享给大家,希望可以做个参考。

概述

一、实验服务器分配

1、192.168.1.112 Nginx WEB+NFS
2、192.168.1.117 MYSQL主库+Tomcat
3、192.168.1.118 MYSQL从库+Tomcat

二、安装实验必备服务

1、源码安装Nginx WEB前端[192.168.1.112]

①、关闭防火墙并下载Nginx源码包

[root@localhost ~]# systemctl stop firewalld
[root@localhost ~]# wget -c http://nginx.org/download/nginx-1.14.0.tar.gz

②、安装PCRE库和基础库支持

[root@localhost ~]# yum install pcre-devel pcre gcc-c++ openssl openssl-devel zlib-devel -y

③、解压nginx-1.14.0源码包,并创建服务用户

[root@localhost ~]# tar -xzf nginx-1.14.0.tar.gz 
[root@localhost ~]# useradd -s /sbin/nologin nginx -M

④、进入nginx-1.14.0,进行预编译

[root@localhost ~]# cd nginx-1.14.0/
[root@localhost nginx-1.14.0]# ./configure --prefix=/data/nginx --with-http_stub_status_module --with-http_ssl_module

⑤、编译与编译安装

[root@localhost nginx-1.14.0]# make && make install

⑥、检查nginx配置文件是否正确

[root@localhost nginx-1.14.0]# /data/nginx/sbin/nginx -t
nginx: the configuration file /data/nginx/conf/nginx.conf syntax is ok
nginx: configuration file /data/nginx/conf/nginx.conf test is successful

2、YUM安装NFS文件共享服务[192.168.1.112]

①、YUM安装NFS文件共享服务

[root@localhost ~]# yum install nfs-utils rpcbind -y

②、创建共享文件目录(也可以直接使用软件包进行改名)

[root@localhost ~]# mkdir -p /data/Jforum
[root@localhost ~]# mkdir -p /data/Jforum_1

③、修改配置文件

[root@localhost ~]# vim /etc/exports

添加如下命令,并保存

/data/Jforum *(rw,no_root_squash,no_all_squash,sync)
/data/Jforum_1 *(rw,no_root_squash,no_all_squash,sync)

④、启动NFS服务

[root@localhost ~]# systemctl start nfs
[root@localhost ~]# systemctl status nfs   #查看运行状态

⑤、热加载配置文件

[root@localhost ~]# exportfs -r

3、源码安装MySQL数据库[192.168.1.117/192.168.1.118]

①、关闭防火墙

[root@localhost ~]# systemctl stop firewalld

②、安装编译需要的依赖

[root@localhost ~]# yum install cmake ncurses-devel ncurses libaio bison git gcc-c++ -y

③、下载MySQL-5.5.20源码包

[root@localhost ~]# wget -c http://down1.chinaunix.net/distfiles/mysql-5.5.20.tar.gz

④、解压MySQL-5.5.20源码包,并进行预编译

[root@localhost ~]# tar -xzf mysql-5.5.20.tar.gz
[root@localhost ~]# cd mysql-5.5.20
[root@localhost mysql-5.5.20]# cmake . -DCMAKE_INSTALL_PREFIX=/usr/local/mysql55  -DMYSQL_UNIX_ADDR=/tmp/mysql.sock  -DMYSQL_DATADIR=/data/mysql  -DSYSCONFDIR=/etc  -DMYSQL_USER=mysql  -DMYSQL_TCP_PORT=3306  -DWITH_XTRADB_STORAGE_ENGINE=1  -DWITH_INNOBASE_STORAGE_ENGINE=1  -DWITH_PARTITION_STORAGE_ENGINE=1  -DWITH_BLACKHOLE_STORAGE_ENGINE=1  -DWITH_MYISAM_STORAGE_ENGINE=1  -DWITH_READLINE=1  -DENABLED_LOCAL_INFILE=1  -DWITH_EXTRA_CHARSETS=1  -DDEFAULT_CHARSET=utf8  -DDEFAULT_COLLATION=utf8_general_ci  -DEXTRA_CHARSETS=all  -DWITH_BIG_TABLES=1  -DWITH_DEBUG=0  -DENABLE_DTRACE=0

⑤、编辑MySQL文件权限与配置文件,并启动

[root@localhost mysql-5.5.20]# cd /usr/local/mysql55
[root@localhost mysql55]# cp -f support-files/my-large.cnf /etc/my.cnf
[root@localhost mysql55]# cp -f support-files/mysql.server /etc/init.d/mysqld
[root@localhost mysql55]# chkconfig --add mysqld
[root@localhost mysql55]# chkconfig --level 35 mysqld on
[root@localhost mysql55]# mkdir -p /data/mysql
[root@localhost mysql55]# useradd -s /sbin/nologin mysql
[root@localhost mysql55]# /usr/local/mysql55/scripts/mysql_install_db --user=mysql --datadir=/data/mysql/ --basedir=/usr/local/mysql55/
[root@localhost mysql55]# ln -s /usr/local/mysql55/bin/* /usr/bin/
[root@localhost mysql55]# service mysqld start

4、建立主从同步[192.168.1.117主]

①、配置两台 MySQL 数据库服务器配置文件 vim /etc/my.cnf

1️⃣192.168.1.117 主数据库
[client]
port		= 3306
socket		= /tmp/mysql.sock

[mysqld]
port		= 3306
socket		= /tmp/mysql.sock
skip-external-locking
key_buffer_size = 256M
max_allowed_packet = 1M
table_open_cache = 256
sort_buffer_size = 1M
read_buffer_size = 1M
read_rnd_buffer_size = 4M
myisam_sort_buffer_size = 64M
thread_cache_size = 8
query_cache_size= 16M
thread_concurrency = 8
log-bin=mysql-bin
binlog_format=mixed
server-id	= 1   #修改这里


[mysqldump]
quick
max_allowed_packet = 16M

[mysql]
no-auto-rehash

[myisamchk]
key_buffer_size = 128M
sort_buffer_size = 128M
read_buffer = 2M
write_buffer = 2M

[mysqlhotcopy]
interactive-timeout
2️⃣192.168.1.118 主数据库
[client]
port		= 3306
socket		= /tmp/mysql.sock

[mysqld]
port		= 3306
socket		= /tmp/mysql.sock
skip-external-locking
key_buffer_size = 256M
max_allowed_packet = 1M
table_open_cache = 256
sort_buffer_size = 1M
read_buffer_size = 1M
read_rnd_buffer_size = 4M
myisam_sort_buffer_size = 64M
thread_cache_size = 8
query_cache_size= 16M
thread_concurrency = 8
log-bin=mysql-bin
binlog_format=mixed
server-id	= 2   #修改这里

[mysqldump]
quick
max_allowed_packet = 16M

[mysql]
no-auto-rehash

[myisamchk]
key_buffer_size = 128M
sort_buffer_size = 128M
read_buffer = 2M
write_buffer = 2M

[mysqlhotcopy]
interactive-timeout

②、重启 MySQL 数据库

[root@localhost ~]# systemctl restart mysql

③、创建主数据库连接账户

[root@localhost ~]# mysql   #进入数据库
mysql> grant replication slave on *.* to 'tongbu'@'192.168.1.118' identified by '123456';

④、查看 bin-log 文件

mysql> show master status;
+------------------+----------+--------------+------------------+
| File             | Position | Binlog_Do_DB | Binlog_Ignore_DB |
+------------------+----------+--------------+------------------+
| mysql-bin.000001 |      396 |              |                  |
+------------------+----------+--------------+------------------+
1 row in set (0.00 sec)

⑤、连接主数据库

mysql> change master to master_host='192.168.1.117',master_user='tongbu',master_password='123456',master_log_file='mysql-bin.000001',master_log_pos=396;
Query OK, 0 rows affected (0.27 sec)

⑥、启动同步,查看主从集群是否创建完成

mysql> slave start;
Query OK, 0 rows affected (0.00 sec)

mysql> show slave status G
Slave_IO_Running: Yes
Slave_SQL_Running: Yes

当前如果 Slave_IO_Running 进程和 Slave_SQL_Running 进程都是yes,就代表主从同步建立完成。

5、建立主从同步[192.168.1.118主]

①、在从数据库创建连接账户

mysql> grant replication slave on *.* to 'tongbu'@'192.168.1.117' identified by '123456789';

②、查看从数据库bin-log文件

mysql> show master status;
+------------------+----------+--------------+------------------+
| File             | Position | Binlog_Do_DB | Binlog_Ignore_DB |
+------------------+----------+--------------+------------------+
| mysql-bin.000008 |      404 |              |                  |
+------------------+----------+--------------+------------------+

③、进入主数据库连接从数据库

mysql> change master to master_host='192.168.1.118',master_user='tongbu',master_password='123456789',master_log_file='mysql-bin.000008',master_log_pos=404;

④、启动同步,查看主从集群是否创建完成

mysql> slave start;
Query OK, 0 rows affected (0.00 sec)

mysql> show slave status G
Slave_IO_Running: Yes
Slave_SQL_Running: Yes

6、安装Apache Tomcat[192.168.1.117/192.168.1.118]

①、上传JDK与Apache Tomcat服务包

[root@localhost ~]# yum install lrzsz -y   #上传组件
[root@localhost ~]# rz -E   #上传命令
[root@localhost ~]# ls
apache-tomcat-8.5.45.tar.gz  jdk1.8.0_131.tar.gz

②、解压JDK与Apache Tomcat服务包

[root@localhost ~]# tar -xzf jdk1.8.0_131.tar.gz
[root@localhost ~]# tar -xzf apache-tomcat-8.5.45.tar.gz

③、移动JDK与Apache Tomcat服务包至 /usr/local 目录下

[root@localhost ~]# mv jdk1.8.0_131 /usr/local/java
[root@localhost ~]# mv apache-tomcat-8.5.45 /usr/local/tomcat_1

④、添加永久环境变量,不然启动Tomcat会报错

[root@localhost local]# vim /etc/profile

在最低下添加,并保存

export JAVA_HOME=/usr/local/java/

使用如下命令使其马上生效

[root@localhost local]# source /etc/profile

⑤、启动Tomcat

[root@localhost bin]# /usr/local/tomcat_1/bin/startup.sh
Using CATALINA_BASE:   /usr/local/tomcat_1
Using CATALINA_HOME:   /usr/local/tomcat_1
Using CATALINA_TMPDIR: /usr/local/tomcat_1/temp
Using JRE_HOME:        /usr/local/java/
Using CLASSPATH:       /usr/local/tomcat_1/bin/bootstrap.jar:/usr/local/tomcat_1/bin/tomcat-juli.jar
Tomcat started.

⑥、访问浏览器,看其服务测试页面正否正常访问
1️⃣、http://192.168.1.117:8080
1
2️⃣、http://192.168.1.118:8080
2

三、安装 Jforum 论坛

动作位置:192.168.1.112
1、下载Jforum 论坛

[root@localhost ~]# yum install lrzsz -y   #上传组件
[root@localhost ~]# rz -E   #上传命令
[root@localhost ~]# ls
jdk1.8.0_131.tar.gz  jforum-2.5.0.war

2、解压 war 包需要JDK支持

①、解压 JDK

[root@localhost ~]# tar -xzf jdk1.8.0_131.tar.gz

②、移动 JDK 至 /usr/local 目录下

[root@localhost ~]# mv jdk1.8.0_131 /usr/local/java

③、添加永久环境变量

[root@localhost local]# vim /etc/profile

在最低下添加,并保存

export JAVA_HOME=/usr/local/java/

使用如下命令使其马上生效

[root@localhost local]# source /etc/profile

3、移动 jforum-2.5.0.war 服务包至共享服务器

[root@localhost ~]# cp jforum-2.5.0.war /data/Jforum/
[root@localhost ~]# cp jforum-2.5.0.war /data/Jforum_1/

4、解压 jforum-2.5.0.war 服务包

[root@localhost Jforum]# /usr/local/java/bin/jar -xf jforum-2.5.0.war
[root@localhost Jforum]# rm jforum-2.5.0.war
[root@localhost Jforum_1]# /usr/local/java/bin/jar -xf jforum-2.5.0.war
[root@localhost Jforum_1]# rm jforum-2.5.0.war

动作位置:192.168.1.117
5、挂载网址内容
①、YUM安装NFS文件共享服务

[root@localhost ~]# yum install nfs-utils -y   #无需启动

②、挂载网址内容

[root@localhost webapps]# mount -t nfs 192.168.1.112:/data/Jforum /usr/local/tomcat_1/webapps/ROOT

6、访问http://192.168.1.117:8080,进行论坛安装
1
7、创建 Jforum 论坛数据库连接

mysql> grant all on Jforum_1.* to Jforum_1@'localhost' identified by "123456";
Query OK, 0 rows affected (0.00 sec)

mysql> create database Jforum_1 charset=utf8;
Query OK, 1 row affected (0.01 sec)

mysql> flush privileges;
Query OK, 0 rows affected (0.01 sec)

8、数据库创建完成进行下一步
2
3
4
动作位置:192.168.1.118
9、挂载网址内容
①、YUM安装NFS文件共享服务

[root@localhost ~]# yum install nfs-utils -y   #无需启动

②、挂载网址内容

[root@localhost webapps]# mount -t nfs 192.168.1.112:/data/Jforum_1 /usr/local/tomcat_1/webapps/ROOT/

10、访问http://192.168.1.118:8080,进行论坛安装
5
11、创建 Jforum 论坛数据库连接

mysql> grant all on Jforum_2.* to Jforum_2@'192.168.1.118' identified by "123456";
Query OK, 0 rows affected (0.00 sec)

mysql> create database Jforum_2 charset=utf8;
Query OK, 1 row affected (0.00 sec)

mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)

6
8
在这里插入图片描述

四、使用 Nginx 进行动静分离与负载均衡

1、断开NFS连接

[root@localhost ~]# umount -t nfs 192.168.1.112:/data/Jforum /usr/local/tomcat_1/webapps/ROOT
umount.nfs4: /usr/local/tomcat_1/webapps/ROOT: device is busy
umount.nfs4: /usr/local/tomcat_1/webapps/ROOT: device is busy
#出现此错误请关闭网页即可
[root@localhost ~]# umount -t nfs 192.168.1.112:/data/Jforum /usr/local/tomcat_1/webapps/ROOT
umount: /usr/local/tomcat_1/webapps/ROOT:未挂载

2、复制多份Tomcat

[root@localhost ~]# cd /usr/local/
[root@localhost local]# pkill java   #关闭jdk
[root@localhost local]# pkill tomcat   #关闭Tomcat
[root@localhost local]# cp tomcat_1 tomcat_2 -a
[root@localhost local]# cp tomcat_1 tomcat_3 -a
[root@localhost local]# cp tomcat_1 tomcat_4 -a

3、修改 tomcat 端口
①、修改 tomcat_2 端口

[root@localhost local]# cd /usr/local/tomcat_2/conf
[root@localhost conf]# cp server.xml server.xml.bak   #先进行备份
[root@localhost conf]# vim server.xml
22 <Server port="8005" shutdown="SHUTDOWN">
22 <Server port="8006" shutdown="SHUTDOWN">   #修改为

69 <Connector port="8080" protocol="HTTP/1.1"
69 <Connector port="8081" protocol="HTTP/1.1"

116 <Connector port="8009" protocol="AJP/1.3" redirectPort="8443" />
116 <Connector port="8010" protocol="AJP/1.3" redirectPort="8443" />   #修改为

②、修改 tomcat_3 端口

[root@localhost local]# cd /usr/local/tomcat_3/conf
[root@localhost conf]# cp server.xml server.xml.bak   #先进行备份
[root@localhost conf]# vim server.xml
22 <Server port="8005" shutdown="SHUTDOWN">
22 <Server port="8007" shutdown="SHUTDOWN">   #修改为

69 <Connector port="8080" protocol="HTTP/1.1"
69 <Connector port="8082" protocol="HTTP/1.1"

116 <Connector port="8009" protocol="AJP/1.3" redirectPort="8443" />
116 <Connector port="8011" protocol="AJP/1.3" redirectPort="8443" />   #修改为

③、修改 tomcat_4 端口

[root@localhost local]# cd /usr/local/tomcat_4/conf
[root@localhost conf]# cp server.xml server.xml.bak   #先进行备份
[root@localhost conf]# vim server.xml
22 <Server port="8005" shutdown="SHUTDOWN">
22 <Server port="8008" shutdown="SHUTDOWN">   #修改为

69 <Connector port="8080" protocol="HTTP/1.1"
69 <Connector port="8083" protocol="HTTP/1.1"

116 <Connector port="8009" protocol="AJP/1.3" redirectPort="8443" />
116 <Connector port="8012" protocol="AJP/1.3" redirectPort="8443" />   #修改为

4、启动 tomcat_1 与 tomcat_2,并查看启动端口

[root@localhost local]# /usr/local/tomcat_1/bin/startup.sh
[root@localhost local]# /usr/local/tomcat_2/bin/startup.sh
[root@localhost local]# /usr/local/tomcat_3/bin/startup.sh
[root@localhost local]# /usr/local/tomcat_4/bin/startup.sh
[root@localhost local]# netstat -tnl
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address           Foreign Address         State            
tcp6       0      0 127.0.0.1:8007          :::*                    LISTEN     
tcp6       0      0 127.0.0.1:8008          :::*                    LISTEN     
tcp6       0      0 :::8009                 :::*                    LISTEN     
tcp6       0      0 :::8010                 :::*                    LISTEN     
tcp6       0      0 :::8011                 :::*                    LISTEN     
tcp6       0      0 :::8012                 :::*                    LISTEN     
tcp6       0      0 :::8080                 :::*                    LISTEN     
tcp6       0      0 :::8081                 :::*                    LISTEN     
tcp6       0      0 :::8082                 :::*                    LISTEN     
tcp6       0      0 :::8083                 :::*                    LISTEN     
tcp6       0      0 127.0.0.1:8005          :::*                    LISTEN     
tcp6       0      0 127.0.0.1:8006          :::*                    LISTEN

5、挂载网址内容

[root@localhost local]# mount -t nfs4 192.168.1.112:/data/Jforum /usr/local/tomcat_1/webapps/ROOT
[root@localhost local]# mount -t nfs4 192.168.1.112:/data/Jforum /usr/local/tomcat_2/webapps/ROOT

6、修改 Nginx 配置文件,并重启Nginx服务

[root@localhost data]# cd /data/nginx/conf
[root@localhost conf]# cp nginx.conf nginx.conf.bak
[root@localhost conf]# vim nginx.conf
worker_processes  1;
events {
    worker_connections  1024;
}
http {
    include       mime.types;
    default_type  application/octet-stream;
    sendfile        on;
    keepalive_timeout  65;

    upstream tomcat_v1 {
        server 192.168.1.117:8080 weight=100 max_fails=2 fail_timeout=15;
        server 192.168.1.117:8081 weight=100 max_fails=2 fail_timeout=15;
        server 192.168.1.118:8082 weight=100 max_fails=2 fail_timeout=15;
        server 192.168.1.118:8083 weight=100 max_fails=2 fail_timeout=15;
    }

    server {
        listen       80;
        server_name  v1.jf.com;

        location / {
            proxy_pass http://tomcat_v1;
            proxy_set_header host $host;
        }
        location ~ .*.(htm|html|js|css|txt|png|jpg|jpeg|doc)$
        {
            root  /data/Jforum;
            expires 30d;
        }

        error_page   500 502 503 504  /50x.html;
        location = /50x.html {
            root   html;
        }
	}
}
[root@localhost conf]# /data/nginx/sbin/nginx -s reload

动作位置:192.168.1.118
7、复制多份Tomcat

[root@localhost ~]# cd /usr/local/
[root@localhost local]# pkill java   #关闭jdk
[root@localhost local]# pkill tomcat   #关闭Tomcat
[root@localhost local]# cp tomcat_1 tomcat_2 -a
[root@localhost local]# cp tomcat_1 tomcat_3 -a
[root@localhost local]# cp tomcat_1 tomcat_4 -a

8、修改 tomcat 端口
①、修改 tomcat_2 端口

[root@localhost local]# cd /usr/local/tomcat_2/conf
[root@localhost conf]# cp server.xml server.xml.bak   #先进行备份
[root@localhost conf]# vim server.xml
22 <Server port="8005" shutdown="SHUTDOWN">
22 <Server port="8006" shutdown="SHUTDOWN">   #修改为

69 <Connector port="8080" protocol="HTTP/1.1"
69 <Connector port="8081" protocol="HTTP/1.1"

116 <Connector port="8009" protocol="AJP/1.3" redirectPort="8443" />
116 <Connector port="8010" protocol="AJP/1.3" redirectPort="8443" />   #修改为

②、修改 tomcat_3 端口

[root@localhost local]# cd /usr/local/tomcat_3/conf
[root@localhost conf]# cp server.xml server.xml.bak   #先进行备份
[root@localhost conf]# vim server.xml
22 <Server port="8005" shutdown="SHUTDOWN">
22 <Server port="8007" shutdown="SHUTDOWN">   #修改为

69 <Connector port="8080" protocol="HTTP/1.1"
69 <Connector port="8082" protocol="HTTP/1.1"

116 <Connector port="8009" protocol="AJP/1.3" redirectPort="8443" />
116 <Connector port="8011" protocol="AJP/1.3" redirectPort="8443" />   #修改为

③、修改 tomcat_4 端口

[root@localhost local]# cd /usr/local/tomcat_4/conf
[root@localhost conf]# cp server.xml server.xml.bak   #先进行备份
[root@localhost conf]# vim server.xml
22 <Server port="8005" shutdown="SHUTDOWN">
22 <Server port="8008" shutdown="SHUTDOWN">   #修改为

69 <Connector port="8080" protocol="HTTP/1.1"
69 <Connector port="8083" protocol="HTTP/1.1"

116 <Connector port="8009" protocol="AJP/1.3" redirectPort="8443" />
116 <Connector port="8012" protocol="AJP/1.3" redirectPort="8443" />   #修改为

9、启动 tomcat_1 与 tomcat_2,并查看启动端口

[root@localhost local]# /usr/local/tomcat_1/bin/startup.sh
[root@localhost local]# /usr/local/tomcat_2/bin/startup.sh
[root@localhost local]# /usr/local/tomcat_3/bin/startup.sh
[root@localhost local]# /usr/local/tomcat_4/bin/startup.sh
[root@localhost local]# netstat -tnl
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address           Foreign Address         State           
tcp6       0      0 127.0.0.1:8007          :::*                    LISTEN     
tcp6       0      0 127.0.0.1:8008          :::*                    LISTEN
tcp6       0      0 :::8009                 :::*                    LISTEN     
tcp6       0      0 :::8010                 :::*                    LISTEN     
tcp6       0      0 :::8011                 :::*                    LISTEN         
tcp6       0      0 :::8012                 :::*                    LISTEN
tcp6       0      0 :::8080                 :::*                    LISTEN     
tcp6       0      0 :::8081                 :::*                    LISTEN     
tcp6       0      0 :::8082                 :::*                    LISTEN     
tcp6       0      0 :::8083                 :::*                    LISTEN
tcp6       0      0 127.0.0.1:8005          :::*                    LISTEN     
tcp6       0      0 127.0.0.1:8006          :::*                    LISTEN

10、修改 Nginx 配置文件,并重启Nginx服务

worker_processes  1;
events {
    worker_connections  1024;
}
http {
    include       mime.types;
    default_type  application/octet-stream;
    sendfile        on;
    keepalive_timeout  65;

    upstream tomcat_v1 {
        server 192.168.1.117:8080 weight=100 max_fails=2 fail_timeout=15;
        server 192.168.1.117:8081 weight=100 max_fails=2 fail_timeout=15;
        server 192.168.1.118:8082 weight=100 max_fails=2 fail_timeout=15;
        server 192.168.1.118:8083 weight=100 max_fails=2 fail_timeout=15;
    }
	
	    upstream tomcat_v2 {
        server 192.168.1.118:8080 weight=100 max_fails=2 fail_timeout=15;
        server 192.168.1.118:8081 weight=100 max_fails=2 fail_timeout=15;
        server 192.168.1.117:8082 weight=100 max_fails=2 fail_timeout=15;
        server 192.168.1.117:8083 weight=100 max_fails=2 fail_timeout=15;
    }

    server {
        listen       80;
        server_name  v1.jf.com;

        location / {
            proxy_pass http://tomcat_v1;
            proxy_set_header host $host;
            add_header backendIP $upstream_addr;
        }
        location ~ .*.(htm|html|js|css|txt|png|jpg|jpeg|doc)$
        {
            root  /data/Jforum;
            expires 30d;
        }

        error_page   500 502 503 504  /50x.html;
        location = /50x.html {
            root   html;
        }
	}
	
	server {
        listen       80;
        server_name  v2.jf.com;

        location / {
            proxy_pass http://tomcat_v2;
            proxy_set_header host $host;
            add_header backendIP $upstream_addr;
        }
        location ~ .*.(htm|html|js|css|txt|png|jpg|jpeg|doc)$
        {
            root  /data/Jforum_1;
            expires 30d;
        }

        error_page   500 502 503 504  /50x.html;
        location = /50x.html {
            root   html;
        }
	}
}
[root@localhost conf]# /data/nginx/sbin/nginx -s reload

五、访问浏览器

1、访问http://v1.jf.com
1
2、访问http://v2.jf.com
2

最后

以上就是懦弱鲜花为你收集整理的LNMT集群架构发布Jforum论坛一、实验服务器分配二、安装实验必备服务三、安装 Jforum 论坛四、使用 Nginx 进行动静分离与负载均衡的全部内容,希望文章能够帮你解决LNMT集群架构发布Jforum论坛一、实验服务器分配二、安装实验必备服务三、安装 Jforum 论坛四、使用 Nginx 进行动静分离与负载均衡所遇到的程序开发问题。

如果觉得靠谱客网站的内容还不错,欢迎将靠谱客网站推荐给程序员好友。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(40)

评论列表共有 0 条评论

立即
投稿
返回
顶部