小白一個小時快速在CentOS6.9搭建Discuz

小白一個小時快速在CentOS6.9搭建Discuz

搭建Discuz!論壇


1、瞭解PHP環境的搭建

2、掌握基礎Discuz!搭建與安裝

3、瞭解騰訊雲服務器的選購注意事項


第一步:購買學習用的騰訊雲服務器

地址:https://url.cn/5ZUrU1J

1、選擇服務器系統 CentOS 6.9


小白一個小時快速在CentOS6.9搭建Discuz

第二步:配置 Nginx 環境安裝


1、使用 yum 安裝 nginx :


yum intsall nginx -y


2、啟動並驗證 Nginx

nginx ---- 啟動 nginx 代理服務器,並通過公網IP驗證安裝

小白一個小時快速在CentOS6.9搭建Discuz

第三步:mysql 環境安裝與配置

1、安裝 mysql-server

yum install mysql-server -y


2、啟動 mysqld

service mysqld restart ----注意:是使用 mysqld 啟動

3、設置密碼

/usr/bin.mysqladmin -u root password 123456 ‘設置自己的密碼’

4、設置開機啟動

chkconfig mysqld on

小白一個小時快速在CentOS6.9搭建Discuz

第四步:PHP 環境安裝與配置


1、安裝 PHP

yum instal php-fpm php-mysql -y


2、啟動 php-fpm

service php-fpm start


3、查看進程

netstat -nlpt|grep php-fpm 查看 php-fpm 監聽的端口為:9000


tcp 0 0 127.0.0.1:9000 0.0.0.0:* LISTEN 7557/php-fpm


4、設置開機啟動

chkconfig php-fpm on


第五步:修改 Nginx 的配置文件

1、修改 nginx 配置

vim /etc/nginx/conf.d/default.conf 進入 default.conf 進行修改

--------------原代碼---------------

server {

listen 80 default_server;

listen [::]:80 default_server; #註釋掉此行

server_name _;

root /usr/share/nginx/html;


# Load configuration files for the default server block.

include /etc/nginx/default.d/*.conf;


location / {

}


error_page 404 /404.html;

location = /40x.html {

}


error_page 500 502 503 504 /50x.html;

location = /50x.html {

}


}


-----------修改後的代碼 -----------

server {

listen 80 default_server;

#listen [::]:80 default_server;

server_name _;

root /usr/share/nginx/html;


# Load configuration files for the default server block.

include /etc/nginx/default.d/*.conf;


location / {

}


error_page 404 /404.html;

location = /40x.html {

}


error_page 500 502 503 504 /50x.html;

location = /50x.html {

}


}


2、查看 /usr/share/nginx/html 路徑有什麼文件?

cd /usr/share/nginx/html

ls

顯示文件如下:

50x.html index.html nginx-logo.png poweredby.png

rm index.html ---- 除掉這個 index.html 文件

第六步:下載Discuz!論壇


1、使用 wget 下載 Discuz!壓縮包在/usr/share/nginx/html 目錄下

Discuz_X3.4 去官方 查找下載地址:https://www.discuz.net/thread-3847642-1-1.html


2、Discuz_X3.4_SC_UTF8【20191201】上傳到 /usr/share/nginx/html 目錄下 進行解壓。

unzip Discuz_X3.4_SC_UTF8??20191201??.zip


3、把 upload 目錄下的所有文件移到 /usr/share/nginx/html 目錄下。

mv upload/* ./

4、查看/usr/share/nginx/html 目錄下是否移動過來了。

ls


第七步:再次修改 nginx 配置,增加fastcgi 配置項,把 nginx 請求轉發給 PHP-FPM 。


1、vim 修改 default.conf 配置文件

vim /etc/nginx/conf.d/default.conf


2、增加fastcgi 配置項,把 nginx 請求轉發給 PHP-FPM

-----修改的代碼-------

server {

listen 80 default_server;

#listen [::]:80 default_server;

server_name _;

root /usr/share/nginx/html;


# Load configuration files for the default server block.

include /etc/nginx/default.d/*.conf;


location / {

index index.php index.html;

}


error_page 404 /404.html;

location = /40x.html {

}


error_page 500 502 503 504 /50x.html;

location = /50x.html {

}

# pass the PHP>

location ~ .php$ {

fastcgi_pass 127.0.0.1:9000;

fastcgi_index index.php;

fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;

include fastcgi_params;

}

}


3、重啟 nginx 服務

nginx -s reload


小白一個小時快速在CentOS6.9搭建Discuz

第八步:安裝 Discuz!論壇設置 與 mysql 配置


1、使用服務器公網IP 在瀏覽中打開Discuz!論壇安裝


2、設置Discuz!論壇在服務器路徑中的目錄權限,把uc_dient 文件的重 命名改為 uc_client (下載到桌面修改),再上傳回去進行設置它的權 限。


3、登陸 mysql 數據庫設置Discuz!論壇的數據庫

mysql -uroot -p ----返回服務器終端輸入命令登陸mysql

password:123456 ----輸入之前在服務器配置的mysql登陸 密碼

CREATE DATABASE wordpress; ---- 創建一個 wordpress

show databases; ---- 查詢數據庫列表


4、轉到瀏覽器填寫數據名 wordpress,root,密碼 等相關信息


分享到:


相關文章: