通過Nginx來安裝一個Discuz

這次由于時間有限,所以我就沒有用編譯安裝來啟動LMP,只有Nginx 是編譯安裝的
因為是在centos7上面安裝的Nginx所以我們這里由于能力有限,暫時不能將其加入開機啟動,日后我會進行改進,將其加入開機啟動。這里我們給出Nginxd的編譯選項及環境

 

yum groupinstall "Development Tools" "Server Platform Deveopment";
 yum install openssl-devel pcre-devel;
 groupadd -r nginx;
 useradd -r -g nginx nginx;

 ./configure \
  --prefix=/usr \
  --sbin-path=/usr/sbin/nginx \
  --conf-path=/etc/nginx/nginx.conf \
  --error-log-path=/var/log/nginx/error.log \
  --http-log-path=/var/log/nginx/access.log \
  --pid-path=/var/run/nginx/nginx.pid  \
  --lock-path=/var/lock/nginx.lock \
  --user=nginx \
  --group=nginx \
  --with-http_ssl_module \
  --with-http_flv_module \
  --with-http_stub_status_module \
  --with-http_gzip_static_module \
  --http-client-body-temp-path=/var/tmp/nginx/client/ \
  --http-proxy-temp-path=/var/tmp/nginx/proxy/ \
  --http-fastcgi-temp-path=/var/tmp/nginx/fcgi/ \
  --http-uwsgi-temp-path=/var/tmp/nginx/uwsgi \
  --http-scgi-temp-path=/var/tmp/nginx/scgi \
  --with-pcre    | tee /tmp/nginx.out            -->重定向至文件;
    make && make install;

  

二、配置Nginx vi /etc/nginx/nginx.conf

Nginx的代碼是由一個核心和一系列的模塊組成, 核心主要用于提供Web Server的基本功能,以及Web和Mail反向代理的功能;還用于啟用網絡協議,創建必要的運行時環境以及確保不同的模塊之間平滑地進行交互。不過,大多跟協議相關的功能和某應用特有的功能都是由nginx的模塊實現的。這些功能模塊大致可以分為事件模塊、階段性處理器、輸出過濾器、變量處理器、協議、upstream和負載均衡幾個類別,這些共同組成了nginx的http功能。事件模塊主要用于提供OS獨立的(不同操作系統的事件機制有所不同)事件通知機制如kqueue或epoll等。協議模塊則負責實現nginx通過http、tls/ssl、smtp、pop3以及imap與對應的客戶端建立會話。

Nginx的核心模塊為Main和Events,此外還包括標準HTTP模塊、可選HTTP模塊和郵件模塊,其還可以支持諸多第三方模塊。Main用于配置錯誤日志、進程及權限等相關的參數,Events用于配置IO模型,如epoll、kqueue、select或poll等,它們是必備模塊。

Nginx的主配置文件由幾個段組成,這個段通常也被稱為nginx的上下文,每個段的定義格式如下所示。需要注意的是,其每一個指令都必須使用分號(;)結束,否則為語法錯誤。
#main  配置段,無需加什么方括號,這里表明是其他幾個盤配置段的公用的配置,當然其他的配置段也可以自己在配置里重新定義;這樣就叫做上下文#定義用戶和用戶組;user  nginx nginx ;#優化性能配置?。?!與cpu相對,一般是cpu數量-1worker_processes  2;
worker_cpu_affinity  01 10;#用于實現cpu綁定即無需切換上下文,優化系統性能;#error_log  logs/error.log;#error_log  logs/error.log  notice;error_log  logs/error.log  info;


pid /var/run/nginx/nginx.pid;#要想禁用error-log則需使用如下命令;#error_log /dev/null crit;#此處為調試功能,暫不開啟;#error_log LOGFILE [debug_core | debug_alloc | debug_mutex | debug_event | debug_http | debug_imap];#優化性能的配置,這里好像只能配置時間;timer_resolution 100ms;#每個進程能打開的最大的句柄數,優化性能的配置worker_rlimit_nofile 200;#每個用戶能發向進程的信號數量,這也是性能優化的一部分;貌似會有問題#worker_rlimit_sigpending  200  ;events {
        worker_connections  1024;        #最大的客戶端數量由上下文決定;
        #max clients = worker_processes * worker_connections
        #use auto;
        #下面這個配置是負載均衡鎖,打開此調度會損耗系統性能;
        #accept_mutex[0n|off] 
        #lock_file為其鎖文件
        #一個worker進程為取得一個鎖真正建立連接的最長等待時間;如果某worker去取鎖時,如果有worker在使用,那么得等待這么久再進行第二次
        # 請求,默認是500ms;
        #accept_mutex_delay #ns ;
        #multi_accept  [on|off];
        #是否允許并發建立連接,一次響應多個用戶請求;默認為off;


        #用于調試、定位問題:只調試Nginx時使用,只讓nginx工作在單進程模式下
        #daemon [on|off];提供關閉守護進程模式;
        #是否讓Nginx運行于后臺,默認為on,調試時默認為off,使得信息直接輸出至控制臺
        #master_process on | off 是否以此模式運行,默認為on,調試時可設為off以便追蹤。
        #                                                                               
        }


