Difference between pages "Requirements" and "Package:Nginx"

From Funtoo
(Difference between pages)
Jump to: navigation, search
(Hardware required)
 
m
 
Line 1: Line 1:
== General Installation Requirements ==
+
{{Ebuild
 +
|Summary=Robust, small and high performance HTTP and reverse proxy server
 +
|CatPkg=www-servers/nginx
 +
|Maintainer=Daniel Robbins, Golodhrim,
 +
}}
  
=== Software required ===
+
[[Image:nginx.gif|frame]]
 +
== What is nginx ==
  
This page is intended to cover a basic overview about what tools and what hardware is required to sucessfully install and run a Funtoo Linux installation. In the installation documentation, [http://www.sysresccd.org/Main_Page SystemRescueCD] is recommended as installation media. But there are plenty of good LiveCDs out there and there also might be good reasons to using one of them instead of [http://www.sysresccd.org/Main_Page SystemRescueCD].
+
nginx (pronounced "engin-x") is a Web and reverse proxy server for HTTP, SMTP, POP3 and IMAP protocols. It focuses on high concurrency, performance and low memory usage. Nginx quickly delivers static content with efficient use of system resources, also dynamic content is delivered on a network using FastCGI, SCGI handlers for scripts, uWSGI application servers or Phusion Passenger module (atm broken in [http://funtoo.org funtoo]), further more it can serve a very capable software load balancer. It uses an asynchronos event-driven approach to handle requests which provides more predictable performance under load, in contrast to the Apache HTTP server model, that uses a threaded or process-oriented approach to handling request. Nginx is licensed under a BSD-like license and it runs on Unix, Linux, BSD variants, Mac OS X, Solaris, AIX and Microsoft Windows.  
  
This is intended to contain some information about what's at least needed to successfully do a Funtoo Linux Installation within the live media of your choice.
+
== Installation ==
  
==== Absolutely must have ====
+
=== USE flags ===
  
The live media of your choice must at least contain these executables to successfully install Funtoo Linux. Without these tools you won't be able to successfully install Funtoo Linux:
+
Before you can install nginx, there are the following USE-flags available, these can be set by ''/etc/portage/package.use'' or ''/etc/portage/package.use/nginx'', depending on your setup of package.use.
  
* <tt>chroot</tt>
+
* aio - Enables file AIO support
* <tt>tar</tt> (with <tt>xz</tt> support)
+
* debug - Enables extra debug codepaths, like asserts and extra output.
* <tt>wget</tt> (or equivalent)
+
* http - Enable http serving
* <tt>fdisk</tt> (for MBR partition tables)
+
* http-cache - Enables caching for http files
* <tt>gdisk</tt> (for GUID partition tables)
+
* ipv6 - Enables IPv6 support
* a text editor
+
* libatomic - Use libatomic instead of buildtin atomic operations
* 64-bit kernel for 64-bit installation, or:
+
* pcre - Enables support for Perl Compatible Regular Expressions
* 32-bit or 64-bit kernel for 32-bit installation
+
* ssl - Adds support for Secure Socket Layer connections
 +
* vim-syntax - Pulls in related vim syntax scripts
  
==== Recommended ====
+
Further more you can set the nginx modules you like to use in ''/etc/make.conf'' in the NGINX_MODULES_HTTP variable as NGINX_MODULES_HTTP="variables".
  
It is possible to install Funtoo Linux without these tools, but having them available makes your life easier during installation:
+
* access
 +
* addition
 +
* auth_basic
 +
* autoindex
 +
* browser
 +
* cache_purge
 +
* charset
 +
* dav
 +
* degradation
 +
* empty_gif
 +
* ey_balancer
 +
* fastcgi
 +
* flv
 +
* geo
 +
* geoip
 +
* gzip
 +
* gzip_static
 +
* headers_more
 +
* image_filter
 +
* limit_req
 +
* limit_zone
 +
* map
 +
* memcached
 +
* perl
 +
* proxy
 +
* push
 +
* random_index
 +
* realip
 +
* referer
 +
* rewrite
 +
* scgi
 +
* secure_link
 +
* slowfs_cache
 +
* split_clients
 +
* ssi
 +
* stub_status
 +
* sub
 +
* upload
 +
* upstream_ip_hash
 +
* userid
 +
* uwsgi
 +
* xslt
  
; GNU <tt>screen</tt> or <tt>tmux</tt>: You can do without, but since there are some parts during installation which take quite a long time to complete (such as compiling the kernel and tools) it might come handy to run all this stuff inside a screen session. This enables you to detach your session from your current screen, prevents you from canceling the current compile in case of a disconnected network connection and work in paralel with multiple shells without the need for opening multiple SSH sessions or terminals.
+
and the following mail modules as NGINX_MODULES_MAIL in '/etc/make.conf':
  
; xz-utils:  Since many files in Funtoo Linux are compressed with an LZMA compression algorithm (such as the stage files and portage snapshots) you will need these to extract the files from those archives. This is considered to be only a recommended requirement, since it's possible to download and extract the tar archive on another machine and download it from there in order to continue even with Live-Media, which do not provide this application (like several recovery images of "Root Server" providers).
+
* imap
 +
* pop3
 +
* smtp
  
=== Hardware required ===
+
=== USE Expanded flags ===
  
Funtoo Linux installs flawlessly on the following architectures:
+
nginx USE-flags go into ''/etc/portage/package.use'' or ''/etc/portage/package.use/nginx'', while the HTTP and MAIL modules go as NGINX_MODULES_HTTP or NGINX_MODULES_MAIL are stored in /etc/make.conf. And as you wouldn't server only static html files, but most commonly also php files/scripts you should also install php with fpm enabled and xcache for caching the content, what makes your nginx setup way faster. For xcache you need to set PHP_TARGETS="php5-3" in '/etc/make.conf'.
  
* amd64
+
Example:
* x86
+
<pre>
 +
echo "www-servers/nginx USE-FLAG-List" >> /etc/portage/package.use/nginx
 +
</pre>
  
You will need the following to successfully install Funtoo Linux, too:
+
=== Emerging nginx ===
  
* Live-Media to boot an installation environment
+
Now you are ready to install nginx with php and xcache support:
* Supported network device
+
<pre>
* 9 GB of disk space (including a 2 GB swap) for the basic system. Please be aware, that even though this is enough to install a very minimal environment, you will definitely face problems and a full disk very soon! So please consider this as the absolute minimum and consider to raise this by mounting additional space into multiple branches of the FS-Tree, soon.
+
emerge -avt nginx php xcache
 +
</pre>
 +
so now just check your useflags and press enter to start emerge.
  
=== Physical/Network Access ===
+
== Configuring ==
  
; Network: Please make sure there's a network connection available on the machine you are installing Funtoo Linux on. It might be possible to install Funtoo Linux without, by providing the needed resources by an USB media or such, but this isn't the intended way to do things. You will have some extra work to do to achieve this and though this way of installing isn't officially supported, you might be lucky and find someone who is passionate and patient enough to help you with this. But since you'll need a network connection to read within IRC and Forums, you might serve this connection to the destination machine in the first place and prevent you and others from getting gray hair in the first place.
+
All configuration is done in ''/etc/nginx'' with ''nginx.conf'' as the main configuration file and all virtual hosts in ''/etc/nginx/sites/available'' while you have to symlink ''/etc/nginx/sites-available/{VHOST}'' to ''/etc/nginx/sites-enabled/{VHOST}'' to activate them. An example config for such a {VHOST} looks like that:
; Physical access or at least a remote sight onto the console: This is important to diagnose potential bootup issues like missing modules in the kernel, not accessible filesystems, or issues with the bootloader configuration. It's important to be able to issue a reset in case of failure, too. You might need physical access to the machine to remove the Live-Media once you installed your machine, too and enter it in the first place.
+
  
__NOTITLE__
+
<pre>
 +
server {
 +
    listen          80;
 +
    server_name    www.example.com;
 +
 
 +
    access_log      /var/log/nginx/www.example.com.access_log main;
 +
    error_log      /var/log/nginx/www.example.com.error_log info;
 +
 
 +
    root /var/www/www.example.com/htdocs;
 +
}
 +
</pre>
 +
 
 +
The ''nginx.conf'' and ''sites-available/localhost'' file is well commented. Customize it to your needs. Make sure you set the listen option correctly. By default, the listen option is set to listen on the loopback interface. If you leave this unchanged other computers on the network will not be able to connect to the server.
 +
 
 +
== Configuring PHP FPM ==
 +
 
 +
As we already installed php with fpm support above we just need to adjust the following settings in ''/etc/php/fpm-php5.3/php-fpm.conf''. You should enable the following settings:
 +
 
 +
<pre>
 +
user = nginx
 +
group = nginx
 +
pm.start_servers = 20
 +
</pre>
 +
 
 +
The other options should all be very well documented, so make it fit your needs.
 +
 
 +
== Configuring xcache ==
 +
 
 +
For setting xcache just edit ''/etc/php/fpm-php5.3/ext-active/xcache''
 +
 
 +
<pre>
 +
zend_extension=/usr/lib64/php5.3/lib/extensions/no-debug-zts-20090626/          xcache.so                                                                 
 +
  2 xcache.admin.enable_auth="On"
 +
  3 xcache.admin.user="admin"
 +
  4 xcache.admin.pass=""
 +
  5 xcache.cacher="On"
 +
  6 xcache.size="64M"
 +
  7 xcache.count="9"
 +
  8 xcache.slots="8k"
 +
  9 xcache.ttl="0"
 +
10 xcache.gc_interval="0"
 +
11 xcache.var_size="8M"
 +
12 xcache.var_count="1"
 +
13 xcache.var_slots="8K"
 +
14 xcache.var_ttl="0"
 +
15 xcache.var_maxttl="0"
 +
16 xcache.var_gc_interval="600"
 +
17 xcache.readonly_protection="Off"
 +
18 xcache.mmap_path="/dev/zero"
 +
19 xcache.coverager="On"
 +
20 xcache.coveragedump_directory="/tmp/coverager"
 +
21 xcache.optimizer="On"
 +
</pre>
 +
 
 +
it might look like that for you, feel free to change the settings, and if you want to be able to log in into the admin interface set the ''xcache.admin.pass'' as a md5 encrypted password you can find it out with:
 +
 
 +
<pre>
 +
php -a
 +
php> echo md5(PASSWORD);
 +
</pre>
 +
 
 +
and copy the admin interface to your vhost:
 +
 
 +
<pre>
 +
cp /usr/share/php/xcache/admin -a /var/www/{VHOST}/htdocs/xcache-admin
 +
</pre>
 +
 
 +
== Starting the service ==
 +
 
 +
Now start the services:
 +
 
 +
<pre>
 +
/etc/init.d/php-fpm start
 +
/etc/init.d/nginx start
 +
</pre>
 +
 
 +
and make them default:
 +
 
 +
<pre>
 +
rc-update add php-fpm default
 +
rc-update add nginx default
 +
</pre>
 +
 
 +
== See also ==
 +
 
 +
== External links ==
 +
 
 +
[[Category:Featured]]
 +
{{EbuildFooter}}

Revision as of 06:56, 24 March 2014

www-servers/nginx


Current Maintainer(s):Daniel Robbins
Martin Scholz
Source Repository:Funtoo Overlay

Summary: Robust, small and high performance HTTP and reverse proxy server

Nginx

Nginx.gif

What is nginx

nginx (pronounced "engin-x") is a Web and reverse proxy server for HTTP, SMTP, POP3 and IMAP protocols. It focuses on high concurrency, performance and low memory usage. Nginx quickly delivers static content with efficient use of system resources, also dynamic content is delivered on a network using FastCGI, SCGI handlers for scripts, uWSGI application servers or Phusion Passenger module (atm broken in funtoo), further more it can serve a very capable software load balancer. It uses an asynchronos event-driven approach to handle requests which provides more predictable performance under load, in contrast to the Apache HTTP server model, that uses a threaded or process-oriented approach to handling request. Nginx is licensed under a BSD-like license and it runs on Unix, Linux, BSD variants, Mac OS X, Solaris, AIX and Microsoft Windows.

Installation

USE flags

Before you can install nginx, there are the following USE-flags available, these can be set by /etc/portage/package.use or /etc/portage/package.use/nginx, depending on your setup of package.use.

  • aio - Enables file AIO support
  • debug - Enables extra debug codepaths, like asserts and extra output.
  • http - Enable http serving
  • http-cache - Enables caching for http files
  • ipv6 - Enables IPv6 support
  • libatomic - Use libatomic instead of buildtin atomic operations
  • pcre - Enables support for Perl Compatible Regular Expressions
  • ssl - Adds support for Secure Socket Layer connections
  • vim-syntax - Pulls in related vim syntax scripts

Further more you can set the nginx modules you like to use in /etc/make.conf in the NGINX_MODULES_HTTP variable as NGINX_MODULES_HTTP="variables".

  • access
  • addition
  • auth_basic
  • autoindex
  • browser
  • cache_purge
  • charset
  • dav
  • degradation
  • empty_gif
  • ey_balancer
  • fastcgi
  • flv
  • geo
  • geoip
  • gzip
  • gzip_static
  • headers_more
  • image_filter
  • limit_req
  • limit_zone
  • map
  • memcached
  • perl
  • proxy
  • push
  • random_index
  • realip
  • referer
  • rewrite
  • scgi
  • secure_link
  • slowfs_cache
  • split_clients
  • ssi
  • stub_status
  • sub
  • upload
  • upstream_ip_hash
  • userid
  • uwsgi
  • xslt

and the following mail modules as NGINX_MODULES_MAIL in '/etc/make.conf':

  • imap
  • pop3
  • smtp

USE Expanded flags

nginx USE-flags go into /etc/portage/package.use or /etc/portage/package.use/nginx, while the HTTP and MAIL modules go as NGINX_MODULES_HTTP or NGINX_MODULES_MAIL are stored in /etc/make.conf. And as you wouldn't server only static html files, but most commonly also php files/scripts you should also install php with fpm enabled and xcache for caching the content, what makes your nginx setup way faster. For xcache you need to set PHP_TARGETS="php5-3" in '/etc/make.conf'.

Example:

echo "www-servers/nginx USE-FLAG-List" >> /etc/portage/package.use/nginx

Emerging nginx

Now you are ready to install nginx with php and xcache support:

emerge -avt nginx php xcache

so now just check your useflags and press enter to start emerge.

Configuring

All configuration is done in /etc/nginx with nginx.conf as the main configuration file and all virtual hosts in /etc/nginx/sites/available while you have to symlink /etc/nginx/sites-available/{VHOST} to /etc/nginx/sites-enabled/{VHOST} to activate them. An example config for such a {VHOST} looks like that:

server {
    listen          80;
    server_name     www.example.com;

    access_log      /var/log/nginx/www.example.com.access_log main;
    error_log       /var/log/nginx/www.example.com.error_log info;

    root /var/www/www.example.com/htdocs;
}

The nginx.conf and sites-available/localhost file is well commented. Customize it to your needs. Make sure you set the listen option correctly. By default, the listen option is set to listen on the loopback interface. If you leave this unchanged other computers on the network will not be able to connect to the server.

Configuring PHP FPM

As we already installed php with fpm support above we just need to adjust the following settings in /etc/php/fpm-php5.3/php-fpm.conf. You should enable the following settings:

user = nginx
group = nginx
pm.start_servers = 20

The other options should all be very well documented, so make it fit your needs.

Configuring xcache

For setting xcache just edit /etc/php/fpm-php5.3/ext-active/xcache

zend_extension=/usr/lib64/php5.3/lib/extensions/no-debug-zts-20090626/          xcache.so                                                                   
  2 xcache.admin.enable_auth="On"
  3 xcache.admin.user="admin"
  4 xcache.admin.pass=""
  5 xcache.cacher="On"
  6 xcache.size="64M"
  7 xcache.count="9"
  8 xcache.slots="8k"
  9 xcache.ttl="0"
 10 xcache.gc_interval="0"
 11 xcache.var_size="8M"
 12 xcache.var_count="1"
 13 xcache.var_slots="8K"
 14 xcache.var_ttl="0"
 15 xcache.var_maxttl="0"
 16 xcache.var_gc_interval="600"
 17 xcache.readonly_protection="Off"
 18 xcache.mmap_path="/dev/zero"
 19 xcache.coverager="On"
 20 xcache.coveragedump_directory="/tmp/coverager"
 21 xcache.optimizer="On"

it might look like that for you, feel free to change the settings, and if you want to be able to log in into the admin interface set the xcache.admin.pass as a md5 encrypted password you can find it out with:

php -a
php> echo md5(PASSWORD);

and copy the admin interface to your vhost:

cp /usr/share/php/xcache/admin -a /var/www/{VHOST}/htdocs/xcache-admin

Starting the service

Now start the services:

/etc/init.d/php-fpm start
/etc/init.d/nginx start

and make them default:

rc-update add php-fpm default
rc-update add nginx default

See also

External links