CentOS搭建Discuz

感谢博客园木木木主,

---------------------------------------------------

系统版本:CentOS-7-x86_64-DVD-1708.iso

机器:ThinkPad R400,换了8GB内存和SSD硬盘

IP:192.168.50.153,宽带自动获取

关闭Selinux,这步很重要,不然你安装discuz的时候目录不可写

----------------------------------------------------

先关闭selinux

临时关闭selinux

可以用getenforce 查看SELinux的状态,如下(默认开启)

<code>[root@localhost ~]# getenforce

//开启状态
Enforcing

[root@localhost ~]# setenforce 0

[root@localhost ~]# getenforce

//开启状态
Permissive

/<code>

临时关闭,重启系统会重新打开,因此同时可以选择把selinux直接关闭。


<code>[root@localhost ~]# vim /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.

// 这里改变为permissive
SELINUX=permissive
# SELINUXTYPE= can take one of three two values:
# targeted - Targeted processes are protected,
# minimum - Modification of targeted policy. Only selected processes are protected.
# mls - Multi Level Security protection.
SELINUXTYPE=targeted

// 重启使配置生效
[root@localhost ~]# reboot

/<code>


-------------------------------------------------------------

1. Apache 服务

2. Mysql 安装

3. Php 安装

4. 服务配置

5. Discuz! 安装


1、安装 Apache

a、使用 yum 搜索相关软件

<code>[root@BBS ~]# yum search httpd
已加载插件:fastestmirror
Loading mirror speeds from cached hostfile
* base: mirrors.163.com
* extras: mirrors.163.com
* updates: mirrors.163.com
======================================================== N/S matched: httpd ========================================================

libmicrohttpd-devel.i686 : Development files for libmicrohttpd
libmicrohttpd-devel.x86_64 : Development files for libmicrohttpd
libmicrohttpd-doc.noarch : Documentation for libmicrohttpd
httpd.x86_64 : Apache HTTP Server
httpd-devel.x86_64 : Development interfaces for the Apache HTTP server
httpd-manual.noarch : Documentation for the Apache HTTP server
httpd-tools.x86_64 : Tools for use with the Apache HTTP Server
libmicrohttpd.i686 : Lightweight library for embedding a webserver in applications
libmicrohttpd.x86_64 : Lightweight library for embedding a webserver in applications
mod_auth_mellon.x86_64 : A SAML 2.0 authentication module for the Apache Httpd Server
mod_dav_svn.x86_64 : Apache httpd module for Subversion server/<code>

b、进行 httpd 软件安装

yum install httpd.x86_64

系统就会开始安装,这时下面会列举很多 httpd 服务的依赖,直接 y 同意安装,这个安装看网速,一般会很快

c、安装成功后查看 httpd 状态

<code>[root@BBS ~]# systemctl status httpd.service
httpd.service - The Apache HTTP Server
Loaded: loaded (/usr/lib/systemd/system/httpd.service; disabled)
Active: inactive (dead)/<code>

dead 说明服务没有启动,启动这个服务:systemctl start httpd.service

<code>[root@BBS ~]# systemctl status httpd.service
httpd.service - The Apache HTTP Server
Loaded: loaded (/usr/lib/systemd/system/httpd.service; disabled)
Active: active (running) since 四 2015-11-05 17:47:08 CST; 6s ago
Main PID: 19288 (httpd)
Status: "Processing requests..."/<code>

Loaded-disabled不是随机启动状态,这个需要修改:systemctl enable httpd.service

d、进行服务器相关配置,很多资料建议修改 Listen 端口为 8080,默认是 80,其实不需要修改,我没改。

e、测试我们的服务器是否安装完成,打开 IE,输入本机 IP 加上端口号即可访问服务器管理页面 。

本机是 192.168.50.153,所以我的地址为:http://192.168.50.153/

CentOS搭建Discuz_X3.2

2、安装 Mysql

不要问为什么装mariadb,装就对了,简单解释跟MySQL换个名而已。

<code>[root@bbs ~]# yum install mariadb-server/<code>
<code>已加载插件:fastestmirror
Loading mirror speeds from cached hostfile
* base: mirrors.163.com
* extras: mirrors.163.com
* updates: mirrors.163.com/<code>

等待他一直安装完成后就可以启动 mariadb 服务了。

<code>[root@bbs ~]# systemctl start mariadb.service
[root@bbs ~]# systemctl enable mariadb.service/<code>

执行完这个命令下面就可以直接使用 mysql 命令了,跟 mysql 操作完全一样。

<code>[root@bbs ~]# mysql
Welcome to the MariaDB monitor. Commands end with ; or \\g.
Your MariaDB connection id is 3
Server version: 5.5.44-MariaDB MariaDB Server

Copyright (c) 2000, 2015, 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)/<code>

下面还要设置 mysql 的密码权限,默认密码为空,此处新密码设置为 root

<code>[root@bbs ~]# 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] n
... skipping.

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!/<code>

3、安装 PHP

[root@bbs ~]# yum -y install php php-bcmath php-cli php-common php-gd php-ldap php-mbstring php-mysqlnd php-pear php-pdo php-xml php-xmlrpc


#重启MariaDB:systemctl restart mariadb.service

#重启apache:systemctl restart httpd.service

4、服务配置

a、编辑 Apache 服务器的配置文件

<code>[root@bbs ~]# vi /etc/httpd/conf/httpd.conf/<code>

修改下面这些属性

<code>#修改允许.htaccess
AllowOverride All
# 修改页面支持属性
DirectoryIndex index.html index.htm Default.html Default.htm index.php
# 新增支持 . pl 脚本
AddHandler cgi-script .cgi .pl
/<code>

systemctl restart httpd.service #重启apache

b、配置 php

<code>[root@bbs ~]# vi /etc/php.ini/<code>

修改下面参数:

<code># 改为 date.timezone = PRC
[Date]
; Defines the default timezone used by the date functions
; http://php.net/date.timezone
date.timezone = RPC

# 支持php短标签
; short_open_tag
; Default Value: On
; Development Value: Off
; Production Value: Off
short_open_tag = On
/<code>

#重启MariaDB:systemctl restart mariadb.service

#重启apache:systemctl restart httpd.service

c、进行php页面测试

<code>[root@bbs html]# cd /var/www/html
[root@bbs html]# vim index.php/<code>

里面的内容很简单 - -

<code>phpinfo();
?>/<code>

在客户端浏览器输入服务器IP地址,可以看到如下图所示相关的配置信息

CentOS搭建Discuz_X3.2

5、安装 discuz

a、Discuz! X3.4

下载地址:

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

这个站最坑的是得注册才能下载,我下载的是GBK版本。

CentOS搭建Discuz_X3.2

<code>[root@bbs download]# unzip Discuz_X3.4_SC_GBK.zip
[root@bbs download]# ls -l
总用量 12120
-rw-r--r--. 1 root root 12402802 6月 9 10:58 Discuz_X3.4_SC_GBK.zip
drwxr-xr-x. 2 root root 97 6月 9 10:21 readme
drwxr-xr-x. 12 root root 4096 6月 9 10:21 upload

drwxr-xr-x. 4 root root 68 6月 9 10:21 utility/<code>

b、将 upload 目录转移到web请求目录下

<code>[root@bbs download]# cp -R ./upload /var/www/html/<code>

c、给upload目录权限访问

<code>[root@bbs html]#chmod -R 777 ./upload//<code>

d、打开浏览器开始安装论坛,http://192.168.50.153/upload/forum.php

CentOS搭建Discuz_X3.2

e、开始安装论坛,点击“我同意”后,进去系统检测页面。如果一切提示OK,就继续下一步,如果提示有错误,就先去解决,一般都是上面第【c】步让你给文件权限的问题,既然上面都执行了 这里一般不会报错。一直下一步,下一步设置管理员密码,就成功安装了。

CentOS搭建Discuz_X3.2

CentOS搭建Discuz_X3.2


分享到:


相關文章: