美好的一天,nginx的:EMERG]不能建立referer_hash,則應該增加referer_hash_bucket_size:64
我是一個新手,PHP的,我想在我的ubuntu-運行livehelperchat開放源代碼(https://livehelperchat.com/) 16.04實例,我有Nginx作爲默認服務器偵聽端口80,並且運行PHP 5.6。
在/ var/www/html等/站點啓用/默認
server {
listen 80 default_server;
listen [::]:80 default_server ipv6only=on;
root /var/www/html;
index index.php index.html index.htm index.nginx-debian.html;
server_name xxxxxxxxx;
location/{
try_files $uri $uri/ =404;
}
error_page 404 /404.html;
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /var/www/html;
}
location ~ \.php$ {
try_files $uri =404;
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass unix:/var/run/php5.6-fpm.sock;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
}
我可以通過訪問我的服務器的域名或公網IP地址,然後/info.php
訪問PHP信息頁面在我的網頁瀏覽器我有我的代碼位於/ var/www/html等/ livehelperchat/ 我已經休耕下面鏈接來設置該項目在nginx的 https://livehelperchat.com/nginx-configuration-tips-132a.html
在/ var/www/html等/啓用站點-/例子。 conf
server {
listen 80;
server_name xxxxxxxxxxxxxxxxxxxxxxxxxxx;
root /var/www/html/livehelperchat;
location ~* (^(?!(?:(?!(php)).)*/(albums|bin|var|lib|cache|doc|settings|pos|modules)/).*?(index\.php|upgrade\.php)$) {
include /etc/nginx/livehelperchat_fastcgi_params;
fastcgi_pass unix:/var/run/php5.6-fpm.sock;
fastcgi_index index.php;
fastcgi_param PATH_INFO $query_string;
# fastcgi_param SCRIPT_FILENAME /var/livehelperchat/$fastcgi_script_name;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
}
#Allow hotlinking to normal and thumb size images
location ~* (normal_|thumb_|^/design|^/cache|^/var/storagetheme)(.*)\.(gif|jpe?g?|png|mp3|svg|otf|woff|eot|ttf|ogg|wav|bmp|htm|swf|css|js|swf|pdf|ico)$ {
## @todo: add expires headers...
# favicon is only stored in 1 dir, the design one; But browsers ask for it in the root
if ($http_user_agent ~* "(WebReaper|wget|SiteSucker|SuperBot|Mihov Picture Downloader|TALWinHttpClient|A1 Website Download|WebCopier|Download Ninja|Microsoft URL Control|GetRight|Arachmo|MJ12bot|Gaisbot|Anonymous|Yanga|Twiceler|psbot|Irvine|Indy Library|HTTrack)") {
return 403;
}
if ($http_referer ~* (stockingteensex.info|cbox.ws|teensos.net|dpstream.net|tagged.com|kaskus.us|gorilladatingservice.info|taringa.net|discuss.com|craigslist.org|poringa.net)) {
return 403;
}
#sendfile off;
#aio on;
directio 512;
expires max;
access_log off;
root /var/www/html/livehelperchat;
}
# Do not allow to hotlink full size images except our self and major search engines
location ~* \.(gif|jpe?g?|png|bmp|swf|css|js|svg|otf|eot|ttf|woff|swf|mp3|ogg|wav|pdf|ico|txt)$ {
## @todo: add expires headers...
valid_referers none blocked server_names ~(livehelperchat.com|google.|reddit.|bing.|yahoo.);
if ($invalid_referer) {
return 403;
}
if ($http_user_agent ~* "(WebReaper|wget|SiteSucker|SuperBot|Mihov Picture Downloader|TALWinHttpClient|A1 Website Download|WebCopier|Download Ninja|Microsoft URL Control|GetRight|Arachmo|MJ12bot|Gaisbot|Anonymous|Yanga|Twiceler|psbot|Irvine|Indy Library|HTTrack)") {
return 403;
}
if ($http_referer ~* (stockingteensex.info|cbox.ws|teensos.net|dpstream.net|tagged.com|kaskus.us|gorilladatingservice.info|taringa.net|discuss.com|craigslist.org|poringa.net)) {
return 403;
}
#sendfile off;
#aio on;
directio 512;
expires max;
root /var/www/html/livehelperchat;
}
location/{
rewrite "^(.*)$" "/index.php?$1" last;
}
}
現在我做得到一個錯誤的nginx -t
nginx: [emerg] could not build referer_hash, you should increase referer_hash_bucket_size: 64
nginx: configuration file /etc/nginx/nginx.conf test failed
服務nginx的重新啓動
工作的nginx.service失敗,因爲控制過程,錯誤代碼退出。有關詳細信息,請參閱「systemctl status nginx.service」和「journalctl -xe」。
systemctl狀態nginx.service
nginx.service - A high performance web server and a reverse proxy server
Loaded: loaded (/lib/systemd/system/nginx.service; enabled; vendor preset: enabled)
Active: failed (Result: exit-code) since Sat 2017-04-22 10:15:40 UTC; 1min 14s ago
Process: 24237 ExecStop=/bin/sleep 1 (code=exited, status=0/SUCCESS)
Process: 24232 ExecStop=/sbin/start-stop-daemon --quiet --stop --retry TERM/5 --pidfile /run/nginx.pid (code=exited, status=0/SUCCES
Process: 24111 ExecStart=/usr/sbin/nginx -g daemon on; master_process on; (code=exited, status=0/SUCCESS)
Process: 31591 ExecStartPre=/usr/sbin/nginx -t -q -g daemon on; master_process on; (code=exited, status=1/FAILURE)
Main PID: 24134 (code=exited, status=0/SUCCESS)
Apr 22 10:15:40 ip-172-31-28-209 systemd[1]: Starting A high performance web server and a reverse proxy server...
Apr 22 10:15:40 ip-172-31-28-209 nginx[31591]: nginx: [emerg] could not build referer_hash, you should increase referer_hash_bucket_si
Apr 22 10:15:40 ip-172-31-28-209 nginx[31591]: nginx: configuration file /etc/nginx/nginx.conf test failed
Apr 22 10:15:40 ip-172-31-28-209 systemd[1]: nginx.service: Control process exited, code=exited status=1
Apr 22 10:15:40 ip-172-31-28-209 systemd[1]: Failed to start A high performance web server and a reverse proxy server.
Apr 22 10:15:40 ip-172-31-28-209 systemd[1]: nginx.service: Unit entered failed state.
Apr 22 10:15:40 ip-172-31-28-209 systemd[1]: nginx.service: Failed with result 'exit-code'.
任何幫助的高度讚賞。在此先感謝
你有沒有[[referer_hash_bucket_size]](http://nginx.org/en/docs/http/ngx_http_referer_module.html#referer_hash_bucket_size)?例如'referer_hash_bucket_size 128;'在'valid_referers'指定的'location' /'server'塊中。 – Deadooshka
@ Deadooshka,感謝您的快速回復。我對Linux很新,所以請讓我知道目錄的路徑,我可以將referer_hash_bucket_size更改爲128 – suresh
這是關於Nginx配置。正如我在日誌中看到的,路徑是'/ etc/nginx/nginx.conf'。 – Deadooshka