Welcome! Log In Create A New Profile

Advanced

How to compile Nginx from source

Posted by rocklee44 
How to compile Nginx from source
November 23, 2015 03:40AM
Hi all,
I'm Nginx newbie, I read Beginer & Wiki Guide and I want to compile Nginx from source. My Nginx server will work as Web server + Caching + Reverse Proxy (load balancing) , my server Centos 6.4 64 bit.
I downloaded Nginx 1.8.0 from here : http://nginx.org/download/nginx-1.8.0.tar.gz , then I compiled it with option:
<code>
./configure --prefix=/opt/nginx --sbin-path=/opt/nginx/sbin --conf-path=/opt/nginx/conf/ --user=nginx --error-log-path=/var/log/nginx/error.log --pid-path=/var/run/nginx.pid --lock-path=/var/lock/subsys/nginx --http-log-path=/var/log/nginx/access.log --group=nginx --with-file-aio --with-http_ssl_module --with-http_spdy_module --with-http_gunzip_module --with-http_gzip_static_module --with-http_stub_status_module --with-pcre
make
make install
</code>
Nginx was compiled successfully but:
- file "proxy_params" wasn't created
- Nginx cannot understand parameters : ip_hash , max_conns
So I get error when I try to start Nginx:
- [emerg] open() "/opt/nginx/conf/proxy_params" failed (2: No such file or directory) in /opt/nginx/site-enabled/proxy.conf:8
- [emerg] invalid number of arguments in "ip_hash" directive in /opt/nginx/site-enabled/upstreams.conf:5
- [emerg] invalid parameter "max_conns=1024" in /opt/nginx/site-enabled/upstreams.conf:5
This is my proxy.conf and upstreams.conf :
<code>
#proxy.conf
server {
listen 80 default_server;
server_name http-website.com;
server {
listen 80;
server_name https-website.com;
return 301 https://$server_name$request_uri;
}
server {
listen 443 ssl;
server_name staging.mymall.vn;
location / {
proxy_pass http://http;
}
location /static {
proxy_pass http://static;
}
</code>
<code>
#upstreams.conf
upstream http {
server 192.168.200.14:82 max_fails=3 fail_timeout=30s max_conns=1024;
zone http 256k;
keepalive 100;
queue 1024 [timeout=15];
}
upstream static {
ip_hash
server 192.168.200.14:83 max_fails=3 fail_timeout=30s max_conns=1024;
zone http 256k;
keepalive 100;
queue 1024 [timeout=15];
}
</code>
If I exclude proxy.conf and upstreams.conf , Nginx can work as Web server properly.
Please give me some advice, how should I compile Nginx to archive my purpose ?
Thanks in advance.



Edited 1 time(s). Last edit at 11/23/2015 03:41AM by rocklee44.
Re: How to compile Nginx from source
November 23, 2015 04:55AM
I can bypass "[emerg] open() "/opt/nginx/conf/proxy_params" failed (2: No such file or directory) in /opt/nginx/site-enabled/proxy.conf:8" by creating /opt/nginx/conf/proxy_params :
<code>
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;

client_max_body_size 100M;
client_body_buffer_size 1m;
proxy_intercept_errors on;
proxy_buffering on;
proxy_buffer_size 128k;
proxy_buffers 256 16k;
proxy_busy_buffers_size 256k;
proxy_temp_file_write_size 256k;
proxy_max_temp_file_size 0;
proxy_read_timeout 300;
</code>
I had syntax error with ip_hash ==> ip_hash;
So why Nginx cannot understand parameter max_conns=1024 in upstreams.conf ?



Edited 1 time(s). Last edit at 11/23/2015 05:02AM by rocklee44.
Re: How to compile Nginx from source
November 23, 2015 05:56AM
rocklee44 Wrote:
-------------------------------------------------------
> So why Nginx cannot understand parameter max_conns=1024 in
> upstreams.conf ?

Easy to find in the online documentation:
"Additionally, the following parameters are available as part of our commercial subscription: "
.........

---
nginx for Windows http://nginx-win.ecsds.eu/
Re: How to compile Nginx from source
November 23, 2015 10:28PM
Oh sorry I missed that, thank you very much, I excluded parameters are available as part of commercial subscription and my Nginx works properly now.
Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 253
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready