lnmp架构部署Discuz论坛并配置重定向转发

lnmp架构部署Discuz论坛并配置重定向转发

环境说明

主机名安装服务版本系统
LNMPnginx,mysql,phpredhat8

部署LNMP-CSDN博客

部署Discuz论坛系统

#下载Discuz论坛
[root@LNMP ~]# cd /usr/src
[root@LNMP src]# wget https://gitee.com/Discuz/DiscuzX/attach_files/1543382/download/Discuz_X3.5_SC_UTF8_20231001.zip

# 创建解压位置
[root@LNMP ~]# mkdir /usr/local/nginx/html/Discuz
[root@LNMP src]# unzip -d /usr/local/nginx/html/Discuz/ Discuz_X3.5_SC_UTF8_20231001.zip
[root@LNMP src]# cd /usr/local/nginx/html/Discuz/ 
[root@LNMP Discuz]# ll 
total 124
-rw-r--r--  1 root root  8181 Oct  1 23:02 LICENSE
-rw-r--r--  1 root root 33294 Dec 21  2022 qqqun.png
drwxr-xr-x  2 root root   124 Oct  2 00:28 readme
-rw-r--r--  1 root root 70226 Mar 16  2023 readme.html
drwxr-xr-x 12 root root  4096 Oct  2 00:28 upload
-rw-r--r--  1 root root   140 Feb 12  2023 utility.html

#创建数据库
[root@LNMP ~]# mysql -uroot -p12345678 -e "create database Discuz;"
[root@LNMP ~]# mysql -uroot -p12345678 -e "create user 'Discuz'@'localhost' identified by '87654321';"
[root@LNMP ~]# mysql -uroot -p12345678 -e "grant all privileges on Discuz.* to 'Discuz'@'localhost';"
[root@LNMP ~]# mysql -uroot -p12345678 -e "flush privileges;"

#修改所需文件的属主属组、权限
[root@LNMP Discuz]# cd /usr/local/nginx/html/Discuz/upload/
[root@LNMP upload]# chmod -R 777 config/
[root@LNMP upload]# chmod -R 777 data/
[root@LNMP upload]# chmod -R 777 uc_client/
[root@LNMP upload]# chmod -R 777 uc_server/

#编辑nginx的配置文件,创建一个虚拟主机,使其可以用域名访问
[root@LNMP ~]# vim /usr/local/nginx/conf/nginx.conf
worker_processes  4;
worker_rlimit_nofile 65535;
worker_cpu_affinity 0001 0010 0100 1000;
error_log  /var/log/nginx/error.log;
pid        logs/nginx.pid;

events {
    worker_connections  1024;
}

http {
    include       mime.types;
    default_type  application/octet-stream;
    sendfile        on;
    tcp_nopush      on;
    keepalive_timeout  65;
    gzip  on;

    log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
                      '$status $body_bytes_sent "$http_referer" '
                      '"$http_user_agent" "$http_x_forwarded_for"';

    access_log  /var/log/nginx/access.log  main;

    server {
        listen       80;
        server_name  www.dis.com;

        charset utf8;
        access_log  logs/host.access.log  main;
        error_page  404              /404.html;
        error_page  500 502 503 504  /50x.html;
        location = /50x.html {
            root   html;
        }

        location / {
            root   html/Discuz/upload;
            index  index.php index.html index.htm;
            # 重定向转发
            #if ($host = 'www.dis.com'){
            #       rewrite ^/(.*)$ http://www.bbs.com/$1 permanent;
            #}
        }
        
        location ~ \.php$ {
            root           html/Discuz/upload;
            fastcgi_pass   127.0.0.1:9000;
            fastcgi_index  index.php;
            fastcgi_param  SCRIPT_FILENAME  $Document_Root$fastcgi_script_name;
            include        fastcgi_params;
        }
    }
}

#重启nginx
[root@LNMP ~]# systemctl restart nginx 

#配置Windows电脑hosts文件
C:\Windows\System32\drivers\etc\hosts
添加以下两句
192.168.200.46 www.dis.com
192.168.200.46 www.bbs.com

Discuz安装

在这里插入图片描述
点击同意
在这里插入图片描述
点击下一步
在这里插入图片描述
点击下一步
在这里插入图片描述
点击下一步,然后安装
在这里插入图片描述

点击直接访问站点
在这里插入图片描述
在这里插入图片描述

重定向转发

if ($host = 'www.dis.com'){
      rewrite ^/(.*)$ http://www.bbs.com/$1 permanent;
}

当我们之前的域名因为某些特殊原因从而导致后续无法继续使用,然而又不能直接更改域名,防止旧用户仍旧使用老域名访问时而无法访问,为了用户体验,这时就需要我们做一个转发,也就是写一个重定向转发域名的配置

测试用旧的域名(www.dis.com)访问,会自动跳转到新域名,正常访问

``

当我们之前的域名因为某些特殊原因从而导致后续无法继续使用,然而又不能直接更改域名,防止旧用户仍旧使用老域名访问时而无法访问,为了用户体验,这时就需要我们做一个转发,也就是写一个重定向转发域名的配置

测试用旧的域名(www.dis.com)访问,会自动跳转到新域名,正常访问

在这里插入图片描述

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值