Linux云计算架构-使用LNMP架构部署Discuz论坛

╰+攻爆jí腚メ 2022-11-22 00:17 338阅读 0赞

文章目录

  • Linux云计算架构-使用LNMP架构部署Discuz论坛
      1. 配置LNMP环境
      1. 安装Discuz_X3.4

Linux云计算架构-使用LNMP架构部署Discuz论坛

1. 配置LNMP环境

①下载aliyun的yum源,下载地址https://developer.aliyun.com/mirror/

  1. # 移除原来的yum源
  2. [root@server ~]# cd /etc/yum.repos.d/
  3. [root@server yum.repos.d]# ll
  4. 总用量 12
  5. -rw-r--r--. 1 root root 2523 6 16 2018 Centos-7.repo
  6. -rw-r--r--. 1 root root 664 5 11 2018 epel-7.repo
  7. -rw-r--r--. 1 root root 71 10 20 13:58 local.repo
  8. [root@server yum.repos.d]# mv ./* /opt/
  9. [root@server yum.repos.d]# ll
  10. 总用量 0
  11. # 下载aliyun最新的yum源
  12. wget -O /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-7.repo
  13. wget -O /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-7.repo
  14. [root@server yum.repos.d]# ll
  15. 总用量 8
  16. -rw-r--r--. 1 root root 2523 6月 16 2018 CentOS-Base.repo
  17. -rw-r--r--. 1 root root 664 5月 11 2018 epel.repo
  18. # 清空原来的缓存,生成新的缓存。
  19. [root@server yum.repos.d]# yum clean all
  20. 已加载插件:fastestmirror, langpacks
  21. 正在清理软件源: base epel extras updates
  22. Cleaning up list of fastest mirrors
  23. Other repos take up 50 M of disk space (use --verbose for details)
  24. [root@server yum.repos.d]# yum makecache

②部署LNMP环境:

  1. # yum快速部署LNMP环境
  2. [root@server ~]# 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
  3. # 启动php-fpm
  4. [root@server ~]# systemctl start php-fpm.service
  5. [root@server ~]# systemctl enable php-fpm.service
  6. # 启动mysql数据库,并创建数据库discuz和用户discuz
  7. [root@server install]# mysql
  8. Welcome to the MariaDB monitor. Commands end with ; or \g.
  9. Your MariaDB connection id is 2
  10. Server version: 5.5.65-MariaDB MariaDB Server
  11. Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.
  12. Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
  13. MariaDB [(none)]> create database discuz;
  14. Query OK, 1 row affected (0.00 sec)
  15. MariaDB [(none)]> grant all privileges on discuz.* to discuz@localhost identified by '123456';
  16. Query OK, 0 rows affected (0.00 sec)
  17. MariaDB [(none)]> flush privileges;
  18. Query OK, 0 rows affected (0.00 sec)
  19. MariaDB [(none)]> exit
  20. Bye
  21. # 测试下能否使用discuz用户登录数据库,如果不行,估计后面安装的时候会报错。
  22. [root@server ~]# mysql -udiscuz -p123456
  23. Welcome to the MariaDB monitor. Commands end with ; or \g.
  24. Your MariaDB connection id is 3
  25. Server version: 5.5.65-MariaDB MariaDB Server
  26. Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.
  27. Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
  28. MariaDB [(none)]>
  29. # 修改nginx的配置文件,以支持php
  30. [root@server ~]# cd /etc/nginx/
  31. [root@server nginx]# cp nginx.conf nginx.conf.bak
  32. [root@server nginx]# vim /etc/nginx/nginx.conf
  33. server {
  34. listen 80;
  35. server_name localhost;
  36. location / {
  37. root /usr/share/nginx/html;
  38. index index.html index.htm index.php; # 指定首页文件,从左往右匹配,用空格隔开。
  39. }
  40. location ~ \.php$ { # 配置支持php
  41. root html;
  42. fastcgi_pass 127.0.0.1:9000;
  43. fastcgi_index index.php;
  44. fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
  45. include fastcgi_params;
  46. }
  47. error_page 404 /404.html;
  48. location = /404.html {
  49. }
  50. error_page 500 502 503 504 /50x.html;
  51. location = /50x.html {
  52. }
  53. }
  54. # 启动并设置开机自启动
  55. [root@server nginx]# systemctl start nginx.service
  56. [root@server nginx]# systemctl enable nginx.service
  57. Created symlink from /etc/systemd/system/multi-user.target.wants/nginx.service to /
  58. # 编写一个简单的php首页文件,用来测试是否支持php
  59. [root@server nginx]# echo "<?php phpinfo(); ?>" > /usr/share/nginx/html/index.php
  60. # 开放防火墙的80端口号
  61. [root@server nginx]# firewall-cmd --permanent --zone=public --add-port=80/tcp
  62. success
  63. [root@server nginx]# firewall-cmd --reload
  64. success

访问IP地址192.168.80.128自动跳转:http://192.168.80.128/index.php,如下:
在这里插入图片描述

2. 安装Discuz_X3.4

下载地址https://gitee.com/3dming/DiscuzL/attach_files
在这里插入图片描述
①上传discuz论坛的安装包,并配置nginx网站数据目录。

  1. # 上传并解压Discuz安装包
  2. [root@server ~]# cd /usr/local/src/
  3. [root@server src]# rz
  4. [root@server src]# ll Discuz_X3.4_SC_UTF820200818】.zip
  5. -rw-r--r--. 1 root root 12144234 11 10 22:13 Discuz_X3.4_SC_UTF820200818】.zip
  6. [root@server src]# unzip Discuz_X3.4_SC_UTF820200818】.zip -d discuz
  7. [root@server src]# ll
  8. 总用量 11860
  9. drwxr-xr-x. 5 root root 85 11 10 22:15 discuz
  10. -rw-r--r--. 1 root root 12144234 11 10 22:13 Discuz_X3.4_SC_UTF820200818】.zip
  11. # 移除nginx网站数据目录下的首页文件
  12. [root@server ~]# cd /usr/share/nginx/html/
  13. [root@server html]# ll
  14. 总用量 16
  15. -rw-r--r--. 1 root root 3650 6 8 00:28 404.html
  16. -rw-r--r--. 1 root root 3693 6 8 00:28 50x.html
  17. lrwxrwxrwx. 1 root root 20 11 10 21:37 en-US -> ../../doc/HTML/en-US
  18. drwxr-xr-x. 2 root root 27 11 10 21:37 icons
  19. lrwxrwxrwx. 1 root root 18 11 10 21:37 img -> ../../doc/HTML/img
  20. lrwxrwxrwx. 1 root root 25 11 10 21:37 index.html -> ../../doc/HTML/index.html
  21. -rw-r--r--. 1 root root 20 11 10 21:44 index.php
  22. -rw-r--r--. 1 root root 368 6 8 00:28 nginx-logo.png
  23. lrwxrwxrwx. 1 root root 14 11 10 21:37 poweredby.png -> nginx-logo.png
  24. [root@server html]# mv ./{index.html,50x.html,index.php} /opt
  25. # 复制discuz论坛的页面到nginx的网站数据目录下
  26. [root@server ~]# cd /usr/local/src/discuz/upload/
  27. [root@server upload]# cp -r ./* /usr/share/nginx/html/
  28. [root@server upload]# cd /usr/share/nginx/html/
  29. [root@server html]# ll
  30. 总用量 76
  31. -rw-r--r--. 1 root root 3650 6月 8 00:28 404.html
  32. -rw-r--r--. 1 root root 2738 11月 11 14:19 admin.php
  33. drwxr-xr-x. 9 root root 135 11月 11 14:19 api
  34. -rw-r--r--. 1 root root 727 11月 11 14:19 api.php
  35. drwxr-xr-x. 2 root root 23 11月 11 14:19 archiver
  36. drwxr-xr-x. 2 root root 90 11月 11 14:19 config
  37. -rw-r--r--. 1 root root 1017 11月 11 14:19 connect.php
  38. -rw-r--r--. 1 root root 106 11月 11 14:19 crossdomain.xml
  39. drwxr-xr-x. 12 root root 202 11月 11 14:19 data
  40. lrwxrwxrwx. 1 root root 20 11月 11 14:03 en-US -> ../../doc/HTML/en-US
  41. -rw-r--r--. 1 root root 5558 11月 11 14:19 favicon.ico
  42. -rw-r--r--. 1 root root 2245 11月 11 14:19 forum.php
  43. -rw-r--r--. 1 root root 821 11月 11 14:19 group.php
  44. -rw-r--r--. 1 root root 1280 11月 11 14:19 home.php
  45. drwxr-xr-x. 2 root root 27 11月 11 14:03 icons
  46. lrwxrwxrwx. 1 root root 18 11月 11 14:03 img -> ../../doc/HTML/img
  47. -rw-r--r--. 1 root root 6472 11月 11 14:19 index.php
  48. drwxr-xr-x. 5 root root 64 11月 11 14:19 install
  49. drwxr-xr-x. 2 root root 23 11月 11 14:19 m
  50. -rw-r--r--. 1 root root 1025 11月 11 14:19 member.php
  51. -rw-r--r--. 1 root root 2435 11月 11 14:19 misc.php
  52. -rw-r--r--. 1 root root 368 6月 8 00:28 nginx-logo.png
  53. -rw-r--r--. 1 root root 1788 11月 11 14:19 plugin.php
  54. -rw-r--r--. 1 root root 977 11月 11 14:19 portal.php
  55. lrwxrwxrwx. 1 root root 14 11月 11 14:03 poweredby.png -> nginx-logo.png
  56. -rw-r--r--. 1 root root 582 11月 11 14:19 robots.txt
  57. -rw-r--r--. 1 root root 1155 11月 11 14:19 search.php
  58. drwxr-xr-x. 10 root root 168 11月 11 14:19 source
  59. drwxr-xr-x. 7 root root 86 11月 11 14:19 static
  60. drwxr-xr-x. 3 root root 38 11月 11 14:19 template
  61. drwxr-xr-x. 7 root root 106 11月 11 14:19 uc_client
  62. drwxr-xr-x. 13 root root 241 11月 11 14:19 uc_server
  63. # 为网页数据设置权限,并设置selinux,否则会出现网站数据目录不可读。
  64. [root@server ~]# chown -R nginx:nginx /usr/share/nginx/html/
  65. [root@server ~]# chmod -R 777 /usr/share/nginx/html/
  66. [root@server ~]# setenforce 0
  67. [root@server ~]# getenforce
  68. Permissive

②安装discuz论坛:
输入网址http://192.168.80.128/install/
在这里插入图片描述
点击“我同意”:
在这里插入图片描述
全部都是正确,然后点击“下一步”:
在这里插入图片描述
输入之前创建的discuz数据库信息:
在这里插入图片描述
点击”下一步“,开始安装,安装好如下:
在这里插入图片描述
③登录discuz论坛:
输入网址http://192.168.80.128/
在这里插入图片描述
输入管理员admin的账号密码:
在这里插入图片描述
可以看到,已经登录成功了。
在这里插入图片描述
拓展:Discuz论坛主要是由php页面构成,如需做负载均衡,可以考虑使用apache做后端服务器。若程序主要由jsp页面构成,可以考虑使用tomcat做后端服务器。有兴趣的同学可以构建下nginx+apache架构实现负载均衡。

发表评论

表情:
评论列表 (有 0 条评论,338人围观)

还没有评论,来说两句吧...

相关阅读