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
    评论
以下是在 LNMP 环境下部署 WordPress 论坛的详细配置步骤: 1. 安装 LNMP 环境 首先需要安装 LNMP 环境,这里我们以 Ubuntu 18.04 为例,执行以下命令: ``` sudo apt-get update sudo apt-get install nginx mysql-server php-fpm php-mysql ``` 2. 配置 Nginx 在配置文件 /etc/nginx/sites-available/default 中添加以下内容: ``` server { listen 80; listen [::]:80; root /var/www/html; index index.php index.html index.htm index.nginx-debian.html; server_name yourdomain.com; location / { try_files $uri $uri/ /index.php?$args; } location ~ \.php$ { include snippets/fastcgi-php.conf; fastcgi_pass unix:/var/run/php/php7.4-fpm.sock; } location ~ /\.ht { deny all; } } ``` 3. 安装 WordPress 下载最新版 WordPress,并解压到 /var/www/html 目录下: ``` cd /tmp wget https://wordpress.org/latest.tar.gz tar -zxvf latest.tar.gz sudo mv wordpress /var/www/html/ ``` 4. 配置数据库 进入 MySQL 终端: ``` sudo mysql -u root -p ``` 创建一个新的数据库: ``` CREATE DATABASE wordpress; ``` 创建一个新用户并授权: ``` CREATE USER 'wordpressuser'@'localhost' IDENTIFIED BY 'password'; GRANT ALL PRIVILEGES ON wordpress.* TO 'wordpressuser'@'localhost'; FLUSH PRIVILEGES; exit; ``` 5. 配置 WordPress 在 /var/www/html/wordpress 目录下,将 wp-config-sample.php 文件命名为 wp-config.php: ``` cd /var/www/html/wordpress mv wp-config-sample.php wp-config.php ``` 编辑 wp-config.php 文件,修改以下内容: ``` define( 'DB_NAME', 'wordpress' ); define( 'DB_USER', 'wordpressuser' ); define( 'DB_PASSWORD', 'password' ); define( 'DB_HOST', 'localhost' ); ``` 6. 安装 WordPress 在浏览器中输入你的域名,进入 WordPress 安装界面,根据提示完成安装。 7. 配置 HTTPS 为了保证网站的安全性,我们可以配置 HTTPS。可以使用 Let's Encrypt 进行免费的 SSL 证书申请和配置。 安装 Certbot: ``` sudo apt-get install certbot python3-certbot-nginx ``` 执行以下命令申请证书: ``` sudo certbot --nginx -d yourdomain.com ``` 根据提示完成证书申请和配置即可。 至此,LNMP 平台下的 WordPress 论坛部署配置完成。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值