Linux之动态网页---搭建论坛

本文档详细介绍了如何在Linux环境中搭建LAMP(Linux, Apache, MariaDB, PHP)架构,包括安装Apache服务、配置虚拟主机、导入论坛包、安装数据库、解压论坛包、初始化数据库、安装PHP、以及进行权限调整和访问测试。通过这些步骤,成功创建了一个能够运行动态网页的服务器环境。
摘要由CSDN通过智能技术生成

动态网页基本框架

lamp
l-linux 平台
a-apache 服务应用程序
m-mariable 默认开源数据库
p-php 应用程序

第一步安装httpd服务

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

修改配置文件

[root@redhat ~]# vim /etc/httpd/conf.d/vhost.conf

打开文件添加如下

<VirtualHost 192.168.12.130:80>
       DocumentRoot /www/xiaopang/
       ServerName 192.168.12.130
</VirtualHost>

<Directory /www>
      AllowOverride none
      Require all granted
</Directory>

新建目录

[root@redhat ~]# mkdir /www/xiaopang

重启服务

[root@redhat conf.d]# systemctl restart httpd

关闭防火墙

[root@redhat upload]# systemctl stop firewalld

临时关闭selinux

[root@redhat upload]# setenforce 0

第二步得话就是导入我们Windows下的论坛包

后期加载网页信息php需要在我们得目录下加载,所以我们将论坛包导入我们的/www/xiaopang 目录下

导包方式:

  1. 使用Xftb工具
  2. 使用Xshell工具,直接使用rz命令
    如果虚拟机没有安装rz命令
    使用 yum -y install lrzsz下载

第三步解压论坛包

[root@redhat xiaopang]# unzip Discuz_X3.4_SC_UTF8_0101.zip

第四步安装数据库

[root@redhat xiaopang]# yum install mariadb-server -y
Updating Subscription Management repositories.
Unable to read consumer identity

This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register.

Repository epel is listed more than once in the configuration
Last metadata expiration check: 1:07:20 ago on Wed 18 Aug 2021 07:53:00 PM CST.
Dependencies resolved.
=======================================================================
 Package                    Arch   Version             Repo       Size
=======================================================================
Installing:
 mariadb-server             x86_64 3:10.3.28-1.module_el8.3.0+757+d382997d
                                                       AppStream  16 M
Installing dependencies:
 mariadb                    x86_64 3:10.3.28-1.module_el8.3.0+757+d382997d
                                                       AppStream 6.0 M
 mariadb-common             x86_64 3:10.3.28-1.module_el8.3.0+757+d382997d
                                                       AppStream  64 k
 mariadb-connector-c        x86_64 3.1.11-2.el8_3      AppStream 200 k
 mariadb-connector-c-config noarch 3.1.11-2.el8_3      AppStream  15 k
 mariadb-errmsg             x86_64 3:10.3.28-1.module_el8.3.0+757+d382997d
                                                       AppStream 234 k
 perl-DBD-MySQL             x86_64 4.046-3.module_el8.1.0+203+e45423dc
                                                       AppStream 156 k
Installing weak dependencies:
 mariadb-backup             x86_64 3:10.3.28-1.module_el8.3.0+757+d382997d
                                                       AppStream 6.1 M
 mariadb-gssapi-server      x86_64 3:10.3.28-1.module_el8.3.0+757+d382997d
                                                       AppStream  51 k
 mariadb-server-utils       x86_64 3:10.3.28-1.module_el8.3.0+757+d382997d
                                                       AppStream 1.1 M
Enabling module streams:
 mariadb                           10.3                               
 perl-DBD-MySQL                    4.046                              

Transaction Summary
=======================================================================
Install  10 Packages

Total download size: 30 M
Installed size: 153 M
Downloading Packages:
(1/10): mariadb-common-10.3.28-1.modul  32 kB/s |  64 kB     00:02    
(2/10): mariadb-connector-c-3.1.11-2.e 228 kB/s | 200 kB     00:00    
(3/10): mariadb-connector-c-config-3.1  22 kB/s |  15 kB     00:00    
(4/10): mariadb-10.3.28-1.module_el8.3 1.5 MB/s | 6.0 MB     00:03    
(5/10): mariadb-errmsg-10.3.28-1.modul 499 kB/s | 234 kB     00:00    
(6/10): mariadb-gssapi-server-10.3.28- 131 kB/s |  51 kB     00:00    
(7/10): mariadb-backup-10.3.28-1.modul 1.3 MB/s | 6.1 MB     00:04    
(8/10): perl-DBD-MySQL-4.046-3.module_ 1.1 MB/s | 156 kB     00:00    
(9/10): mariadb-server-utils-10.3.28-1 1.0 MB/s | 1.1 MB     00:01    
(10/10): mariadb-server-10.3.28-1.modu 3.7 MB/s |  16 MB     00:04    
-----------------------------------------------------------------------
Total                                  3.6 MB/s |  30 MB     00:08     
Running transaction check
Transaction check succeeded.
Running transaction test
Transaction test succeeded.
Running transaction
  Preparing        :                                               1/1 
  Installing       : mariadb-connector-c-config-3.1.11-2.el8_3    1/10 
  Installing       : mariadb-common-3:10.3.28-1.module_el8.3.0    2/10 
  Installing       : mariadb-errmsg-3:10.3.28-1.module_el8.3.0    3/10 
  Installing       : perl-DBD-MySQL-4.046-3.module_el8.1.0+203    4/10 
  Installing       : mariadb-connector-c-3.1.11-2.el8_3.x86_64    5/10 
  Installing       : mariadb-backup-3:10.3.28-1.module_el8.3.0    6/10 
  Installing       : mariadb-gssapi-server-3:10.3.28-1.module_    7/10 
  Installing       : mariadb-server-utils-3:10.3.28-1.module_e    8/10 
  Running scriptlet: mariadb-server-3:10.3.28-1.module_el8.3.0    9/10 
  Installing       : mariadb-server-3:10.3.28-1.module_el8.3.0    9/10 
  Running scriptlet: mariadb-server-3:10.3.28-1.module_el8.3.0    9/10 
  Installing       : mariadb-3:10.3.28-1.module_el8.3.0+757+d3   10/10 
  Running scriptlet: mariadb-3:10.3.28-1.module_el8.3.0+757+d3   10/10 
  Verifying        : mariadb-3:10.3.28-1.module_el8.3.0+757+d3    1/10 
  Verifying        : mariadb-backup-3:10.3.28-1.module_el8.3.0    2/10 
  Verifying        : mariadb-common-3:10.3.28-1.module_el8.3.0    3/10 
  Verifying        : mariadb-connector-c-3.1.11-2.el8_3.x86_64    4/10 
  Verifying        : mariadb-connector-c-config-3.1.11-2.el8_3    5/10 
  Verifying        : mariadb-errmsg-3:10.3.28-1.module_el8.3.0    6/10 
  Verifying        : mariadb-gssapi-server-3:10.3.28-1.module_    7/10 
  Verifying        : mariadb-server-3:10.3.28-1.module_el8.3.0    8/10 
  Verifying        : mariadb-server-utils-3:10.3.28-1.module_e    9/10 
  Verifying        : perl-DBD-MySQL-4.046-3.module_el8.1.0+203   10/10 
Installed products updated.

Installed:
  mariadb-3:10.3.28-1.module_el8.3.0+757+d382997d.x86_64               
  mariadb-backup-3:10.3.28-1.module_el8.3.0+757+d382997d.x86_64        
  mariadb-common-3:10.3.28-1.module_el8.3.0+757+d382997d.x86_64        
  mariadb-connector-c-3.1.11-2.el8_3.x86_64                            
  mariadb-connector-c-config-3.1.11-2.el8_3.noarch                     
  mariadb-errmsg-3:10.3.28-1.module_el8.3.0+757+d382997d.x86_64        
  mariadb-gssapi-server-3:10.3.28-1.module_el8.3.0+757+d382997d.x86_64 
  mariadb-server-3:10.3.28-1.module_el8.3.0+757+d382997d.x86_64        
  mariadb-server-utils-3:10.3.28-1.module_el8.3.0+757+d382997d.x86_64  
  perl-DBD-MySQL-4.046-3.module_el8.1.0+203+e45423dc.x86_64            

Complete!

重启服务

[root@redhat xiaopang]# systemctl restart mariadb

第五步初始化数据库

回车输入设置用户root密码(此root不是linux的root只是数据库的用户)
后续一直y或者n都可以

[root@redhat xiaopang]# mysql_secure_installation

NOTE: RUNNING ALL PARTS OF THIS SCRIPT IS RECOMMENDED FOR ALL MariaDB
      SERVERS IN PRODUCTION USE!  PLEASE READ EACH STEP CAREFULLY!

In order to log into MariaDB to secure it, we'll need the current
password for the root user.  If you've just installed MariaDB, and
you haven't set the root password yet, the password will be blank,
so you should just press enter here.

Enter current password for root (enter for none): 
OK, successfully used password, moving on...

Setting the root password ensures that nobody can log into the MariaDB
root user without the proper authorisation.

Set root password? [Y/n] y
New password: 
Re-enter new password: 
Password updated successfully!
Reloading privilege tables..
 ... Success!


By default, a MariaDB installation has an anonymous user, allowing anyone
to log into MariaDB without having to have a user account created for
them.  This is intended only for testing, and to make the installation
go a bit smoother.  You should remove them before moving into a
production environment.

Remove anonymous users? [Y/n] y
 ... Success!

Normally, root should only be allowed to connect from 'localhost'.  This
ensures that someone cannot guess at the root password from the network.

Disallow root login remotely? [Y/n] y
 ... Success!

By default, MariaDB comes with a database named 'test' that anyone can
access.  This is also intended only for testing, and should be removed
before moving into a production environment.

Remove test database and access to it? [Y/n] y
 - Dropping test database...
 ... Success!
 - Removing privileges on test database...
 ... Success!

Reloading the privilege tables will ensure that all changes made so far
will take effect immediately.

Reload privilege tables now? [Y/n] y
 ... Success!

Cleaning up...

All done!  If you've completed all of the above steps, your MariaDB
installation should now be secure.

Thanks for using MariaDB!

第六步登录数据库

[root@redhat xiaopang]# mysql -uroot -proot     //使用-uroot用户  -proot密码登录(注意:此root不是linux的root)
Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MariaDB connection id is 18
Server version: 10.3.28-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 |
+--------------------+
3 rows in set (0.000 sec)

MariaDB [(none)]> create database hxfluntan;    //新建数据库
Query OK, 1 row affected (0.000 sec)

MariaDB [(none)]> use hxfluntan;      //使用数据库
Database changed
MariaDB [hxfluntan]> show tables;     //查看表
Empty set (0.000 sec)

MariaDB [hxfluntan]> exit;       //退出
Bye

第七步下载应用程序php

[root@redhat xiaopang]# yum install php* -y

第八步安装向导

在浏览器中输入http://192.168.12.130/dir_SC_UTF8/upload/install/,因为加载页面在这个下面,然后点击我同意
在这里插入图片描述

可以看到下面有个提示,请将以上红叉部分修正再试,导致红叉的原因就是没有权限
在这里插入图片描述

解决红叉、修改权限

注意查看我的目录

[root@redhat upload]# chmod 777 uc_* config/ data/ -R

刷新页面,红叉消失,点击下一步
在这里插入图片描述

直接下一步
在这里插入图片描述

主要修改数据库名、管理员账号、管理员密码,完成点击下一步
在这里插入图片描述

开始安装
在这里插入图片描述

安装完成
在这里插入图片描述

因为数据已经下载匹配所以直接访问upload
在这里插入图片描述

论坛测试

管理员登录并发帖
在这里插入图片描述

优化访问方式

将ip访问改为域名访问
将DoucmentRoot 路径改到upload下
将配置文件里面的ServerName 改为域名

在这里插入图片描述

重启服务

[root@redhat upload]# systemctl restart httpd

修改C:\Windows\System32\drivers\etc下的hosts文件,将我们的IP对应域名写入文件中,
我是用nodepad++打开,因为修改文件需要权限

在这里插入图片描述

使用域名登录

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

一个F啊

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值