LAMP架构+Discuz应用部署

 文章在linux上搭建LAMP架构,此基础上部署Discuz社区论坛应用。

一、架构

  • Linux:Centos操作系统。
  • Apache(httpd):Web 服务器。
  • Mysql:MariaDB数据库服务器。
  • PHP:php编程语言运行环境。
  • Discuz:一套通用的社区论坛软件系统。下载地址:https://www.discuz.vip/download.html

二、软硬件环境

节点

功能

硬件

操作系统

IP

软件

Web Server

LAMP+Discuz

VMware虚拟机2vcpu、2g内存

CentOS7.9

192.168.80.10/24

CentOS7.9安装光盘自带的Apache(httpd 2.4.6)、mariadb(5.5.68)和PHP(5.4.16);

Discuz_X3.4_SC_UTF8_20220518

Client

客户端浏览器

宿主机或虚拟机

任意

192.168.80.x/24

浏览器

三、实施

1、Web Server基础环境配置

  • 设置ip

#Centos初始的ip设置

#设置ip地址为:192.168.80.10

#注:如果要上网,则把网关设置为虚拟机NAT的网关,该ip可以上网

#使用SSH工具远程连接Centos

  • 设置计算机名

[root@localhost ~]# hostnamectl set-hostname web

[root@localhost ~]# bash

bash

[root@web ~]#

  • 关闭防火墙

[root@web ~]# systemctl stop firewalld && systemctl disable firewalld

Removed symlink /etc/systemd/system/multi-user.target.wants/firewalld.service.

Removed symlink /etc/systemd/system/dbus-org.fedoraproject.FirewallD1.service.

  • 关闭selinux

#查看selinux

[root@web ~]# getenforce

Enforcing

#临时关闭selinux

[root@web ~]# setenforce 0

[root@web ~]# getenforce

Permissive

#永久关闭selinux

[root@web ~]# vi /etc/selinux/config

# This file controls the state of SELinux on the system.

# SELINUX= can take one of these three values:

#     enforcing - SELinux security policy is enforced.

#     permissive - SELinux prints warnings instead of enforcing.

#     disabled - No SELinux policy is loaded.

SELINUX=disabled

# SELINUXTYPE= can take one of three values:

#     targeted - Targeted processes are protected,

#     minimum - Modification of targeted policy. Only selected processes are protected.

#     mls - Multi Level Security protection.

SELINUXTYPE=targeted

  • 设置yum安装源

#创建两个文件夹,一个用于保存原系统yum源,另一个用于挂载光盘

[root@web ~]# mkdir /opt/yum /opt/centos

[root@web ~]# mv /etc/yum.repos.d/* /opt/yum

#虚拟机连接CentOS ISO镜像;挂载光盘

[root@web ~]# mount /dev/sr0 /opt/centos

mount: /dev/sr0 is write-protected, mounting read-only

[root@web ~]# ll /opt/centos

total 696

-rw-r--r--.  3 root root     14 Oct 30  2020 CentOS_BuildTag

drwxr-xr-x.  3 root root   2048 Oct 27  2020 EFI

-rw-rw-r--. 21 root root    227 Aug 30  2017 EULA

-rw-rw-r--. 21 root root  18009 Dec 10  2015 GPL

drwxr-xr-x.  3 root root   2048 Oct 27  2020 images

drwxr-xr-x.  2 root root   2048 Nov  3  2020 isolinux

drwxr-xr-x.  2 root root   2048 Oct 27  2020 LiveOS

drwxr-xr-x.  2 root root 673792 Nov  4  2020 Packages

drwxr-xr-x.  2 root root   4096 Nov  4  2020 repodata

-rw-rw-r--. 21 root root   1690 Dec 10  2015 RPM-GPG-KEY-CentOS-7

-rw-rw-r--. 21 root root   1690 Dec 10  2015 RPM-GPG-KEY-CentOS-Testing-7

-r--r--r--.  1 root root   2883 Nov  4  2020 TRANS.TBL

#配置本地yum源

[root@web ~]# vi /etc/yum.repos.d/local.repo

[centos]

name=centos

baseurl=file:///opt/centos

gpgcheck=0

enabled=1

~

~

"/etc/yum.repos.d/local.repo" [New] 6L, 70C written

#清理yum源缓存

[root@web ~]# yum clean all

Loaded plugins: fastestmirror

Cleaning repos: centos

#列出新的yum源

[root@web ~]# yum repolist

Loaded plugins: fastestmirror

Determining fastest mirrors

centos                                                                                                                                | 3.6 kB  00:00:00    

(1/2): centos/group_gz                                                                                                                | 153 kB  00:00:00    

(2/2): centos/primary_db                                                                                                              | 3.3 MB  00:00:00    

repo id                                                                     repo name                                                                  status

centos                                                                      centos                                                                     4,070

repolist: 4,070

2、Apache web服务器部署

#安装httpd

[root@web ~]# yum install -y httpd

Loaded plugins: fastestmirror

Loading mirror speeds from cached hostfile

Resolving Dependencies

--> Running transaction check

---> Package httpd.x86_64 0:2.4.6-95.el7.centos will be installed

。。。。。                                                                                         

Installed:

  httpd.x86_64 0:2.4.6-95.el7.centos                                                                                                                        

Dependency Installed:

  apr.x86_64 0:1.4.8-7.el7        apr-util.x86_64 0:1.5.2-6.el7        httpd-tools.x86_64 0:2.4.6-95.el7.centos        mailcap.noarch 0:2.1.41-2.el7      

Complete!

#查看安装的httpd rpm包详细信息

[root@web ~]# rpm -qi httpd

Name        : httpd

Version     : 2.4.6

Release     : 95.el7.centos

Architecture: x86_64

Install Date: Sun 21 Aug 2022 08:37:35 PM CST

Group       : System Environment/Daemons

Size        : 9821056

License     : ASL 2.0

Signature   : RSA/SHA256, Thu 15 Oct 2020 02:50:46 AM CST, Key ID 24c6a8a7f4a80eb5

Source RPM  : httpd-2.4.6-95.el7.centos.src.rpm

Build Date  : Fri 02 Oct 2020 12:56:36 AM CST

Build Host  : x86-01.bsys.centos.org

Relocations : (not relocatable)

Packager    : CentOS BuildSystem <http://bugs.centos.org>

Vendor      : CentOS

URL         : Welcome! - The Apache HTTP Server Project

Summary     : Apache HTTP Server

Description :

The Apache HTTP Server is a powerful, efficient, and extensible

web server.

#启动httpd服务并设置开机自启

[root@web ~]# systemctl start httpd && systemctl enable httpd

Created symlink from /etc/systemd/system/multi-user.target.wants/httpd.service to /usr/lib/systemd/system/httpd.service.

#测试apache网站服务http://192.168.80.10

3、PHP安装

#安装php语言支持;php-mysql必需安装,用于php调用mysql

[root@web ~]# yum install -y php php-mysql

Loaded plugins: fastestmirror

Loading mirror speeds from cached hostfile

Resolving Dependencies

--> Running transaction check

---> Package php.x86_64 0:5.4.16-48.el7 will be installed

。。。。。                                                                                                             

Installed:

  php.x86_64 0:5.4.16-48.el7                                                 php-mysql.x86_64 0:5.4.16-48.el7                                               

Dependency Installed:

  libzip.x86_64 0:0.10.1-8.el7        php-cli.x86_64 0:5.4.16-48.el7        php-common.x86_64 0:5.4.16-48.el7        php-pdo.x86_64 0:5.4.16-48.el7      

Complete!

[root@web ~]# rpm -qi php

Name        : php

Version     : 5.4.16

Release     : 48.el7

Architecture: x86_64

Install Date: Sun 21 Aug 2022 08:42:45 PM CST

Group       : Development/Languages

Size        : 4596198

License     : PHP and Zend and BSD

Signature   : RSA/SHA256, Sat 04 Apr 2020 05:04:52 AM CST, Key ID 24c6a8a7f4a80eb5

