lnmp 安裝discuz

課程大綱:
1. 下載discuz! 
mkdir /date/www
cd /data/www
wget  http://download.comsenz.com/DiscuzX/3.0/Discuz_X3.0_SC_UTF8.zip

unzip Discuz_X3.0_SC_UTF8.zip

 mv upload/*  .

2.配置php-fpm

>  /usr/local/php/etc/php-fpm.conf    //“>” 這個符號爲重定向的意思,單獨用它,可以把一個文本文檔快速清空

useradd -s /sbin/nologin php-ops

vim /usr/local/php/etc/php-fpm.conf    //把之前的內容清空,然後寫入如下配置:

[global]
pid = /usr/local/php/var/run/php-fpm.pid
error_log = /usr/local/php/var/log/php-fpm.log
[www]
#listen = /tmp/www.sock
listen = 127.0.0.1:9000
user = php-fpm
group = php-fpm
pm = dynamic
pm.max_children = 50
pm.start_servers = 20
pm.min_spare_servers = 5
pm.max_spare_servers = 35
pm.max_requests = 500
rlimit_files = 1024
slowlog = /path/to/slow.log
request_slowlog_timeout = 1
open_basedir
php_admin_value[open_basedir]=/usr/local/nginx/html:/tmp/  //(多個存放目錄用冒號分割)
[ops]
#listen = /tmp/ops.sock
listen = 127.0.0.1:9001
user = php-ops
group = php-ops
pm = dynamic
pm.max_children = 50
pm.start_servers = 20
pm.min_spare_servers = 5
pm.max_spare_servers = 35
pm.max_requests = 500
rlimit_files = 1024
slowlog = /path/to/slow.log
request_slowlog_timeout = 1
php_admin_value[open_basedir]=/date/www:/tmp  //(多個存放目錄用冒號分割)


3.配置nginx
 >  /usr/local/nginx/conf/nginx.conf     //“>” 這個符號爲重定向的意思,單獨用它,可以把一個文本文檔快速清空

vim   /usr/local/nginx/conf/nginx.conf //把之前的內容清空,然後寫入如下配置:  

user nobody nobody;
worker_processes 2;
error_log /usr/local/nginx/logs/nginx_error.log crit;
pid /usr/local/nginx/logs/nginx.pid;
worker_rlimit_nofile 51200;

events
{
    use epoll;
    worker_connections 6000;
}

http
{
    include mime.types;
    default_type application/octet-stream;
    server_names_hash_bucket_size 3526;
    server_names_hash_max_size 4096;
    log_format combined_realip '$remote_addr $http_x_forwarded_for [$time_local]'
    '$host "$request_uri" $status'
    '"$http_referer" "$http_user_agent"';
    sendfile on;
    tcp_nopush on;
    keepalive_timeout 30;
    client_header_timeout 3m;
    client_body_timeout 3m;
    send_timeout 3m;
    connection_pool_size 256;
    client_header_buffer_size 1k;
    large_client_header_buffers 8 4k;
    request_pool_size 4k;
    output_buffers 4 32k;
    postpone_output 1460;
    client_max_body_size 10m;
    client_body_buffer_size 256k;
    client_body_temp_path /usr/local/nginx/client_body_temp;
    proxy_temp_path /usr/local/nginx/proxy_temp;
    fastcgi_temp_path /usr/local/nginx/fastcgi_temp;
    fastcgi_intercept_errors on;
    tcp_nodelay on;
    gzip on;
    gzip_min_length 1k;
    gzip_buffers 4 8k;
    gzip_comp_level 5;
    gzip_http_version 1.1;
    gzip_types text/plain application/x-javascript text/css text/htm application/xml;
    include vhosts/*.conf;
}

mkdir /usr/local/nginx/conf/vhosts

vim /usr/local/nginx/conf/vhosts/default.conf

server
{
    listen 8080 default_server;
    server_name localhost;
    index index.html index.htm index.php;
    root /usr/local/nginx/html;

    location ~ \.php$ {
        include fastcgi_params;
        #fastcgi_pass unix:/tmp/www.sock;
        fastcgi_pass 127.0.0.1:9000;
        fastcgi_index index.php;
        fastcgi_param SCRIPT_FILENAME /usr/local/nginx/html$fastcgi_script_name;
    }
}

vim /usr/local/nginx/conf/vhosts/chinaops.conf

server
{
    listen 80 default_server;
    server_name chinaops.com;
    index index.html index.htm index.php;
    root /date/www;

    location ~ \.php$ {
        include fastcgi_params;
        #fastcgi_pass unix:/tmp/ops.sock;
        fastcgi_pass 127.0.0.1:9001;
        fastcgi_index index.php;
        fastcgi_param SCRIPT_FILENAME /date/www$fastcgi_script_name;
    }
}

3. 配置mysql,給Discuz!增加一個賬戶
給mysql root賬戶設置密碼,然後命令行進入mysql,創建新的庫,並創建一個新的帳號對該庫有所有權限:
> create database discuz;
> grant all on discuz.* to 'aming'@'localhost' identified by '123456aminglinux';
> quit

4. 安裝Discuz!
先綁定hosts  
192.168.0.106  www.chinaops.com  
瀏覽器輸入: 
www.chinaops.com  
根據提示,修改對應目錄的權限
cd /data/www

ps aux | grep php-fpm

chinaops 監聽用戶爲php-ops localhost監聽用戶爲php-fpm
 chown php-ops:php-ops  data  uc_server/data  uc_client/data config   // 讓這幾個目錄支持nginx運行帳號可寫


5慢執行日誌

放在/usr/local/php/etc/php-fpm.conf
slowlog = /path/to/slow.log
request_slowlog_timeout = 1

6域名池設置多個所在目錄

open_basedir
php_admin_value[open_basedir]=/data/www/:/tmp/


7 用戶認正(例如admin.php)

首先需要安裝apache (參看lamp中apache的編譯安裝,或者直接yum install httpd)

編譯安裝出錯,configure: error: /bin/sh build/config.sub  --with-pcre failed
configure: WARNING: cache variable ac_cv_build contains a newline 沒辦法只能進行yum install httpd

vim /usr/local/nginx/conf/vhosts/chinaops.conf

      

 location /abc/   { 
      auth_basic "lnmp auth";
      auth_basic_user_file /usr/local/nginx/conf/.htpasswd;
       }
       location ~ .*admin\.php$ { 
       auth_basic "lnmp auth";
       auth_basic_user_file /usr/local/nginx/conf/.htpasswd;
       include fastcgi_params;
       #fastcgi_pass unix:/tmp/ops.sock;
        fastcgi_pass 127.0.0.1:9001;
        fastcgi_index index.php;
        fastcgi_param SCRIPT_FILENAME /date/www$fastcgi_script_name;
        }

請將PHP解析部分加到後面,否則講不解析直接下載該文件


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