天天看點

Linux雲計算架構-使用LNMP架構部署Discuz論壇Linux雲計算架構-使用LNMP架構部署Discuz論壇

文章目錄

  • Linux雲計算架構-使用LNMP架構部署Discuz論壇
    • 1. 配置LNMP環境
    • 2. 安裝Discuz_X3.4

Linux雲計算架構-使用LNMP架構部署Discuz論壇

1. 配置LNMP環境

①下載下傳aliyun的yum源,下載下傳位址:

https://developer.aliyun.com/mirror/

# 移除原來的yum源
[[email protected] ~]# cd /etc/yum.repos.d/
[[email protected] yum.repos.d]# ll
總用量 12
-rw-r--r--. 1 root root 2523 6月  16 2018 Centos-7.repo
-rw-r--r--. 1 root root  664 5月  11 2018 epel-7.repo
-rw-r--r--. 1 root root   71 10月 20 13:58 local.repo
[[email protected] yum.repos.d]# mv ./* /opt/
[[email protected] yum.repos.d]# ll
總用量 0

# 下載下傳aliyun最新的yum源
wget -O /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-7.repo
wget -O /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-7.repo
[[email protected] yum.repos.d]# ll
總用量 8
-rw-r--r--. 1 root root 2523 6月  16 2018 CentOS-Base.repo
-rw-r--r--. 1 root root  664 5月  11 2018 epel.repo

# 清空原來的緩存,生成新的緩存。
[[email protected] yum.repos.d]# yum clean all
已加載插件:fastestmirror, langpacks
正在清理軟體源: base epel extras updates
Cleaning up list of fastest mirrors
Other repos take up 50 M of disk space (use --verbose for details)
[[email protected] yum.repos.d]# yum makecache
           

②部署LNMP環境:

# yum快速部署LNMP環境
[[email protected] ~]# yum install nginx mariadb mariadb-server php php-mysql php-fpm php-gd php-mysql php-mbstring php-xml php-mcrypt php-imap php-odbc php-pear php -xmlrpc -y

# 啟動php-fpm
[[email protected] ~]# systemctl start php-fpm.service
[[email protected] ~]# systemctl enable php-fpm.service

# 啟動mysql資料庫,并建立資料庫discuz和使用者discuz
[[email protected] install]# mysql
Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MariaDB connection id is 2
Server version: 5.5.65-MariaDB MariaDB Server

Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

MariaDB [(none)]> create database discuz;
Query OK, 1 row affected (0.00 sec)

MariaDB [(none)]> grant all privileges on discuz.* to [email protected] identified by '123456';
Query OK, 0 rows affected (0.00 sec)

MariaDB [(none)]> flush privileges;
Query OK, 0 rows affected (0.00 sec)

MariaDB [(none)]> exit
Bye
# 測試下能否使用discuz使用者登入資料庫,如果不行,估計後面安裝的時候會報錯。
[[email protected] ~]# mysql -udiscuz -p123456
Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MariaDB connection id is 3
Server version: 5.5.65-MariaDB MariaDB Server

Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

MariaDB [(none)]> 


# 修改nginx的配置檔案,以支援php
[[email protected] ~]# cd /etc/nginx/
[[email protected] nginx]# cp nginx.conf nginx.conf.bak 
[[email protected] nginx]# vim /etc/nginx/nginx.conf
    server {
        listen       80;
        server_name  localhost;
        
        location / {
            root         /usr/share/nginx/html;
            index index.html index.htm index.php;   # 指定首頁檔案,從左往右比對,用空格隔開。
        }
        location ~ \.php$ {   # 配置支援php
                root           html;
                fastcgi_pass   127.0.0.1:9000;
                fastcgi_index  index.php;
                fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name; 
                include        fastcgi_params;
        }

        error_page 404 /404.html;
        location = /404.html {
        }

        error_page 500 502 503 504 /50x.html;
        location = /50x.html {
        }
    }

# 啟動并設定開機自啟動
[[email protected] nginx]# systemctl start nginx.service 
[[email protected] nginx]# systemctl enable nginx.service 
Created symlink from /etc/systemd/system/multi-user.target.wants/nginx.service to /

# 編寫一個簡單的php首頁檔案,用來測試是否支援php
[[email protected] nginx]# echo "<?php phpinfo(); ?>" > /usr/share/nginx/html/index.php

# 開放防火牆的80端口号
[[email protected] nginx]# firewall-cmd --permanent --zone=public --add-port=80/tcp
success
[[email protected] nginx]# firewall-cmd --reload
success
           

通路IP位址

192.168.80.128

自動跳轉:

http://192.168.80.128/index.php

,如下:

Linux雲計算架構-使用LNMP架構部署Discuz論壇Linux雲計算架構-使用LNMP架構部署Discuz論壇

2. 安裝Discuz_X3.4

下載下傳位址:

https://gitee.com/3dming/DiscuzL/attach_files

Linux雲計算架構-使用LNMP架構部署Discuz論壇Linux雲計算架構-使用LNMP架構部署Discuz論壇

①上傳discuz論壇的安裝包,并配置nginx網站資料目錄。

# 上傳并解壓Discuz安裝包
[[email protected] ~]# cd /usr/local/src/
[[email protected] src]# rz
[[email protected] src]# ll Discuz_X3.4_SC_UTF8【20200818】.zip 
-rw-r--r--. 1 root root 12144234 11月 10 22:13 Discuz_X3.4_SC_UTF8【20200818】.zip
[[email protected] src]# unzip Discuz_X3.4_SC_UTF8【20200818】.zip -d discuz
[[email protected] src]# ll
總用量 11860
drwxr-xr-x. 5 root root       85 11月 10 22:15 discuz
-rw-r--r--. 1 root root 12144234 11月 10 22:13 Discuz_X3.4_SC_UTF8【20200818】.zip


# 移除nginx網站資料目錄下的首頁檔案
[[email protected] ~]# cd /usr/share/nginx/html/
[[email protected] html]# ll
總用量 16
-rw-r--r--. 1 root root 3650 6月   8 00:28 404.html
-rw-r--r--. 1 root root 3693 6月   8 00:28 50x.html
lrwxrwxrwx. 1 root root   20 11月 10 21:37 en-US -> ../../doc/HTML/en-US
drwxr-xr-x. 2 root root   27 11月 10 21:37 icons
lrwxrwxrwx. 1 root root   18 11月 10 21:37 img -> ../../doc/HTML/img
lrwxrwxrwx. 1 root root   25 11月 10 21:37 index.html -> ../../doc/HTML/index.html
-rw-r--r--. 1 root root   20 11月 10 21:44 index.php
-rw-r--r--. 1 root root  368 6月   8 00:28 nginx-logo.png
lrwxrwxrwx. 1 root root   14 11月 10 21:37 poweredby.png -> nginx-logo.png
[[email protected] html]# mv ./{index.html,50x.html,index.php} /opt


# 複制discuz論壇的頁面到nginx的網站資料目錄下
[[email protected] ~]# cd /usr/local/src/discuz/upload/
[[email protected] upload]# cp -r ./* /usr/share/nginx/html/
[[email protected] upload]# cd /usr/share/nginx/html/
[[email protected] html]# ll
總用量 76
-rw-r--r--.  1 root root 3650 6月   8 00:28 404.html
-rw-r--r--.  1 root root 2738 11月 11 14:19 admin.php
drwxr-xr-x.  9 root root  135 11月 11 14:19 api
-rw-r--r--.  1 root root  727 11月 11 14:19 api.php
drwxr-xr-x.  2 root root   23 11月 11 14:19 archiver
drwxr-xr-x.  2 root root   90 11月 11 14:19 config
-rw-r--r--.  1 root root 1017 11月 11 14:19 connect.php
-rw-r--r--.  1 root root  106 11月 11 14:19 crossdomain.xml
drwxr-xr-x. 12 root root  202 11月 11 14:19 data
lrwxrwxrwx.  1 root root   20 11月 11 14:03 en-US -> ../../doc/HTML/en-US
-rw-r--r--.  1 root root 5558 11月 11 14:19 favicon.ico
-rw-r--r--.  1 root root 2245 11月 11 14:19 forum.php
-rw-r--r--.  1 root root  821 11月 11 14:19 group.php
-rw-r--r--.  1 root root 1280 11月 11 14:19 home.php
drwxr-xr-x.  2 root root   27 11月 11 14:03 icons
lrwxrwxrwx.  1 root root   18 11月 11 14:03 img -> ../../doc/HTML/img
-rw-r--r--.  1 root root 6472 11月 11 14:19 index.php
drwxr-xr-x.  5 root root   64 11月 11 14:19 install
drwxr-xr-x.  2 root root   23 11月 11 14:19 m
-rw-r--r--.  1 root root 1025 11月 11 14:19 member.php
-rw-r--r--.  1 root root 2435 11月 11 14:19 misc.php
-rw-r--r--.  1 root root  368 6月   8 00:28 nginx-logo.png
-rw-r--r--.  1 root root 1788 11月 11 14:19 plugin.php
-rw-r--r--.  1 root root  977 11月 11 14:19 portal.php
lrwxrwxrwx.  1 root root   14 11月 11 14:03 poweredby.png -> nginx-logo.png
-rw-r--r--.  1 root root  582 11月 11 14:19 robots.txt
-rw-r--r--.  1 root root 1155 11月 11 14:19 search.php
drwxr-xr-x. 10 root root  168 11月 11 14:19 source
drwxr-xr-x.  7 root root   86 11月 11 14:19 static
drwxr-xr-x.  3 root root   38 11月 11 14:19 template
drwxr-xr-x.  7 root root  106 11月 11 14:19 uc_client
drwxr-xr-x. 13 root root  241 11月 11 14:19 uc_server


# 為網頁資料設定權限,并設定selinux,否則會出現網站資料目錄不可讀。
[[email protected] ~]# chown -R nginx:nginx /usr/share/nginx/html/
[[email protected] ~]# chmod -R 777 /usr/share/nginx/html/
[[email protected] ~]# setenforce 0
[[email protected] ~]# getenforce 
Permissive
           

②安裝discuz論壇:

輸入網址:

http://192.168.80.128/install/

Linux雲計算架構-使用LNMP架構部署Discuz論壇Linux雲計算架構-使用LNMP架構部署Discuz論壇

點選“我同意”:

Linux雲計算架構-使用LNMP架構部署Discuz論壇Linux雲計算架構-使用LNMP架構部署Discuz論壇

全部都是正确,然後點選“下一步”:

Linux雲計算架構-使用LNMP架構部署Discuz論壇Linux雲計算架構-使用LNMP架構部署Discuz論壇

輸入之前建立的discuz資料庫資訊:

Linux雲計算架構-使用LNMP架構部署Discuz論壇Linux雲計算架構-使用LNMP架構部署Discuz論壇

點選”下一步“,開始安裝,安裝好如下:

Linux雲計算架構-使用LNMP架構部署Discuz論壇Linux雲計算架構-使用LNMP架構部署Discuz論壇

③登入discuz論壇:

輸入網址:

http://192.168.80.128/

Linux雲計算架構-使用LNMP架構部署Discuz論壇Linux雲計算架構-使用LNMP架構部署Discuz論壇

輸入管理者admin的賬号密碼:

Linux雲計算架構-使用LNMP架構部署Discuz論壇Linux雲計算架構-使用LNMP架構部署Discuz論壇

可以看到,已經登入成功了。

Linux雲計算架構-使用LNMP架構部署Discuz論壇Linux雲計算架構-使用LNMP架構部署Discuz論壇

拓展:Discuz論壇主要是由php頁面構成,如需做負載均衡,可以考慮使用apache做後端伺服器。若程式主要由jsp頁面構成,可以考慮使用tomcat做後端伺服器。有興趣的同學可以建構下nginx+apache架構實作負載均衡。