Source RPM  : php-5.4.16-48.el7.src.rpm

Build Date  : Wed 01 Apr 2020 12:18:10 PM CST

Build Host  : x86-01.bsys.centos.org

Relocations : (not relocatable)

Packager    : CentOS BuildSystem <http://bugs.centos.org>

Vendor      : CentOS

URL         : PHP: Hypertext Preprocessor

Summary     : PHP scripting language for creating dynamic web sites

Description :

PHP is an HTML-embedded scripting language. PHP attempts to make it

easy for developers to write dynamically generated web pages. PHP also

offers built-in database integration for several commercial and

non-commercial database management systems, so writing a

database-enabled webpage with PHP is fairly simple. The most common

use of PHP coding is probably as a replacement for CGI scripts.

The php package contains the module (often referred to as mod_php)

which adds support for the PHP language to Apache HTTP Server.

#需要重启httpd后,php的安装才生效

[root@web ~]# systemctl restart httpd

#httpd的根目录在/var/www/html/;创建php测试页

[root@web ~]# echo "<?php phpinfo()?>" >/var/www/html/phpinfo.php

#测试php

4、Mariadb数据库引擎部署

#安装mariadb server

[root@web ~]# yum install -y mariadb mariadb-server

Loaded plugins: fastestmirror

Loading mirror speeds from cached hostfile

Resolving Dependencies

--> Running transaction check

---> Package mariadb.x86_64 1:5.5.68-1.el7 will be installed

--> Processing Dependency: perl(Sys::Hostname) for package: 1:mariadb-5.5.68-1.el7.x86_64

。。。。。

Installed:

  mariadb.x86_64 1:5.5.68-1.el7                                             mariadb-server.x86_64 1:5.5.68-1.el7                                           

Dependency Installed:

  perl.x86_64 4:5.16.3-297.el7                       perl-Carp.noarch 0:1.26-244.el7                     perl-Compress-Raw-Bzip2.x86_64 0:2.061-3.el7      

  perl-Compress-Raw-Zlib.x86_64 1:2.061-4.el7        perl-DBD-MySQL.x86_64 0:4.023-6.el7                 perl-DBI.x86_64 0:1.627-4.el7                     

  perl-Data-Dumper.x86_64 0:2.145-3.el7              perl-Encode.x86_64 0:2.51-7.el7                     perl-Exporter.noarch 0:5.68-3.el7                 

  perl-File-Path.noarch 0:2.09-2.el7                 perl-File-Temp.noarch 0:0.23.01-3.el7               perl-Filter.x86_64 0:1.49-3.el7                   

  perl-Getopt-Long.noarch 0:2.40-3.el7               perl-HTTP-Tiny.noarch 0:0.033-3.el7                 perl-IO-Compress.noarch 0:2.061-2.el7             

  perl-Net-Daemon.noarch 0:0.48-5.el7                perl-PathTools.x86_64 0:3.40-5.el7                  perl-PlRPC.noarch 0:0.2020-14.el7                 

  perl-Pod-Escapes.noarch 1:1.04-297.el7             perl-Pod-Perldoc.noarch 0:3.20-4.el7                perl-Pod-Simple.noarch 1:3.28-4.el7               

  perl-Pod-Usage.noarch 0:1.63-3.el7                 perl-Scalar-List-Utils.x86_64 0:1.27-248.el7        perl-Socket.x86_64 0:2.010-5.el7                  

  perl-Storable.x86_64 0:2.45-3.el7                  perl-Text-ParseWords.noarch 0:3.29-4.el7            perl-Time-HiRes.x86_64 4:1.9725-3.el7             

  perl-Time-Local.noarch 0:1.2300-2.el7              perl-constant.noarch 0:1.27-2.el7                   perl-libs.x86_64 4:5.16.3-297.el7                 

  perl-macros.x86_64 4:5.16.3-297.el7                perl-parent.noarch 1:0.225-244.el7                  perl-podlators.noarch 0:2.5.1-3.el7               

  perl-threads.x86_64 0:1.87-4.el7                   perl-threads-shared.x86_64 0:1.43-6.el7           

