1. 程式人生 > >教你搭建個人/企業私有云盤-kodexplorer指南

教你搭建個人/企業私有云盤-kodexplorer指南

環境說明:

系統版本:CentOS 6.9 x86_64 
軟體版本:nginx-1.12.2
php-5.5.38 
可道雲kodexplorer4.37

1、nginx的編譯安裝

1.1 建立目錄
mkdir -p /service/tools
mkdir /application
cd /service/tools
wget http://nginx.org/download/nginx-1.12.2.tar.gz 下載或者上傳nginx包

1.2 解壓
tar zxvf nginx-1.12.2.tar.gz

1.3 編譯安裝
yum install gcc gcc-c++ glibc -y #安裝編譯器
yum install pcre-devel zlib-devel openssl-devel –y

裝pcre為了重寫rewrite提供正則表示式庫,裝zlib為了gzip提供資料壓縮用的函式庫,裝openssl為 Nginx 模組(如 ssl )提供密碼演算法、證書以及 SSL 協議等功能
C語言原始碼包,需要編譯才能使用
編譯安裝三部曲

./configure(指定編譯引數:安裝目錄及版本)
cd nginx-1.12.2
./configure --prefix=/application/nginx-1.12.2 --pid-path=/var/run/nginx.pid --user=nginx --group=nginx --with-http_ssl_module ./configure -help #檢視幫助 

生成Makefile檔案
make
make是用來編譯的,它從Makefile中讀取指令,然後編譯

cc -c -pipe -O -W -Wall -Wpointer-arith -Wno-unused-parameter -Werror -g -I src/core -I src/event -I src/event/modules -I src/os/unix -I objs -I src/http -I src/http/modules \
-o objs/src/http/modules/ngx_http_geo_module.o \
src/http/modules/ngx_http_geo_module.c

make install
make install是用來安裝的,它也從Makefile中讀取指令,安裝到指定的位置

[[email protected] nginx-1.12.2]# cd /application/nginx-1.12.2/
[[email protected] nginx1.12.2]# ls -1 conf #配置檔案 html #網站html檔案 logs #日誌 sbin #二進位制的執行檔案 

1.4 配置

建立軟連結

ln -s /application/nginx-1.12.2 /application/nginx
ln -s /application/nginx/sbin/nginx /usr/bin/
useradd -M -s /sbin/nologin -r -u 88 nginx   #建立使用者
-M 不建立使用者的HOME目錄
-s shell 指定預設登入shell
-r 建立系統賬戶
-u uid 為賬戶指定一個唯一的UID
conf目錄
fastcgi.conf        配合php
uwsgi_params        配合python
nginx.conf        主配置檔案
mime.types        多媒體資源型別配置檔案

最小化配置檔案

grep -Ev '^$|#' nginx.conf.default >nginx.conf
[[email protected] conf]# grep -Ev '^$|#' nginx.conf.default >nginx.conf
[[email protected] conf]# cat nginx.conf
worker_processes 1;        #工作程序數
events {        #event模組
worker_connections 1024;        #預設工作連線數
}
http {            #http模組,nginx核心模組
include mime.types;    #載入的多媒體資源型別配置檔案
default_type application/octet-stream;    #預設型別(16進位制) sendfile on; #優化配置選項 keepalive_timeout 65; #長連線超時時間65秒 server { listen 80; #預設監聽的埠 server_name localhost; #網站域名 location / { #網站站點根目錄位置 root html; #網站檔案 index index.html index.htm; #網站首頁 } error_page 500 502 503 504 /50x.html; #錯誤頁面500,502.503.504返回50x.html location = /50x.html { root html; } } } 

1.5 啟動

/application/nginx/sbin/nginx –t            #語法檢查並測試
/application/nginx/sbin/nginx            #啟動
/application/nginx/sbin/nginx -s reload    #平滑重啟,不影響使用者訪問
/application/nginx/sbin/nginx -s stop        #關閉
/application/nginx/sbin/nginx -V            #檢視版本及安裝的模組

啟動後會生成幾個temp目錄
瀏覽器訪問

編譯安裝Nginx完成

2、編譯安裝php

2.1下載並安裝相關編譯器
mkdir -p /service/tools #建立目錄 
cd /service/tools/ 
wget http://mirrors.sohu.com/php/php-5.5.38.tar.gz #下載包 
tar xf php-5.5.38.tar.gz #解壓 
yum install gcc gcc-c++ glibc -y #安裝編譯器,如果已經編譯安裝了nginx則不需要此步驟 
yum install -y libxml2-devel curl curl-devel libjpeg-devel libpng-devel freetype-devel 
安裝編譯時所需庫 
cd php-5.5.38 #進入php-5.5.38目錄

2.2 編譯安裝
編譯生成makefile**

./configure 
--prefix=/application/php-5.5.38 
--with-jpeg-dir=/usr/lib64 --with-freetype-dir=/usr/lib64/ --with-curl --enable-fpm --enable-mbstring --with-gd --with-fpm-user=nginx --with-fpm-group=nginx make && make install 

3、配置

[[email protected] php-5.5.38]# ln -s /application/php-5.5.38 /application/php #建立軟連結  
[[email protected] php-5.5.38]# ln -s /application/php/bin/* /usr/bin/ #建立命令軟連結 [[email protected] php-5.5.38]# cp php.ini-production /application/php-5.5.38/etc/php.ini

拷貝預設配置檔案

[[email protected] php-5.5.38]#  
cp /application/php-5.5.38/etc/php-fpm.conf.default /application/php-5.5.38/etc/php-fpm.conf

拷貝預設php-fpm配置檔案,php-fpm 啟動程序數

4、啟動

[[email protected] php-5.5.38]# /application/php/sbin/php-fpm  #啟動php  
[[email protected] php-5.5.38]# netstat -lntup|grep 9000 #檢視程序9000埠 tcp 0 0 127.0.0.1:9000 0.0.0.0:* LISTEN 97399/php-fpm 

5、配置nginx使其支援php

檢視nginx.conf.default有關php的部分(65-71行),將此內容新增到nginx.conf中,並修改fastcgi_param指定script檔名documentrootdocumentrootfastcgi_script_name
可以在/application/nginx/conf/fastcgi.conf檢視

65 #location ~ \.php$ {
66 # root html;
67 # fastcgi_pass 127.0.0.1:9000; 68 # fastcgi_index index.php; 69 # fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name; 70 # include fastcgi_params; 71 #} [[email protected] php-5.5.38]# cd /application/nginx/conf/ [[email protected] conf]# vim nginx.conf server { listen 80; server_name localhost; index index.php index.html index.htm; location / { root html; } location ~ \.php$ { root html; fastcgi_pass 127.0.0.1:9000; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME documentrootdocumentrootfastcgi_script_name; include fastcgi_params; } } } 

這個配置的意思是 在瀏覽器中訪問的.php檔案,實際讀取的是 $document_root(網站根目錄)下的.php檔案 -- 也就是說當訪問127.0.0.1/index.php的時候,需要讀取網站根目錄下面的index.php檔案,如果沒有配置這一配置項時,nginx不回去網站根目錄下訪問.php檔案,所以返回空白

配置專案中:include fastcgi_params; fastcgi_params 檔案中含有各個nginx常量的定義,預設情況 SCRIPT_FILENAME = /scripts$fastcgi_script_name
檢查語法nginx -t

6、配置網盤,下載解壓可道雲kodexplorer

[[email protected] conf]# cd ../html/      #進入到站點目錄  
[[email protected] html]# ls  
50x.html  index.html  
[[email protected] html]# rm -rf *     #刪除原有的站點檔案  
[[email protected] html]# wget http://static.kodcloud.com/update/download/kodexplorer4.37.zip  
下載  
[[email protected] html]# unzip kodexplorer4.37.zip    #解壓  
[[email protected] html]# nginx    #啟動nginx

瀏覽器訪問

根據提示操作

su -c 'setenforce 0'        #關閉selinux,su -c 指定命令,用root執行
chmod -R 777 /var/www/html/    #按照提示修改許可權

重新整理頁面重新訪問,成功,設定管理員使用者名稱和密碼,進行登入及後續圖形介面操作