美文网首页
dokuwiki 搭建

dokuwiki 搭建

作者: 阳光_8af8 | 来源:发表于2018-07-10 18:58 被阅读0次

    1. 建立逻辑卷存放wiki数据

    建立新分卷 /dev/sda3

    fdisk -l
    fdisk /dev/sda
    partprobe
    

    建立逻辑卷

    pvcreate /dev/sda2 /dev/sda3
    vgextend VG1 /dev/sda3
    lvcreate VG1 -n wiki -l 100%FREE
    mkfs.ext4 /dev/VG1/wiki
    

    建立目录存放wiki数据

    mkdir wikidata
    mount /dev/VG1/wiki /wikidata
    

    2. 安装nginx

    使用yum 安装nginx。

    yum install nginx
    

    3. 安装php

    编译安装php 5.6.30
    首先安装依赖

    yum install gcc-c++ make perl libxml2 libxml2-devel libjpeg-devel libjpeg libpng-devel libepng expat-devel freetype-devel expat freetype openssl openssl-devel
    

    下载最新稳定版php

    cd /usr/local/
    wget http://cn2.php.net/distributions/php-5.6.30.tar.gz
    

    准备编译安装

    tar zxvf php-5.6.30.tar.gz
    cd php-5.6.30
    

    编译安装php

    ./configure --prefix=/usr/local/php5.6.30 --with-config-file-path=/etc/php/ --with-bz2 --with-curl --with-gd --enable-ftp --enable-sockets --disable-ipv6 --with-jpeg-dir=/wikidata/site/php-tmp/jpg --with-png-dir=/wikidata/site/php-tmp/png --with-freetype-dir=/wikidata/site/php-tmp/freetype --enable-gd-native-ttf --with-iconv-dir=/wikidata/site/php-tmp/iconv --enable-mbstring --enable-calendar --with-gettext --with-libxml-dir=/wikidata/site/php-tmp/xml --with-zlib --enable-dom --enable-xml --enable-fpm --with-libdir=lib64 --enable-bcmath --with-openssl
    make
    make install
    cp /usr/local/php-5.6.30/php.ini-production /etc/php/php.ini
    

    p.s 安装时忘记安装openssl时可以添加后续添加

    cd cd /usr/local/php-5.6.30/ext/openssl
    mv config0.m4 config.m4
    yum install m4 autoconf
    /usr/local/php5.6.30/bin/phpize
    ./configure --with-openssl --with-php-config=/usr/local/php5.6.30/bin/php-config
    make
    make install
    

    执行后可以会给出一个 openssl.so 的安装路径
    将openssl.so 复制到php的extensions路径下 重启nginx即可
    php的extensions路径 可以使用phpinfo查看,也可以在php.ini配置。

    4. 配置dokuwiki站点、nginx

    编辑nginx使nginx可以使用php vim /etc/nginx/nginx.conf

    # For more information on configuration, see:
    #   * Official English Documentation: http://nginx.org/en/docs/
    #   * Official Russian Documentation: http://nginx.org/ru/docs/
    
    user nginx;
    worker_processes auto;
    error_log /var/log/nginx/error.log;
    pid /run/nginx.pid;
    
    # Load dynamic modules. See /usr/share/nginx/README.dynamic.
    include /usr/share/nginx/modules/*.conf;
    
    events {
        worker_connections 1024;
    }
    
    http {
        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  /var/log/nginx/access.log  main;
    
        sendfile            on;
        tcp_nopush          on;
        tcp_nodelay         on;
        keepalive_timeout   65;
        types_hash_max_size 2048;
        client_max_body_size 8M;
        client_body_buffer_size 128k;
        include             /etc/nginx/mime.types;
        default_type        application/octet-stream;
    
        # Load modular configuration files from the /etc/nginx/conf.d directory.
        # See http://nginx.org/en/docs/ngx_core_module.html#include
        # for more information.
        include /etc/nginx/conf.d/*.conf;
    
        server {
            listen       80 default_server;
            listen       [::]:80 default_server;
            server_name  _;
            root         /wikidata;
            index   index.php index.html index.html;
            # Load configuration files for the default server block.
            include /etc/nginx/default.d/*.conf;
    
            location /
            {
            try_files $uri $uri/ /index.php?$args;
            }
    
            location ~ .*\.(php)?$
            {
            expires -1s;
            try_files $uri =404;
            fastcgi_split_path_info ^(.+\.php)(/.+)$;
            include fastcgi_params;
            fastcgi_param PATH_INFO $fastcgi_path_info;
            fastcgi_index index.php;
            fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
            fastcgi_pass 127.0.0.1:9000;
            }
    
    
            error_page 404 /404.html;
                location = /40x.html {
            }
    
            error_page 500 502 503 504 /50x.html;
                location = /50x.html {
            }
        }
    }
    

    配置vhost vim /etc/nginx/conf.d/dokuwiki.conf
    参考github dokuwiki文档

    server {
      server_name 192.168.8.ip opswiki.5678.com;
      root /wikidata/site/dokuwiki;
    
      location / {
        index doku.php;
        try_files $uri $uri/ @dokuwiki;
      }
    
      location ^~ /conf/ { return 403; }
      location ^~ /data/ { return 403; }
    
      location @dokuwiki {
        rewrite ^/_media/(.*) /lib/exe/fetch.php?media=$1 last;
        rewrite ^/_detail/(.*) /lib/exe/detail.php?media=$1 last;
        rewrite ^/_export/([^/]+)/(.*) /doku.php?do=export_$1&id=$2 last;
        rewrite ^/(.*) /doku.php?id=$1 last;
      }
    
      location ~ \.php$ {
        if (!-f $request_filename) { return 404; }
        include fastcgi_params;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        fastcgi_pass 127.0.0.1:9000;
      }
    

    启动 php-fpm

    /usr/local/php5.6.30/sbin/php-fpm
    

    启动nginx

    systemctl start nginx
    systemctl enable nginx
    

    打开防火墙80端口

    firewall-cmd --zone=public --add-port=80/tcp --permanent
    firewall-cmd --reload
    

    将dokuwiki站点文件复制到nginx vhost站点目录下,同时修改目录权限

    wget https://download.dokuwiki.org/out/dokuwiki-3203a8fa2af3c3d5304bfdecb210ec5d.tgz
    tar -zxvf dokuwiki-3203a8fa2af3c3d5304bfdecb210ec5d.tgz
    cp -R dokuwiki /wikidata/site/
    cd /wikidata/site/dokuwiki
    chmod -R 777 conf/ data/ lib/
    

    第一次使用访问opswiki.5678.com/install.php进行安装

    相关文章

      网友评论

          本文标题:dokuwiki 搭建

          本文链接:https://www.haomeiwen.com/subject/ynyqpftx.html