Complete!

Complete!

#启动mariadb服务,并且开机自启

[root@web ~]# systemctl start mariadb && systemctl enable mariadb

Created symlink from /etc/systemd/system/multi-user.target.wants/mariadb.service to /usr/lib/systemd/system/mariadb.service.

#mariadb初始密码为空,以下命令设置root密码

[root@web ~]# mysqladmin -uroot password "000000"

#登录数据库引擎

[root@web ~]# mysql -uroot -p000000

Welcome to the MariaDB monitor.  Commands end with ; or \g.

Your MariaDB connection id is 3

Server version: 5.5.68-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)]> show databases;

+--------------------+

| Database           |

+--------------------+

| information_schema |

| mysql              |

| performance_schema |

| test               |

+--------------------+

4 rows in set (0.00 sec)

MariaDB [(none)]> exit

Bye

至此,LAMP架构部署完成!

5、Discuz论坛部署

#下载discuz并把其上传到Centos上

[root@web ~]# ll

total 11688

-rw-------. 1 root root     1646 Mar 26 13:10 anaconda-ks.cfg

-rw-r--r--. 1 root root 11962143 Aug 20 17:35 Discuz_X3.4_SC_UTF8_20220518.zip

#安装unzip解压软件

[root@web ~]# yum install -y unzip

Loaded plugins: fastestmirror

Loading mirror speeds from cached hostfile

Resolving Dependencies

--> Running transaction check

---> Package unzip.x86_64 0:6.0-21.el7 will be installed

--> Finished Dependency Resolution

Dependencies Resolved

=============================================================================================================================================================

 Package                            Arch                                Version                                    Repository                           Size

=============================================================================================================================================================

Installing:

 unzip                              x86_64                              6.0-21.el7                                 centos                              171 k

Transaction Summary

=============================================================================================================================================================

Install  1 Package

Total download size: 171 k

Installed size: 365 k

Downloading packages:

Running transaction check

Running transaction test

Transaction test succeeded

Running transaction

  Installing : unzip-6.0-21.el7.x86_64                                                                                                                   1/1

  Verifying  : unzip-6.0-21.el7.x86_64                                                                                                                   1/1

Installed:

  unzip.x86_64 0:6.0-21.el7                                                                                                                                 

Complete!

#解压代码到discuz目录

[root@web ~]# unzip Discuz_X3.4_SC_UTF8_20220518.zip -d discuz

。。。。。。

[root@web ~]# ll discuz/

total 120

-rw-r--r--.  1 root root  8310 May 18 15:15 LICENSE

-rw-r--r--.  1 root root 26774 Sep 22  2021 qqqun.png

drwxr-xr-x.  2 root root   124 May 20 13:20 readme

-rw-r--r--.  1 root root 71393 Jan 31  2022 readme.html

drwxr-xr-x. 13 root root  4096 May 20 13:20 upload

-rw-r--r--.  1 root root   142 Jan 29  2022 utility.html

#把论坛源码复制到网站根目录

[root@web ~]# cp -rf discuz/upload/* /var/www/html/

[root@web ~]# ll /var/www/html/

total 72

-rw-r--r--.  1 root root 2848 Aug 21 21:10 admin.php

drwxr-xr-x.  9 root root  135 Aug 21 21:10 api

-rw-r--r--.  1 root root  727 Aug 21 21:10 api.php

drwxr-xr-x.  2 root root   23 Aug 21 21:10 archiver

drwxr-xr-x.  2 root root   90 Aug 21 21:10 config

-rw-r--r--.  1 root root 1040 Aug 21 21:10 connect.php

-rw-r--r--.  1 root root  106 Aug 21 21:10 crossdomain.xml

drwxr-xr-x. 12 root root  178 Aug 21 21:10 data

-rw-r--r--.  1 root root 5558 Aug 21 21:10 favicon.ico

-rw-r--r--.  1 root root 2245 Aug 21 21:10 forum.php

-rw-r--r--.  1 root root  821 Aug 21 21:10 group.php

