LNMP環境にDiscuzフォーラムをインストールする方法

LNMP環境の構築

LNMP環境の構築手順については、以下の記事を参照してください。
※本章では既にLNMP環境が構築済みであることを前提とします。

Discuzフォーラムシステムの導入

アーカイブのダウンロードと展開

まず、Discuzフォーラムシステムのアーカイブをダウンロードします。公式ウェブサイトから最新バージョンを取得してください。

[root@webserver01 ~]# ls
anaconda-ks.cfg  Discuz_X3.5_SC_UTF8.zip

次に、Webサーバー用のディレクトリを作成し、アーカイブを展開します。

[root@webserver01 ~]# mkdir -p /usr/local/nginx/html/forum
[root@webserver01 ~]# unzip Discuz_X3.5_SC_UTF8.zip -d /usr/local/nginx/html/forum/
[root@webserver01 ~]# cd /usr/local/nginx/html/forum/
[root@webserver01 forum]# ls
LICENSE  qqqun.png  readme  readme.html  upload  utility.html
[root@webserver01 forum]# cd upload/
[root@webserver01 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

パーミッションの設定

Discuzの正常に動作するために、特定のディレクトリに対して適切な所有者と権限を設定する必要があります。

[root@webserver01 upload]# chown -R nginx config/
[root@webserver01 upload]# chown -R nginx data/
[root@webserver01 upload]# chown -R nginx uc_client/
[root@webserver01 upload]# chown -R nginx uc_server/
[root@webserver01 upload]# chmod -R 777 config/
[root@webserver01 upload]# chmod -R 777 data/
[root@webserver01 upload]# chmod -R 777 uc_client/
[root@webserver01 upload]# chmod -R 777 uc_server/

データベースの作成

MySQLでDiscuz用のデータベースを作成します。

mysql> CREATE DATABASE forum_db;
mysql> SHOW DATABASES;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| forum_db           |
| mysql              |
| performance_schema |
| sys                |
+--------------------+

仮想ホストの設定

Nginxの設定ファイルを編集して、フォーラム用の仮想ホストを構成します。

[root@webserver01 upload]# vim /usr/local/nginx/conf/nginx.conf
......
server {
        listen       80;
        server_name  www.example.local;
        
        location / {
            root   html/forum/upload;
            index  index.php index.html index.htm;
        }
        
        error_page   500 502 503 504  /50x.html;
        location = /50x.html {
            root   html;
        }
        
        location ~ \.php$ {
            root           html/forum/upload;
            fastcgi_pass   127.0.0.1:9000;
            fastcgi_index  index.php;
            fastcgi_param  SCRIPT_FILENAME  /scripts$fastcgi_script_name;
            include        fastcgi.conf;
        }
    }
......

サービスの再起動

設定を有効にするため、Nginxとphp-fpmを再起動します。

[root@webserver01 upload]# systemctl restart nginx.service
[root@webserver01 upload]# systemctl restart php-fpm.service

Discuzフォーラムのインストール

初回セットアップ時は、ドメイン名の末尾に「/install」を付けてアクセスすることで、インストールウィザードが開始されます。

サイトへのアクセス

ブラウザで設定したドメイン名にアクセスし、画面の指示に従ってインストール作業を完了してください。

タグ: nginx php-fpm MySQL discuz CentOS

9月3日 05:04 投稿