可能出現錯誤在配置資訊./configure --prefix=/usr/local/nginx 的時,出現錯誤:
/configure: error: the HTTP rewrite module requires the PCRE library.
解決方法:安裝pcre
yum -y install pcre pcre-devel
-y 是跳過所有需要手動确認的環節
缺少ssl錯誤,錯誤資訊如下:
./configure: error: the HTTP cache module requires md5 functions
from OpenSSL library. You can either disable the module by using
--without-http-cache option, or install the OpenSSL library into the system,
or build the OpenSSL library statically from the source with nginx by using
--with-http_ssl_module --with-openssl=<path> options.
解決方法:安裝openssl
yum -y install openssl openssl-devel
缺少編譯器,錯誤資訊如下:
./configure: error: C compiler cc is not found
解決方法:安裝gcc-c++
yum -y install gcc-c++ autoconf automake
autoconf是自動配置,automake是自動編譯
缺少zlib包,錯誤資訊如下:
./configure: error: the HTTP gzip module requires the zlib library.
You can either disable the module by using –without-http_gzip_module
option, or install the zlib library into the system, or build the zlib
library
statically from the source with nginx by using –with-zlib=<path> option.
解決方法:安裝zlib
yum install -y zlib-devel
确實libxml2,錯誤資訊如下:
./configure: error: the HTTP XSLT module requires the libxml2/libxslt
libraries. You can either do not enable the module or install the libraries.
解決方法:
yum -y install libxml2 libxml2-dev
yum -y install libxslt-devel
http_image_filter_module是nginx提供的內建圖檔處理子產品,需要gd-devel的支援,錯誤資訊如下:
./configure: error: the HTTP image filter module requires the GD library.
You can either do not enable the module or install the libraries.
解決方法:
yum -y install gd-devel
缺少ExtUtils,錯誤資訊如下:
./configure: error: perl module ExtUtils::Embed is required
解決方法:
yum -y install perl-devel perl-ExtUtils-Embed
缺少GeoIP,錯誤資訊如下:
./configure: error: the GeoIP module requires the GeoIP library.
You can either do not enable the module or install the library.
解決方法:
yum -y install GeoIP GeoIP-devel GeoIP-data
安裝完成後啟動安裝成功後 /usr/local/nginx 目錄下如下
fastcgi.conf koi-win nginx.conf.default
fastcgi.conf.default logs scgi_params
fastcgi_params mime.types scgi_params.default
fastcgi_params.default mime.types.default uwsgi_params
html nginx uwsgi_params.default
koi-utf nginx.conf win-utf
啟動
確定系統的 80 端口沒被其他程式占用,運作/usr/local/nginx/nginx 指令來啟動 Nginx,
netstat -ano|grep 80
如果查不到結果後執行,有結果則忽略此步驟(ubuntu下必須用sudo啟動,不然隻能在前台運作)
sudo /usr/local/nginx/nginx
打開浏覽器通路此機器的 IP,如果浏覽器出現 Welcome to nginx! 則表示 Nginx 已經安裝并運作成功。
運作400
可以試一下 加上這個
location / {
proxy_pass http://websocket;
proxy_pass_header Date;
proxy_pass_header Server;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
}
轉載于:https://www.cnblogs.com/lwj1022/p/10100714.html