-rw-r--r--.  1 root root 1280 Aug 21 21:10 home.php

-rw-r--r--.  1 root root 6655 Aug 21 21:10 index.php

drwxr-xr-x.  5 root root   64 Aug 21 21:10 install

drwxr-xr-x.  2 root root   23 Aug 21 21:10 m

-rw-r--r--.  1 root root  998 Aug 21 21:10 member.php

-rw-r--r--.  1 root root 2371 Aug 21 21:10 misc.php

-rw-r--r--.  1 root root   18 Aug 21 20:44 phpinfo.php

-rw-r--r--.  1 root root 1788 Aug 21 21:10 plugin.php

-rw-r--r--.  1 root root  977 Aug 21 21:10 portal.php

-rw-r--r--.  1 root root  615 Aug 21 21:10 robots.txt

-rw-r--r--.  1 root root 1274 Aug 21 21:10 search.php

drwxr-xr-x. 10 root root  168 Aug 21 21:10 source

drwxr-xr-x.  7 root root   86 Aug 21 21:10 static

drwxr-xr-x.  3 root root   38 Aug 21 21:10 template

drwxr-xr-x.  7 root root  106 Aug 21 21:10 uc_client

drwxr-xr-x. 13 root root  241 Aug 21 21:10 uc_server

#界面安装Discuz,地址为:http://192.168.80.10

#出现目录不存在或不可写错误

#把网站根目录的文件和目录设置为可写

[root@web ~]# chmod 777 -R /var/www/html/*

[root@web ~]# ll /var/www/html/

total 72

-rwxrwxrwx.  1 root root 2848 Aug 21 21:10 admin.php

drwxrwxrwx.  9 root root  135 Aug 21 21:10 api

-rwxrwxrwx.  1 root root  727 Aug 21 21:10 api.php

drwxrwxrwx.  2 root root   23 Aug 21 21:10 archiver

drwxrwxrwx.  2 root root   90 Aug 21 21:12 config

-rwxrwxrwx.  1 root root 1040 Aug 21 21:10 connect.php

-rwxrwxrwx.  1 root root  106 Aug 21 21:10 crossdomain.xml

drwxrwxrwx. 12 root root  178 Aug 21 21:12 data

-rwxrwxrwx.  1 root root 5558 Aug 21 21:10 favicon.ico

-rwxrwxrwx.  1 root root 2245 Aug 21 21:10 forum.php

-rwxrwxrwx.  1 root root  821 Aug 21 21:10 group.php

-rwxrwxrwx.  1 root root 1280 Aug 21 21:10 home.php

-rwxrwxrwx.  1 root root 6655 Aug 21 21:10 index.php

drwxrwxrwx.  5 root root   64 Aug 21 21:10 install

drwxrwxrwx.  2 root root   23 Aug 21 21:10 m

-rwxrwxrwx.  1 root root  998 Aug 21 21:10 member.php

-rwxrwxrwx.  1 root root 2371 Aug 21 21:10 misc.php

-rwxrwxrwx.  1 root root   18 Aug 21 20:44 phpinfo.php

-rwxrwxrwx.  1 root root 1788 Aug 21 21:10 plugin.php

-rwxrwxrwx.  1 root root  977 Aug 21 21:10 portal.php

-rwxrwxrwx.  1 root root  615 Aug 21 21:10 robots.txt

-rwxrwxrwx.  1 root root 1274 Aug 21 21:10 search.php

drwxrwxrwx. 10 root root  168 Aug 21 21:10 source

drwxrwxrwx.  7 root root   86 Aug 21 21:10 static

drwxrwxrwx.  3 root root   38 Aug 21 21:10 template

drwxrwxrwx.  7 root root  106 Aug 21 21:10 uc_client

drwxrwxrwx. 13 root root  241 Aug 21 21:10 uc_server

#刷新网页,再次检查安装环境

#填入本地数据库的用户名和密码,并创建后台管理员密码

#安装成功

论坛应用安装完成!

 

  • 8
    点赞
  • 6
    收藏
    觉得还不错? 一键收藏
  • 3
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值