從零開始 CentOs 7 搭建論壇BBS Discuz_X3.2

因爲公司項目須要一個互動平臺,能夠發起活動,發消息留言,討論事後發現這居然是一個論壇的功能。php

因而就不打算耗費功夫開發相關功能,直接另外搭一套BBS算球。。。html

 

一直以爲搭建BBS不是一件難事,目前有不少成熟的產品都支持直接建站,找了一些資料看了後發現仍是須要不少知識和架構的,下面是詳細的搭建過程mysql

從新安裝了一臺CentOs 7虛擬機,安裝過程資料不少,你們去搜索下linux


      系統配置相關

系統版本:CentOS-7-x86_64-Minimal-1503-01.isoweb

主機名: BBSsql

IP: 10.10.10.14   這是虛擬機自動分配shell

防火牆: firewall 已經關閉數據庫

關閉 SELINUXapache

 

下面列出建站須要的服務支持瀏覽器

1. Apache 服務

2. Mysql 安裝

3. Php 安裝

4. 服務配置

5. Discuz! 安裝


 

服務安裝


一、安裝 Apache

a、使用 yum 搜索相關軟件

[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

 

b、進行 httpd 軟件安裝

     yum install httpd.x86_64

系統就會開始安裝,這時下面會列舉不少 httpd 服務的依賴,直接 y 贊成安裝,這個安裝看網速,通常會很快

c、安裝成功後查看 httpd 狀態

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

    dead 說明服務沒有啓動,啓動這個服務:systemctl start httpd.service

[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..."

    Loaded-disabled不是隨機啓動狀態,這個須要修改:systemctl enable httpd.service

d、進行服務器相關配置,不少資料建議修改 Listen 端口爲 8080,默認是 80,其實不須要修改,若是有修改配置須要重啓服務。此處默認端口配置。

     vi /etc/httpd/conf/httpd.conf

#
# Listen: Allows you to bind Apache to specific IP addresses and/or
# ports, instead of the default. See also the <VirtualHost>
# directive.
#
# Change this to Listen on specific IP addresses as shown below to
# prevent Apache from glomming onto all bound IP addresses.
#
#Listen 12.34.56.78:80
Listen 80

 

e、測試咱們的服務器是否安裝完成,打開 IE,輸入本機 IP 加上端口號便可訪問服務器管理頁面 。

     本機是 10.10.10.14,因此個人地址爲:http://10.10.10.14/

     image

   

若是想要地址欄顯示爲網址形式的話,一樣能夠修改配置文件的數據項 ServerName,我設置成公司縮寫luoan,保存重啓服務生效。

#
# ServerName gives the name and port that the server uses to identify itself.
# This can often be determined automatically, but we recommend you specify
# it explicitly to prevent problems during startup.
#
# If your host doesn't have a registered DNS name, enter its IP address here.
#
ServerName bbs.luoan.com:80

 

image

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

這樣是否是更像那麼回事了,哈哈,對了,上面網址要瀏覽器能解析的話須要另外配置DNS服務器或者修改本地hosts,詳細後續會將搭建DNS服務器篇發佈出來。

OK,這下服務器就安裝完成了。

二、安裝 Mysql

進入系統搜索時才發現 CentOs 7 裏面的庫已經不支持 mysql 安裝了,因爲下載又要到官網很麻煩,就大概看了下庫裏面存在哪一種數據庫,通過查資料找到了一個叫 mariadb 的東西,聽說是 mysql 原班人馬出來另立的數據庫,因爲擔憂sun 會將 mysql 閉源什麼的,這都是好人啊

那就暫定用這個數據庫了

[root@bbs ~]# yum install MariaDB-server MariaDB-client
已加載插件:fastestmirror
Loading mirror speeds from cached hostfile
 * base: mirrors.163.com
 * extras: mirrors.163.com
 * updates: mirrors.163.com
軟件包 1:mariadb-5.5.44-1.el7_1.x86_64 已安裝而且是最新版本
軟件包 1:mariadb-libs-5.5.44-1.el7_1.x86_64 已安裝而且是最新版本
 
 

等待他一直安裝完成後就能夠啓動 mariadb 服務了。

[root@bbs ~]# systemctl start mariadb.service
[root@bbs ~]# systemctl enable mariadb.service

執行完這個命令下面就能夠直接使用 mysql 命令了,跟 mysql 操做徹底同樣,至於裏面細節就不去管他了,也用不到。

[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)

 

下面還要設置 mysql 的密碼權限,默認密碼爲空,此處新密碼設置爲 root

[root@bbs ~]# mysql_secure_installation
/usr/bin/mysql_secure_installation:行379: find_mysql_client: 未找到命令

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!

 

是否是so easy!!!

三、安裝 PHP

一樣的模式,先搜索一下看看存在哪些包

[root@bbs ~]# yum search php
已加載插件:fastestmirror
Loading mirror speeds from cached hostfile
 * base: mirrors.163.com
 * extras: mirrors.163.com
 * updates: mirrors.163.com
========================================================= N/S matched: php =========================================================
graphviz-php.x86_64 : PHP extension for graphviz
php.x86_64 : PHP scripting language for creating dynamic web sites
php-bcmath.x86_64 : A module for PHP applications for using the bcmath library
php-cli.x86_64 : Command-line interface for PHP
php-common.x86_64 : Common files for PHP
php-dba.x86_64 : A database abstraction layer module for PHP applications
php-devel.x86_64 : Files needed for building PHP extensions
php-embedded.x86_64 : PHP library for embedding in applications
php-enchant.x86_64 : Enchant spelling extension for PHP applications
php-fpm.x86_64 : PHP FastCGI Process Manager
php-gd.x86_64 : A module for PHP applications for using the gd graphics library
php-intl.x86_64 : Internationalization extension for PHP applications
php-ldap.x86_64 : A module for PHP applications that use LDAP
php-mbstring.x86_64 : A module for PHP applications which need multi-byte string handling
php-mysql.x86_64 : A module for PHP applications that use MySQL databases php-mysqlnd.x86_64 : A module for PHP applications that use MySQL databases
php-odbc.x86_64 : A module for PHP applications that use ODBC databases
php-pdo.x86_64 : A database access abstraction module for PHP applications
php-pear.noarch : PHP Extension and Application Repository framework
php-pgsql.x86_64 : A PostgreSQL database module for PHP
php-process.x86_64 : Modules for PHP script using system process interfaces
php-pspell.x86_64 : A module for PHP applications for using pspell interfaces
php-recode.x86_64 : A module for PHP applications for using the recode library
php-snmp.x86_64 : A module for PHP applications that query SNMP-managed devices
php-soap.x86_64 : A module for PHP applications that use the SOAP protocol
php-xml.x86_64 : A module for PHP applications which use XML
php-xmlrpc.x86_64 : A module for PHP applications which use the XML-RPC protocol
rrdtool-php.x86_64 : PHP RRDtool bindings
uuid-php.x86_64 : PHP support for Universally Unique Identifier library
php-pecl-memcache.x86_64 : Extension to work with the Memcached caching daemon

查看後面的一些註釋發現咱們可能須要這幾個包,不要問我爲何知道這些報須要裝,由於知道,因此知道,這是男人的直覺 額

固然你能夠選擇 yum –y php* 所有安裝,應該沒問題。

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

執行命令發現有衝突發現確實引用了兩個鏈接數據庫的包那就去掉一個。由於官方建議用後面一個包 mysqlnd。

[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

OK 安裝完成。

 

#重啓MariaDB:systemctl restart mariadb.service

#重啓apache:systemctl restart httpd.service

四、服務配置

a、編輯 Apache 服務器的配置文件

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

修改下面這些屬性

#修改容許.htaccess
AllowOverride All 
# 修改頁面支持屬性
DirectoryIndex index.html index.htm Default.html Default.htm index.php
# 新增支持 . pl 腳本
AddHandler cgi-script .cgi .pl

systemctl restart httpd.service #重啓apache

 

b、配置 php

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

修改下面參數:

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

# 新增禁用的函數,須要使用時再放開
; This directive allows you to disable certain functions for security reasons.
; It receives a comma-delimited list of function names. This directive is
; *NOT* affected by whether Safe Mode is turned On or Off.
; http://php.net/disable-functions
disable_functions = passthru,exec,system,chroot,scandir,chgrp,chown,shell_exec,proc_open,proc_get_status,ini_alter,ini_alter,ini_restore,dl,openlog,syslog,readlink,symlink,popepassthru,stream_socket_server,escapeshellcmd,dll,popen,disk_free_space,checkdnsrr,checkdnsrr,getservbyname,getservbyport,disk_total_space,posix_ctermid,posix_get_last_error,posix_getcwd,posix_getegid,posix_geteuid,posix_getgid,posix_getgrgid,posix_getgrnam,posix_getgroups,posix_getlogin,posix_getpgid,posix_getpgrp,posix_getpid,posix_getppid,posix_getpwnam,posix_getpwuid,posix_getrlimit,posix_getsid,posix_getuid,posix_isatty,posix_kill,posix_mkfifo,posix_setegid,posix_seteuid,posix_setgid,posix_setpgid,posix_setsid,posix_setuid,posix_strerror,posix_times,posix_ttyname,posix_uname

# 支持php短標籤
; short_open_tag
;   Default Value: On
;   Development Value: Off
;   Production Value: Off
short_open_tag = On

# 設置表示容許訪問當前目錄(即PHP腳本文件所在之目錄)和/tmp/目錄,能夠防止php木馬跨站,若是改了以後安裝程序有問題(例如:織夢內容管理系統),能夠註銷此行,或者直接寫上程序的目錄/data/www.osyunwei.com/:/tmp/
open_basedir = .:/tmp/

#重啓MariaDB:systemctl restart mariadb.service

#重啓apache:systemctl restart httpd.service

c、進行php頁面測試

[root@bbs html]# cd /var/www/html
[root@bbs html]# vi index.php

裏面的內容很簡單,可是我看到別人的教程仍是寫錯了,我也被坑了,出了個空白頁面  -  -

<?php
phpinfo();
?>

 

在客戶端瀏覽器輸入服務器IP地址,能夠看到以下圖所示相關的配置信息

image

五、安裝 discuz

a、這個程序系統沒有集成,須要本身下載,去官方論壇上找了個discuz3.2x的中文簡體版下載地址

產品介紹
Discuz! X3.2 在繼承和完善 Discuz! X3.1 的基礎上,針對社區移動端進行了新的嘗試。推出微信登陸、微社區等功能。安全穩定的程序爲站長提供更加可靠的保障。
下載地址
簡體中文GBK
http://download.comsenz.com/DiscuzX/3.2/Discuz_X3.2_SC_GBK.zip
繁體中文 BIG5
http://download.comsenz.com/DiscuzX/3.2/Discuz_X3.2_TC_BIG5.zip
簡體 UTF8
http://download.comsenz.com/DiscuzX/3.2/Discuz_X3.2_SC_UTF8.zip
繁體 UTF8
http://download.comsenz.com/DiscuzX/3.2/Discuz_X3.2_TC_UTF8.zip

 

下面咱們就直接使用 wget 下載下來安裝,若是沒有這個命令,使用 yum 安裝就好了,我下載的是GBK的包,若是出現亂碼請下載UTF8的。

[root@bbs download]# yum -y install wget
[root@bbs download]# wget http://download.comsenz.com/DiscuzX/3.2/Discuz_X3.2_SC_GBK.zip
--2015-11-06 17:45:41--  http://download.comsenz.com/DiscuzX/3.2/Discuz_X3.2_SC_GBK.zip
正在解析主機 download.comsenz.com (download.comsenz.com)... 101.227.130.115
正在鏈接 download.comsenz.com (download.comsenz.com)|101.227.130.115|:80... 已鏈接。
已發出 HTTP 請求,正在等待迴應... 200 OK
長度:12402802 (12M) [application/zip]
正在保存至: 「Discuz_X3.2_SC_GBK.zip」

100%[==========================================================================================>] 12,402,802  7.74MB/s 用時 1.5s   

2015-11-06 17:45:43 (7.74 MB/s) - 已保存 「Discuz_X3.2_SC_GBK.zip」 [12402802/12402802])

OK 下載完成。

直接解壓文件,因爲是個zip包 ,坑爹 linux 確定沒工具解,直接安裝 yum -y install unzip

[root@bbs download]# unzip Discuz_X3.2_SC_GBK.zip
[root@bbs download]# ls -l
總用量 12120
-rw-r--r--.  1 root root 12402802 6月   9 10:58 Discuz_X3.2_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

OK,解壓成功,出來了3個目錄。

 

b、將 upload 目錄轉移到web請求目錄下

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

c、進去upload給予幾個目錄權限訪問

[root@bbs download]# chown apache:apache -R ./upload 
[root@bbs upload]# chmod -R 777 config
[root@bbs upload]# chmod -R 777 data
[root@bbs upload]# chmod -R 777 uc_client
[root@bbs upload]# chmod -R 777 uc_server

d、打開瀏覽器開始安裝論壇,這一步網上都是說什麼站點的根目錄,而後域名加上 install 就能夠訪問了,我根本沒有站點,因此嘗試了好久未知因此然,找不到入口該是多蛋疼,蛋碎了

image

又去查看資料具體入口跳轉的php頁面,發現是 forum.php,這下簡單了,在upload 目錄下有這個頁面。直接訪問果真出來。看瀏覽器的解析結果分析,若是本身在根目錄下的一層文件夾須要添加在路徑上。

http://10.10.10.14/upload/forum.php

image

e、開始安裝論壇,點擊「我贊成」後,進去系統檢測頁面。若是一切提示OK,就繼續下一步,若是提示有錯誤,就先去解決,通常都是上面第【c】步讓你給文件權限的問題,既然上面都執行了 這裏通常不會報錯。一直下一步,下一步設置管理員密碼,就成功安裝了。

image

image

相關文章
相關標籤/搜索