安裝理由通過nginx查看和下載檔案
準備資源: fastdfs-5.11.tar.gz和fastdfs-nginx-module_v1.16.tar.gz和nginx
使用到的nginx的常見命令:
到nginx目錄:cd /usr/local/nginx/sbin
啟動nginx: ./nginx -t
重啟nginx: ./nginx -s reload
馬上開始安裝:
nginx依賴包安裝
[root@fastdfs2 fdfs]# cd /opt
[root@fastdfs2 opt]# yum -y install zlib zlib-devel openssl openssl--devel pcre pcre-devel
解壓nginx
[root@fastdfs2 opt]# tar -zxvf nginx-1.13.12.tar.gz
安裝nginx并添加fastdfs模塊
[root@fastdfs2 opt]# cd nginx-1.13.12
[root@fastdfs2 nginx-1.13.12]# ./configure --prefix=/usr/local/nginx --add-module=/usr/local/fastdfs-nginx-module-master/src
[root@fastdfs2 nginx-1.13.12]# make
[root@fastdfs2 nginx-1.13.12]# make install
檢查nginx模塊
[root@fastdfs2 nginx-1.13.12]# cd /usr/local/nginx/sbin/
[root@fastdfs2 sbin]# ./nginx -V
顯示:
nginx version: nginx/1.13.12 uilt by gcc 4.4.7 20120313 (Red Hat 4.4.7-18) (GCC) configure arguments: --prefix=/usr/local/nginx --add-module=/usr/local/fastdfs-nginx-module-master/src
已經把fastdfs模塊添加進去了,
配置nginx組態檔
[root@fastdfs2 sbin]# cd /usr/local/nginx/conf
[root@fastdfs2 conf]# vi nginx.conf
內容如下,ip注意改成自己的:
events {
use epoll;
worker_connections 1024;
}
http {
server {
listen 80;
server_name 192.168.1.207;
location /group1/M00/{
#root /home/FastDFS/fdfs_storage/data;
ngx_fastdfs_module;
}
}
server {
listen 8888;
server_name 192.168.1.207;
location / {
root html;
index index.html index.htm;
}
}
}
啟動nginx
[root@fastdfs2 conf]# cd /usr/local/nginx/sbin/
[root@fastdfs2 sbin]# ./nginx -c /usr/local/nginx/conf/nginx-fdfs.conf

下面我們來說說安裝程序中遇到的坑:

埠被占用這就不多說了

找不到http.cong檔案
啟動nginx
sudo nginx
然后用【ps aux | grep nginx】,確認nginx行程是否成功啟動
root 9126 0.0 0.0 32980 436 ? Ss 20:52 0:00 nginx: master process nginx
發現結果如上,發現只有master行程,而沒有worker行程,說明啟動出了問題,
解決辦法:去看nginx的log檔案【/usr/local/nginx/logs/error.log】,log內容如下
2019/09/02 20:52:26 [notice] 8956#0: signal process started
ngx_http_fastdfs_process_init pid=9127
[2019-09-02 20:52:41] ERROR - file: shared_func.c, line: 968, file /etc/fdfs/mod_fastdfs.conf not exist
[2019-09-02 20:52:41] ERROR - file: /home/ys2/fastdfs/fastdfs-nginx-module-1.20/src/common.c, line: 163, load con\
f file "/etc/fdfs/mod_fastdfs.conf" fail, ret code: 2
2019/09/02 20:52:41 [alert] 9126#0: worker process 9127 exited with fatal code 2 and cannot be respawned
發現沒有找到/etc/fdfs/mod_fastdfs.conf 檔案,mod_fastdfs.conf 檔案在解壓后的src檔案夾里,所以拷貝到/etc/fdfs目錄下,
STEP6:編輯/etc/fdfs/mod_fastdfs.conf 檔案,發現此檔案和storage.conf檔案十分類似,所以照著storage.conf檔案修改此檔案,
-
修改base_path=,讓值和storage.conf一樣,
-
修改tracker_server=,讓值和storage.conf一樣,
-
修改storage_server_port=,讓值和storage.conf里的port一樣,
-
修改group_name=,讓值和storage.conf一樣,
-
修改url_have_group_name ,讓值為true,目的是在瀏覽器的URL里,顯示group_name的值,也就是能看到訪問的storage的哪個group,
-
修改store_path_count=,讓值和storage.conf一樣,
-
修改store_path0=,讓值和storage.conf一樣,
-
修改group_count =,fastdfs檔案系統里有幾個組就寫幾,只有一個組就寫1.
-
如果group_count =1,則必須設定[group1],如果group_count =2,則必須設定[group1]和[group2],以此類推,
然后,再把[group1]下的所以設定,再寫一遍,
把上面都修改好后,再次啟動nginx,發現還是沒有worker行程,再去看log內容,發現log內容和上一次不一樣了,就說明上面的問題已經修改好了,又有別的問題了,已經在向成功邁進了,
[2019-09-02 23:37:19] ERROR - file: ini_file_reader.c, line: 824, include file "http.conf" not exists, line: "#include http.conf"
[2019-09-02 23:37:19] ERROR - file: /home/ys2/fastdfs/fastdfs-nginx-module-1.20/src/common.c, line: 163, load conf file "/etc/fdfs/mod_fastdfs.conf" fail, ret code: 2
2019/09/02 23:37:19 [alert] 9383#0: worker process 9384 exited with fatal code 2 and cannot be respawned
說明沒找到http.conf檔案,
解決辦法:拷貝fastdfs原始碼安裝包里的http.conf檔案(在conf檔案夾里),到/etc/fdfs/檔案夾里,
修改好后,再次啟動nginx,發現還是沒有worker行程,再去看log內容,發現log內容和上一次不一樣了,就說明上面的問題已經修改好了,又有別的問題了,已經在向成功邁進了,
2019/09/02 23:53:59 [notice] 9532#0: signal process started
ngx_http_fastdfs_process_exit pid=9497
ngx_http_fastdfs_process_init pid=9536
[2019-09-02 23:54:05] ERROR - file: shared_func.c, line: 968, file /etc/fdfs/mime.types not exist
2019/09/02 23:54:05 [alert] 9535#0: worker process 9536 exited with fatal code 2 and cannot be respawned
說明沒找到/etc/fdfs/mime.types檔案
解決辦法:拷貝nginx原始碼安裝包里的mime.types檔案(在conf檔案夾里),到/etc/fdfs/檔案夾里,
修改好后,再次啟動nginx,發現有worker行程了,說明nginx啟動成功了,
修改nginx.conf檔案,添加下面
location /group1/M00 {
root /home/ys2/fastdfs/data;
ngx_fastdfs_module;
}
最后,在瀏覽器里直接訪問storage節點下的某個檔案,比如下面,如果能成功顯示在瀏覽器中,則說明配置成功了,
轉載請註明出處,本文鏈接:https://www.uj5u.com/ruanti/312089.html
標籤:其他
上一篇:nginx中斜杠(/)詳解
下一篇:LNMP操作手冊
