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


分享到:


相關文章: