Nginx搭建Discuz論壇

        Discuz是一套通用的社區論壇軟件系統,用戶可以在不需要任何編程的基礎上,通過簡單的設置和安裝,在互聯網上搭建起具備完善功能、很強負載能力和可高度定製的論壇服務。今天我們就使用redhat7.2的鏡像在Linux上使用LNMP環境搭建一個簡單的Discuz論壇~

        前幾篇我們有說到LNMP的環境搭建,現在吶~我們就i開始搭建一個Discuz論壇叭~

        首先我們準備Discuz安裝包,此處附上大佬的網盤永久連接:https://pan.baidu.com/s/14ZPFy35pnpYpKeePDFoArw 密碼:2olg

1、指定安裝包目錄並解壓

[root@localhost local]# unzip Discuz_X3.3_SC_UTF8.zip

[root@localhost local]# mv upload/ /var/www/

2、編輯nginx配置文件

[root@localhost local]# vi /usr/local/nginx/conf/nginx.conf

[root@localhost local]# cat /usr/local/nginx/conf/nginx.conf

user  ruready ruready;
worker_processes  2;
 
error_log  /usr/local/nginx/logs/error.log crit; # 日誌位置和日誌級別
pid        /usr/local/nginx/logs/nginx.pid;
 
#Specifies the value for maximum file descriptors that can be opened by this process.
worker_rlimit_nofile 65535;
events {
    use epoll;
    worker_connections  65535;
}
 
 
http {
    include      mime.types;
    default_type  application/octet-stream;
 
    log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
                      '$status $body_bytes_sent "$http_referer" '
                      '"$http_user_agent" "$http_x_forwarded_for"';
 
    access_log  /usr/local/nginx/logs/access.log  main;
 
    sendfile        on;
    tcp_nopush    on;
 
    keepalive_timeout  60;
 
    gzip  on;
    gzip_min_length 1k;
    gzip_buffers 4 16k;
    gzip_http_version 1.0;
    gzip_comp_level 2;
    gzip_types text/plain application/x-javascript text/css application/xml;
    gzip_vary on;
 
    # 下面是server虛擬主機的配置
    server {
        listen      80;#監聽端口
        server_name  localhost;#域名
 
        charset utf-8;
 
        access_log  /usr/local/nginx/logs/host.access.log  main;
########將root後面的html換成了指定的目錄/var/www 
        location / {
            root  /var/www;
            index  index.html index.htm index.php;
	    expires 1d;
        }
 
        error_page  404              /404.html;
 
        # redirect server error pages to the static page /50x.html
 
        error_page  500 502 503 504  /50x.html;
        location = /50x.html {
            root  html;
        }
 
        # proxy the PHP scripts to Apache listening on 127.0.0.1:80
 
        #location ~ \.php$ {
        #    proxy_pass  http://127.0.0.1;
        #}
 
        # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
 #######將$document_root換成/var/www/
        location ~ \.php$ {
            root          html;
            fastcgi_pass  127.0.0.1:9000;
            fastcgi_index  index.php;
            fastcgi_param  SCRIPT_FILENAME  /var/www/$fastcgi_script_name;
            include        fastcgi_params;
        }
 
        # deny access to .htaccess files, if Apache's document root
        # concurs with nginx's one
        #
        #location ~ /\.ht {
        #    deny  all;
        #}
    }
 
 
    # another virtual host using mix of IP-, name-, and port-based configuration
    #
    #server {
    #    listen      8000;
    #    listen      somename:8080;
    #    server_name  somename  alias  another.alias;
 
    #    location / {
    #        root  html;
    #        index  index.html index.htm;
    #    }
    #}
 
 
    # HTTPS server
    #
    #server {
    #    listen      443 ssl;
    #    server_name  localhost;
 
    #    ssl_certificate      cert.pem;
    #    ssl_certificate_key  cert.key;
 
    #    ssl_session_cache    shared:SSL:1m;
    #    ssl_session_timeout  5m;
 
    #    ssl_ciphers  HIGH:!aNULL:!MD5;
    #    ssl_prefer_server_ciphers  on;
 
    #    location / {
    #        root  html;
    #        index  index.html index.htm;
    #    }
    #}
 
}

 3、創建指定目錄並授予權限

[root@localhost local]# mkdir /var/www -p

[root@localhost www]# cd upload/

[root@localhost upload]# chown -R php config data uc_client/data/ uc_server/data/

[root@localhost upload]# chmod -R 777 ../upload/

4、重啓nginx,在網頁中安裝

[root@localhost upload]# /usr/local/nginx/sbin/nginx -s reload

輸入網址如下網址:

 

 

 

 

 

 

 登錄時會一直停在這個界面導致我們進不去個人頁面,所以需要去修改文件:

[root@localhost upload]# vi source/class/class_core.php

註釋這幾行:

 

之後再刷新一下就進去了

        然後吶~就搭建完成啦。搭建的時候一定要注意配置文件的修改,當時忘記修改第一個location的root,就出現了路徑不存在的錯誤,細心細心再細心。

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章