關於如何配置fastDFS+nginx這個問題小安就不在此多說了,網上都有教程,雖然不近完美但是想必大家都可以把這個架構配出來。
為了大家需要我還是找了份詳細的教程,將串連分享如下:
http://pan.baidu.com/s/1i3D6wPR
下面是我小安在配置過程之中切身的經驗,做成了Q&A以供參考,如有雷同純屬巧合,哈哈。
首先我先寫兩條基本操作:
fastDFS開啟:
開啟tracker:
/usr/bin/fdfs_trackerd /home/an/work/fastDFS/TLOGS/conf/tracker.conf restart
開啟storage:
/usr/bin/fdfs_storaged /home/an/work/fastDFS/SLOGS/conf/storage.conf restart
上傳檔案:
fdfs_upload_file /home/an/work/fastDFS/CLOGS/conf/client.conf /home/an/work/fastDFS/CLOGS/conf/1.jpg
(注意:路徑改為你在自己系統裡安裝的實際路徑!!)
另外記得用root許可權哦~
如果需要更改設定檔但並沒有熟練的vi基本功用gedit的話那麼記得修改檔案夾許可權:
chmod -R 777 [filename]
查看連接埠情況:
netstat -unltp | grep fdfs
fastDFS如果不能正常啟動的話請檢查依賴包是否完整
這個是nginx需要的依賴包:wget http://fastdfs.googlecode.com/files/fastdfs-nginx-module_v1.15.tar.gz
下面是小安Q&A環節:
1,
Q:安裝完fastDFS但沒有安裝nginx可以上傳圖片,但是通過返回的URL用瀏覽器訪問圖片做不到
A:最新版的fastDFS已經不內建支援HTTP訪問服務了,只能說你看的教程太舊了,必須配合其他的伺服器才可提供訪問。
2,
Q:安裝完nginx修改完配置nginx.conf後一直報錯怎麼辦?(此問題適用於各種情況)
A:這個很大程度上在於你的nginx並沒有配置相關的模組。這時候你要問了:我nginx已經安裝好了如何把模組添加進去?呵呵,哼是沒法硬插進去。所以我的朋友,重新編譯吧!
在網上有許多配置模組的命令但我特意到國外官網上找到最全的:
首先進入nginx安裝資料夾所在目錄,將其中的make.sh刪掉,之後運行以下命令
./configure --prefix=/etc/nginx \
--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.pid \
--lock-path=/var/run/nginx.lock \
--http-client-body-temp-path=/var/cache/nginx/client_temp \
--http-proxy-temp-path=/var/nginx/proxy_temp \
--http-fastcgi-temp-path=/var/cache/nginx/fastcgi_temp \
--http-uwsgi-temp-path=/var/cache/nginx/uwsgi_temp \
--http-scgi-temp-path=/var/cache/nginx/scgi_temp \
--user=nginx \
--group=nginx \
--with-http_ssl_module \
--with-http_realip_module \
--with-http_addition_module \
--with-http_sub_module \
--with-http_dav_module \
--with-http_flv_module \
--with-http_mp4_module \
--with-http_gunzip_module \
--with-http_gzip_static_module \
--with-http_random_index_module \
--with-http_secure_link_module \
--with-http_stub_status_module \
--with-http_auth_request_module \
--with-mail \
--with-mail_ssl_module \
--with-file-aio \
--with-http_spdy_module \
--with-ipv6 \
--add-module=/home/an/work/etc/fastdfs-nginx-module/src \
--add-module=/home/an/work/etc/ngx_cache_purge \
--with-pcre=/home/an/work/etc/pcre-8.34 \
--with-zlib=/home/an/work/etc/zlib-1.2.7
這裡請注意把目錄調整為你自己的目錄並且最後四個命令相關的組件:fastdfs-nginx-module || ngx_cache_purge || pcre-8.34 || zlib-1.2.7如果你沒有的話就到網上下載。運行命令之前記住要先安裝 pcre-8.34 || zlib-1.2.7這兩個組件(進入檔案夾make+make install)
運行命令之後輸入命令make進行編譯,之後將以前安裝好的nginx設定檔 *.conf自己備份後(改了哪個就備份哪個)運行make install。
(其實就是圖省事,你也可以複製替換nginx二進位檔案,如果還是不懂的話可以搜一下“nginx升級”)
3,
Q:ERROR: nginx: [emerg] getpwnam("**") failed
A:這個網上也有相關的回答例如:sudo adduser --system --no-create-home --disabled-password --group nginx
額,反正我是沒成功滴...
我的辦法是:在nginx.conf中 把"#user [nobody];"的前面#注釋去掉,改為"user root;"就可(介個是從根本上解決問題呀!)
4,
Q:ERROR:open() "/var/run/nginx.pid" failed (2: No such file or directory)
A:這是經常出現的問題,不廢話:nginx -c /etc/nginx/nginx.conf 解決問題(請填寫自己的正確目錄)
5,
Q:ERROR:include file "http.conf" not exists, line: "#include http.conf"
A:找到mod_fastdfs.conf檔案(找不到就到根目錄find -name)之中找到: #include http.conf 在這個的前面添加“#”就可
6,
Q:ERROR:host "tracker" is invalid
A:這個的話在仍然是mod_fastdfs.conf檔案中 有一項目是tracker_server=**** 預設顯示的是tracker_server = tracker. 應該是沒有替換後面的tracker為實際tracker的ip:port.
小安奉勸順手吧後面的store_path0=....的連接埠號碼都改了吧。
7,
Q:ERROR:unknown directive "proxy_cache_purge"
A:nginx缺少了proxy_cache_purge模組,不要懷疑,直接按照小安上文第二個Q&A來解決。
8,
Q:Error:http.mime_types_filename not exist or is empty
A:找到http.conf(如果找不到咋整?搜!)找到其中
http.mime_types_filename=
http.anti_steal.token_check_fail=
改為實際mime.types和anti-steal.jpg存在的路徑
如果說找不到或者改了也沒用的話就刪掉小安覺得也無傷大雅
還有一個在安裝時別忘了
ln -s /home/an/work/fastDFS/SP0/data /home/an/work/fastDFS/SP0/data/M00(改為實際路徑)
我所遇到的大坎也就這麼多了,如果有小問題自己琢磨著解決吧,嘿嘿,另附完成:
著作權聲明:本文為博主原創文章,未經博主允許不得轉載。
以上就介紹了關於fastDFS+nginx的叢集配置問題解答集錦Q&A,包括了方面的內容,希望對PHP教程有興趣的朋友有所協助。