Welcome! Log In Create A New Profile

Advanced

Compile Nginx on Ubuntu

Posted by juliuss 
Compile Nginx on Ubuntu
March 04, 2011 10:07PM
Hi,

I normally install software using a package manager rather that compiling so maybe there will be a very obvious answer to this question that I am not seeing. I need to learn how to compile my own stuff, hence, the preference not to use apt.

I am on Ubuntu 10.04. It's a fresh, default install with nothing extra installed (no Apache, MySQL, PHP, nothing).

I have downloaded and unpacked Nginx with:
root@Emu:~# wget http://sysoev.ru/nginx/nginx-0.8.54.tar.gz

Then I ran configure with the SSL module that I would like:
root@Emu:~/nginx-0.8.54# ./configure --with-http_ssl_module

and got:
./configure: error: SSL modules require the OpenSSL library.
You can either do not enable the modules, or install the OpenSSL library
into the system, or build the OpenSSL library statically from the source
with nginx by using --with-openssl=<path> option.

However, doing 'which openssl' reveals that openssl is indeed installed at /usr/bin/openssl.

Is there somewhere that I should specify a path to OpenSSL so that configure picks it up? Is there something else I should be doing?

Thanks in advance.

Julius
Re: Compile Nginx on Ubuntu
March 05, 2011 03:42AM
OK, I have found some answers.

On a fresh Ubuntu install, despite the fact that 'which' shows a existent install of OpenSSL, you will still need some extra libs. You will also need some extra libs for PCRE which Nginx requires. So, before configuring, install the following:

sudo aptitude install libpcre3-dev

and also:

sudo aptitude install libssl-dev

After installing these, my ./configure command went like this:

./configure \
--prefix=/usr \
--conf-path=/etc/nginx/nginx.conf \
--http-log-path=/var/log/nginx/access.log \
--error-log-path=/var/log/nginx/error.log \
--pid-path=/var/run/nginx.pid \
--lock-path=/var/lock/nginx.lock \
--user=nginx \
--group=nginx \
--http-client-body-temp-path=/var/tmp/nginx/client \
--http-proxy-temp-path=/var/tmp/nginx/proxy \
--with-http_ssl_module \
--http-fastcgi-temp-path=/var/tmp/nginx/fastcgi

Also, because I have specified '--user=nginx' and '--group=nginx', we will need to run:

adduser --system --no-create-home --disabled-login --disabled-password --group nginx

The above will add the nginx user to the system.

Finally, I added the following config to /etc/nginx/nginx.conf:

user nginx;
worker_processes 6;

events {
worker_connections 1024;
}

http {
include mime.types;
default_type application/octet-stream;
sendfile on;
keepalive_timeout 10 10;

gzip on;
gzip_comp_level 1;
gzip_proxied any;
gzip_types text/plain text/html text/css application/x-javascript text/xml application/xml application/xml+rss text/javascript;

log_format main '$remote_addr - $remote_user [$time_local] '
'"$request" $status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';


server {
listen *:80;

location / {
root /var/www;
index index.php;

# if file exists return it right away
if (-f $request_filename) {
break;
}

# otherwise rewrite the fucker
if (!-e $request_filename) {
rewrite ^(.+)$ /index.php$1 last;
break;
}

}

# if the request starts with our frontcontroller, pass it on to fastcgi
location ~ ^/index.php
{
fastcgi_pass 127.0.0.1:9000;
fastcgi_param SCRIPT_FILENAME /var/www$fastcgi_script_name;
fastcgi_param PATH_INFO $fastcgi_script_name;
include /etc/nginx/fastcgi_params;
}
}
}


Please note that the above is just a quick, hacky config to ensure that everything is working. You will probably want to improve this to allow you to split up your config for vhosts, etc. See this for more: http://wiki.nginx.org/Configuration. Also, I have not gone through the installation of PHP-FPM (see below for more).

That's it.

References:
http://vladgh.com/blog/install-nginx-php-fpm-ubuntu-1004
http://recursive-design.com/blog/2010/03/16/compiling-nginx-with-flv-streaming-support-on-ubuntu/
http://interfacelab.com/nginx-php-fpm-apc-awesome/
Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 310
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