http {#客戶端類指令:如client_body_buffer_size 128k ;
client_header_buffer_size 32k;#large_client_buffer_size  32k;client_max_body_size  8m;#client_header_timeout;#keepalive_timeout;#文件IO類指令:如#aio;#directio;#open_file_cache;#open_file_cache_min_uses;#open_file_cache_valid;#sendfile;#hash類指令:用于定義Nginx為某特定的變量分配多大的內存空間,如#types_hash_bucket_size;#server_names_hash_bucket_size;#variables_hash_bucket_size;#套接字類指令:用于定義Nginx如何處理tcp套接字相關的功能,如tcp_nodelay on;#(用于keepalive功能啟用時);tcp_nopush on;#(用于sendfile啟用時);

    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  logs/access.log  main;

    sendfile        on;    #tcp_nopush     on;

    #keepalive_timeout  0;
    keepalive_timeout  65;    #gzip  on;
    #配置壓縮模塊格式;gzip on;
gzip_min_length 1k;
gzip_buffers   4 16k;
gzip_http_version 1.0;
gzip_comp_level 4;#這里是一個引用配置段,我就不啟用了;#include vh/bbs.yourich.com.cn.conf;

 log_format  main  '$remote_addr-$remote_user $time_local "$request" '
                     '$status $body_bytes_sent "$http_referer" '
                      '"$http_user_agent" "$http_x_forwarded_for"'
                       '$upstream_addr $upstream_response_time $request_time ';#   配置公用的server段#   server{#       }#
        server {
        listen       80;
        server_name  www.sjf.com;
        index  index.html index.php;
        access_log /var/log/nginx/access.log  main;
        error_log   /var/log/nginx/error.log;        #server_name_hash_bucket_size;定義一次最多存儲多少主機名
        #

        #charset koi8-r;

        #access_log  logs/host.access.log  main;#允許根據用戶請求的URI來匹配指定的各location以進行訪問配置;匹配到時,將被location塊中的配置所處理;#比如:http://www.magedu.com/images/logo.gif# =:精確匹配;# ~:正則表達式模式匹配,匹配時區分字符大小寫# ~*:正則表達式模式匹配,匹配時忽略字符大小寫# ^~: URI前半部分匹配,不檢查正則表達式
        location ^~ /admin{
        auth_basic  "Auth Area";
        auth_basic_user_file   /etc/nginx/.nginx_passwd;

        }
        location ~ .*\.(jpg|jpeg|png|gif\js|css)$ {
                root /usr/html;
                access_log off;
        }
        location   / {
                root /usr/html;                #try_files $uri $uri/ /index.php?$args;
                index index.html index.htm  index.php ;
        }
        location ~* \.php$ {               #        expires -1s;
                #這一條是可以不寫的;
                root   /usr/html;        #       try_files $uri =404
                fastcgi_pass  127.0.0.1:9000;
                fastcgi_index     index.php ;
                fastcgi_param    SCRIPT_FILENAME /usr/html$fastcgi_script_name;
                include  fastcgi_params;                #fastcgi_param QUERY_STRING  $query_string;
                #fastcgi_param REQUEST_METHOD $request_method;
                #fastcgi_param CONTENT_TYPE  $content_type;
                #fastcgi_param CONTENT_LENGTH $content_length;
                fastcgi_cache off;
                fastcgi_cache_key  $request_uri;
                fastcgi_cache_valid  200 302 10m;
                fastcgi_cache_valid  301  1h;
                fastcgi_cache_valid  any  1m;
        }
        location    ~* ^/(status|ping)$   {
                include fastcgi_params;
                fastcgi_pass 127.0.0.1:9000;
                fastcgi_param   SCRIPT_FILENAME $fastcgi_script_name;

}
        location /status {
          stub_status                 on;
          access_log                  off;
          allow                       127.0.0.1;
          allow                       192.168.42.171;
          deny                        all;
      }

        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
        #
        #location ~ \.php$ {
        #    root           html;
        #    fastcgi_pass   127.0.0.1:9000;
        #    fastcgi_index  index.php;
        #    fastcgi_param  SCRIPT_FILENAME  /scripts$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;
                #fastcgi_param CONTENT_TYPE  $content_type;
                #fastcgi_param CONTENT_LENGTH $content_length;
                fastcgi_cache off;
                fastcgi_cache_key  $request_uri;
                fastcgi_cache_valid  200 302 10m;
                fastcgi_cache_valid  301  1h;
                fastcgi_cache_valid  any  1m;
        }
        location    ~* ^/(status|ping)$   {
                include fastcgi_params;
                fastcgi_pass 127.0.0.1:9000;
                fastcgi_param   SCRIPT_FILENAME $fastcgi_script_name;

}
        location /status {
          stub_status                 on;
          access_log                  off;
          allow                       127.0.0.1;
          allow                       192.168.42.171;
          deny                        all;
      }

        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;
        }

這里我們用數據哭給用戶授權對論壇數據庫的訪問

mysql -uroot -p123 -e 'create database ultrax;'
mysql -u root -p123 -e 'grant all on 'root'@'192.168.42.171'  identified by  '123'; '

這里我們解壓Discuz

blob.png

這里我們用數據哭給用戶授權對論壇數據庫的訪問
這里我們解壓Discuz
得到這個目錄,然后我們復制所有文件到/usr/html 中
chown -R ngin.nginx /usr/html
然后修改/etc/php-fpm.d/www.conf
將與php連接的用戶和組均改為nginx.
這樣我們打開網站首頁就可以進行訪問了?。?/h6>
接下來我們要實現的就是結合nfs 實現多級LNMP的架構?。?!

原創文章,作者:sjfbjs,如若轉載,請注明出處:http://www.www58058.com/55154

(1)
sjfbjssjfbjs
上一篇 2016-10-30
下一篇 2016-10-30

相關推薦

  • Linux基礎知識(四)

    本文主要講述:Linux上用戶和組的基本管理,具體包括一下內容 1、復制/etc/skel目錄到/home/tuser1,要求/home/tuser1及其內部文件的屬組和其它用戶均沒有任何訪問權限。 2、編輯/etc/group文件,添加組hadoop。 3、手動編輯/etc/passwd文件新增一行,添加用戶hadoop,其基本組ID為hadoop組的id…

    Linux干貨 2016-10-16
  • 馬哥教育網絡班21期第2周課程練習

    1、Linux上的文件管理類命令都有哪些,其常用的使用方法及其相關示例演示。     復制命令:cp         cp [OPTION]… [-T] SOURCE DEST     &…

    Linux干貨 2016-07-16
  • centos系統啟動流程詳解

    centos系統啟動流程詳解 CentOS啟動流程: POST 加電自檢 主板上有一個ROM芯片,有只讀程序,CPU被設計為一旦通電就會自動去找ROM芯片上的程序并運行,即檢查各種硬件設備是否存在。 BootSequence 引導過程 加電自檢后按BIOS中設定的次序查找各引導設備,第一個有引導程序的設備即是本次啟動用到的設備 MBR(BootLoader)…

    Linux干貨 2017-09-04
  • 馬哥教育網絡班21期+第一周課程練習

    1、描述計算機的組成及其功能。 計算機由五大組件組成包括:計算器,控制器,存儲,輸入設備,輸出設備。 運算器:做運算,且只能做二進制運算,包括算術運算和邏輯運算,如加減乘除,移位,取模。運算器的核心是加法器。 控制器:控制整個計算機部件之間協調。比如做計算,運算器先從存儲器取數,運算器作運算,再回存存儲器。這整個過程都由控制器做協調。  &nbsp…

    Linux干貨 2016-07-12
  • apache工作模式及虛擬主機的配置

    apache的工作模式 MPM 名詞解釋MPM   Multipath Process Module 多道處理模塊。Linux中常使用prefork worker event三種MPM 即apache常用的三種工作模式。 prefork prefork為多進程模型,每個進程響應一個請求。其工作過程簡單說來就是一個主進程:負責生成n個 子進程(子進程…

    Linux干貨 2016-07-02
  • 三劍客之Sed

    sed:stream editor(流編輯器) 工作特性:并不直接處理文本文件本身,處理機制為每當處理一個文件的時候,它會逐行讀取,每次把一行讀取到內存空間中去,而后在模式空間(pattern space)中完成編輯.并把編輯好的結果輸出到屏幕上  功      能:數據替換、刪除、增加、等,數據為關鍵字或者一整行, …

    Linux干貨 2016-08-08
欧美性久久久久