lnmp architecture deploys Discuz forum and configures redirection forwarding

lnmp architecture deploys Discuz forum and configures redirection forwarding

Article directory

  • lnmp architecture deploys Discuz forum and configures redirection forwarding
    • Environmental Statement
    • Deploy Discuz forum system
      • Download the Discuz forum system code package, the official website address is as follows:
      • Steps to deploy Discuz forum system:
          • Unzip and install the Discuz source package
          • Configure virtual host
          • Enter the Discuz installation interface
          • Access the site directly via IP again
          • Create a new account
          • Domain name access
      • Configure redirect forwarding

Environmental description

Host name IP address Required services/architecture System version
lnmp 192.168.195.133 nginx-1.24.0 mysql-5.7 php-8.2.11 (lnmp architecture) centos 8

The lnmp architecture needs to be deployed first. Please read the detailed steps:

Source code compilation, installation and deployment lnmp

Deploy Discuz forum system

Download the Discuz forum system code package, the official website address is as follows:

Disucz! Download_Build a website for free_Open source website building system download_Discuz! Official_Provide you with a full range of website building services!

Upload to the virtual host after downloading

Steps to deploy Discuz forum system:

Unzip and install the Discuz source code package
//Create a website storage directory
[root@lnmp ~]# mkdir /usr/local/nginx/html/Discuz

//Install the unzip software package required to decompress the zip package, and decompress the Discuz zip to the website storage directory we created
[root@lnmp ~]# yum -y install unzip
[root@lnmp ~]# unzip Discuz_X3.5_SC_UTF8_20231001.zip -d /usr/local/nginx/html/Discuz/
[root@lnmp ~]# cd /usr/local/nginx/html
[root@lnmp html]# ls
404.html 50x.html auth_page Discuz index.html index.php
[root@lnmp html]# cd Discuz/
[root@lnmp Discuz]# ls
LICENSE qqqun.png readme readme.html upload utility.html
[root@lnmp Discuz]# cd upload/
[root@lnmp upload]# ls
admin.php archiver crossdomain.xml forum.php index.php misc.php robots.txt static uc_server
api config data group.php install plugin.php search.php template
api.php connect.php favicon.ico home.php member.php portal.php source uc_client

//Modify the owner group and permissions of the required file
[root@lnmp upload]# chown -R nginx config/
[root@lnmp upload]# chown -R nginx data/
[root@lnmp upload]# chown -R nginx uc_client/
[root@lnmp upload]# chown -R nginx uc_server/
[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/

//Create database
[root@lnmp ~]# mysql -uroot -p12345678 -e "create database Discuz;"
mysql: [Warning] Using a password on the command line interface can be insecure.
[root@lnmp ~]# mysql -uroot -p12345678 -e "show databases;"
mysql: [Warning] Using a password on the command line interface can be insecure.
 + -------------------- +
| Database |
 + -------------------- +
| information_schema |
| Discuz |
| mysql |
| performance_schema |
| sys |
 + -------------------- +
[root@lnmp ~]# mysql -uroot -p12345678 -e "grant all on Discuz.* to 'Discuz'@'%' identified by '12345678';"
mysql: [Warning] Using a password on the command line interface can be insecure.
[root@lnmp ~]# mysql -uroot -p12345678 -e "grant all on Discuz.* to 'Discuz'@'localhost' identified by '12345678';"
mysql: [Warning] Using a password on the command line interface can be insecure.
[root@lnmp ~]# mysql -uroot -p12345678 -e "flush privileges;"
mysql: [Warning] Using a password on the command line interface can be insecure.
Configure virtual host
//Edit the nginx configuration file and create a virtual host so that it can be accessed using the domain name
[root@lnmp ~]# vim /usr/local/nginx/conf/nginx.conf
[root@lnmp ~]# cat /usr/local/nginx/conf/nginx.conf
.......
server {<!-- -->
        listen 80;
        server_name www.ftx.com; //own domain name
        
        
        location / {<!-- -->
            root html/Discuz/upload; //Change to website directory
            index index.php index.html index.htm;
        }
        
        location ~ \.php$ {<!-- -->
            root html/Discuz/upload; //Change to website directory
            fastcgi_pass 127.0.0.1:9000;
            fastcgi_index index.php;
            fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name;
            include fastcgi.conf;
        }
    }
...

[root@lnmp ~]# nginx -s reload //Reread
Enter Discuz installation interface







Installation completed

Access the site directly through IP again

Create a new account


Registration successful

Domain name access


Domain name access can also be successful

Configure redirect forwarding

When our previous domain name cannot be used in the future due to some special reasons, but we cannot directly change the domain name to prevent old users from still using the old domain name to access and sometimes being unable to access. For the sake of user experience, we need to make a Forwarding, that is, writing a redirection forwarding domain name configuration

For example, our www.yyr.com is our old domain name. Now if we want the new domain name to be able to access the previous webpage, we need to add the following content to the nginx.conf configuration file:

[root@lnmp conf]# vim nginx.conf
[root@lnmp conf]# cat nginx.conf
. . . . . .
server {<!-- -->
        listen 80;
        server_name www.yyr.com;

        location / {<!-- -->
            roothtml;
            index index.php index.html index.htm;
            rewrite ^/(.*)$ http://www.ftx.com/$1 break;
        }

        error_page 500 502 503 504 /50x.html;
        location = /50x.html {<!-- -->
            roothtml;
        }




        location ~ \.php$ {<!-- -->
           roothtml;
           fastcgi_pass 127.0.0.1:9000;
           fastcgi_index index.php;
           fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name;
           include fastcgi.conf;
        }
    }
. . . . . .
[root@lnmp conf]# nginx -s reload //Reload

Use old domain name

Access using a new domain name

If you still cannot access it after following the above steps, you can try other browsers (such as Google)