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

From Funtoo
(Difference between pages)
Jump to navigation Jump to search
m (add up some php caching.)
 
 
Line 1: Line 1:
{{Ebuild
{{Ebuild
|Summary=Robust, small and high performance HTTP and reverse proxy server
|Summary=A small, dynamic tiling window manager for X11.
|CatPkg=www-servers/nginx
|CatPkg=x11-wm/spectrwm
|Maintainer=Drobbins
|Maintainer=
|Repository=Funtoo Overlay
|Homepage=https://opensource.conformal.com/wiki/spectrwm
|Overlay=Funtoo
}}
}}  
[[Image:nginx.gif|frame]]


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.  
{{Note|Spectrwm was previously known as Scrotwm.}}


=== USE Expanded flags ===
==== Introduction ====
From their page:
spectrwm is a small dynamic tiling window manager for X11. It tries to stay out of the way so that valuable screen real estate can be used for much more important stuff. It has sane defaults and does not require one to learn a language to do any configuration. It was written by hackers for hackers and it strives to be small, compact and fast.


Furthermore, 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".


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:
==== Installation ====
<console>
<console>
###i## echo "www-servers/nginx USE-FLAG-List" >> /etc/portage/package.use/nginx
# ##i##emerge x11-wm/spectrwm
</console>
</console>
 
Xlockmore is also needed
=== Emerging nginx ===
 
Now you are ready to install nginx with php and xcache support:
<console>
<console>
###i## emerge -avt nginx php xcache
# ##i##emerge x11-misc/xlockmore
</console>
</console>
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:


==== Setup ====
===== xinitrc =====
Edit ~/.xinitrc:
<pre>
<pre>
server {
exec spectrwm
    listen          80;
</pre>
    server_name    www.example.com;
Copy /etc/spectrwm.conf to your home dir as an hidden file.
 
<console>
    access_log      /var/log/nginx/www.example.com.access_log main;
$ ##i## cp /etc/spectrwm.conf ~/.spectrwm.conf
    error_log      /var/log/nginx/www.example.com.error_log info;
</console>
 
You can edit spectrwm.conf to suit your needs. The file is thoroughly commented so you won't feel lost.
    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.
 
=== php-fpm ===
 
nginx does not natively support php, so we delegate that responsibility to [[Package:Php#Fpm | php-fpm]]
 
{{file|name=/etc/nginx/sites-available/localhost|desc=fpm configuration|body=
server {
        ...
index index.php index.cgi index.htm index.html;
location ~ .php$ {
        fastcgi_pass 127.0.0.1:9000;
include fastcgi.conf;
        }
        ...
}
}}
 
==== php caching ====
{{file|name=/etc/nginx/sites-available/localhost|desc=fpm cache configuration|body=
fastcgi_cache_path /etc/nginx/cache levels=1:2 keys_zone=MYAPP:100m inactive=60m;
fastcgi_cache_key "$scheme$request_method$host$request_uri";
server {
...
        location ~ \.php$ {
...
fastcgi_cache MYAPP;
fastcgi_cache_valid 200 60m;
...
}}
[https://www.digitalocean.com/community/tutorials/how-to-setup-fastcgi-caching-with-nginx-on-your-vps for more information on php caching]
 
=== proxy_pass===
This configuration proxies to other webservers.  In this example we have webrick running on port 3000 behind nginx producing the live link http://localhost/rails
 
{{file|name=/etc/nginx/sites-available/localhost|desc=rails or python configurations|body=
server {
        ...
location /rails/ {
    proxy_set_header Host $host;
    proxy_set_header X-Real-IP $remote_addr;
    proxy_pass http://127.0.0.1:3000/; #for ruby on rails webrick
            #proxy_pass http://127.0.0.1:8000/; #for python -m http.server
            #proxy_pass http://127.0.0.1:8080/; #for other web servers like apache, lighttpd, tengine, cherokee, etc...
}
        ...
}
}}
 
== Location Processing Order ==
One often confusing aspect of nginx configuration is the order in which it processes location directives. This section is intended to clarify the confusion and help you to write secure nginx location directives.
 
=== Two basic types of Location directives ===
There are two basic types of location directives. The first is called a "conventional string", and looks something like this:
location /foo { deny all; }
The second basic type of location directive is a regex, or regular expression block. In its most basic form, it looks like this, with a "~" and then a regular expression that is matched against the request path. "^" can be used to match the beginning of the request path, and "$" can be used to match the end of the request path. If you need to match a ".", you must escape it as "\." as per regular expression matching rules:
location ~ \.php$ { blah; }
 
=== The basic algorithm ===
Nginx uses a special algorithm to find the proper location string to match the incoming request. The basic concept to remember is that conventional string directives are placed in one "bucket", and then regular expression strings are placed in another "bucket". Nginx will use the first regular expression match that it finds, when scanning the file from top to bottom. If no matching regular expression is found, nginx will look in its "conventional string" bucket, and try to find a match. In the case of the conventional string matches, the most ''specific'' match will be used, in other words, the one will be used that matches the greatest number of characters in the request path.
 
This is the foundation for nginx location processing, so always use these rules as a starting point for understanding location matching order. Nginx then provides various sub-types of location directives which modify this default behavior in a number of ways. This will be covered in the next section.
 
== Advanced Location Processing ==
Always use the location processing logic described in the previous section as the foundation for understanding how nginx finds a matching location directive, and then once you are comfortable with how this works, read about these more advanced directives and understand how they fit into nginx's overall logic.
 
=== = (equals) Location ===
One advanced location directive is the "=" location, which can be considered a variant of a "conventional string" directive. "=" directives are searched before all other directives, and if a match found, then the corresponding location block is used. A "=" location must the requested path ''exactly'' and ''completely''. For example, the following location block will match only the request /foo/bar, but not /foo/bar/oni.html:
location = /foo/bar { deny all; }


=== ~* (case-insensitive regex) Location ===
==== Bindings (default) ====
A "~*" regex match is just like a regular "~" regex match, except matches will be performed in a case-insensitive manner. "~*" location directives, being regex directives, fall into the regex "bucket" and are processed along other regex directives. This means that they are processed in the order they appear in your configuration file and the first match will be used -- assuming no "=" directives match.
{{Note|Usually the M (Modus) key is either alt or the super key.}}
From the man page:


=== ^~ (short-circuit conventional string) Location ===
BINDINGS
You may think that a "^~" location is a regex location, but it is not. It is a variant of a conventional string location. If you recall, nginx will search for conventional string matches by finding the ''most specific'' match. However, when you use a "^~" location, nginx behavior is modified. Imagine the way a conventional string match works. Nginx scans your configuration file, looking at each conventional string match from line 1 to the end of file, but it scans ''all'' conventional string matches to find the ''best'' match. Well, the "~^" location match short-circuits this process. If, in the process of scanning each conventional string match in the config file, nginx encounters a "^~" match that matches the current request path, then nginx will apply this match, and stop looking for the ''best'' match.


== Ebuild Update Protocol ==
    spectrwm provides many functions (or actions) accessed via key or mouse
    bindings.


To work on a new version of the ebuild, perform the following steps.
    The current mouse bindings are described below:
{| class="wikitable sortable"
|-
! Mouse binding  !! description
|-
| M1 || Focus window
|-
| M-M1 || Move window
|-
| M-M3|| Resize window
|-
| M-S-M3|| Resize window while maintaining it centered
|}                     


First, temporarily set the following settings in <tt>/etc/make.conf</tt>:
    The default key bindings are described below:


<syntaxhighlight lang="bash">
          M-S-<Return>        term
NGINX_MODULES_HTTP="*"
          M-p                menu
NGINX_MODULES_MAIL="*"
          M-S-q              quit
</syntaxhighlight>
          M-q                restart
          M-<Space>          cycle_layout
          M-S-<\>            flip_layout
          M-S-<Space>        stack_reset
          M-h                master_shrink
          M-l                master_grow
          M-,                master_add
          M-.                master_del
          M-S-,              stack_inc
          M-S-.              stack_dec
          M-<Return>          swap_main
          M-j, M-<TAB>        focus_next
          M-k, M-S-<TAB>      focus_prev
          M-m                focus_main
          M-S-j              swap_next
          M-S-k              swap_prev
          M-b                bar_toggle
          M-S-b              bar_toggle_ws
          M-x                wind_del
          M-S-x              wind_kill
          M-<1-9,0,F1-F12>    ws_<1-22>
          M-S-<1-9,0,F1-F12>  mvws_<1-22>
          M-<Keypad 1-9>      rg_<1-9>
          M-S-<Keypad 1-9>    mvrg_<1-9>
          M-<Right>          ws_next
          M-<Left>            ws_prev
          M-<Up>              ws_next_all
          M-<Down>            ws_prev_all
          M-a                ws_next_move
          M-S-<Left>          ws_prev_move
          M-S-<Up>            ws_prior
          M-S-<Right>        rg_next
          M-S-<Left>          rg_prev
          M-s                screenshot_all
          M-S-s              screenshot_wind
          M-S-v              version
          M-t                float_toggle
          M-S-<Delete>       lock
          M-S-i              initscr
          M-w                iconify
          M-S-w              uniconify
          M-S-r              always_raise
          M-v                button2
          M--                width_shrink
          M-=                 width_grow
          M-S--              height_shrink
          M-S-=               height_grow
          M-[                move_left
          M-]                move_right
          M-S-[              move_up
          M-S-]              move_down
          M-S-/              name_workspace
          M-/                 search_workspace
          M-f                search_win


This will enable all available modules for nginx.
The action names and descriptions are listed below:


Now, create a new version of the ebuild in your overlay, and look at all the modules listed at the top of the ebuild. Visit the URLs in the comments above each one and ensure that the latest versions of each are included. Now run <tt>ebuild nginx-x.y.ebuild clean install</tt> to ensure that all modules patch/build properly. Basic build testing is now complete.
          term              Spawn a new terminal (see PROGRAMS above).
          menu              Menu (see PROGRAMS above).
          quit              Quit spectrwm.
          restart          Restart spectrwm.
          cycle_layout      Cycle layout.
          flip_layout      Swap the master and stacking areas.
          stack_reset      Reset layout.
          master_shrink    Shrink master area.
          master_grow      Grow master area.
          master_add        Add windows to master area.
          master_del        Remove windows from master area.
          stack_inc        Add columns/rows to stacking area.
          stack_dec        Remove columns/rows from stacking area.
          swap_main        Move current window to master area.
          focus_next        Focus next window in workspace.
          focus_prev        Focus previous window in workspace.
          focus_main        Focus on main window in workspace.
          swap_next        Swap with next window in workspace.
          swap_prev        Swap with previous window in workspace.
          bar_toggle        Toggle overall visibility of status bars.
          bar_toggle_ws    Toggle status bar on current workspace.
          wind_del          Delete current window in workspace.
          wind_kill        Destroy current window in workspace.
          ws_n              Switch to workspace n, where n is 1 through
                            workspace_limit.
          mvws_n            Move current window to workspace n, where n is 1
                            through workspace_limit.
          rg_n              Focus on region n, where n is 1 through 9.
          mvrg_n            Move current window to region n, where n is 1
                            through 9.
          ws_next          Switch to next workspace with a window in it.
          ws_prev          Switch to previous workspace with a window in it.
          ws_next_all      Switch to next workspace.
          ws_prev_all      Switch to previous workspace.
          ws_next_move      Switch to next workspace with the current window.
          ws_prev_move      Switch to previous workspace with the current
                            window.
          ws_prior          Switch to last visited workspace.
          rg_next          Switch to next region.
          rg_prev          Switch to previous region.
          screenshot_all    Take screenshot of entire screen (if enabled)
                            (see PROGRAMS above).
          screenshot_wind  Take screenshot of selected window (if enabled)
                            (see PROGRAMS above).
          version          Toggle version in status bar.
          float_toggle      Toggle focused window between tiled and floating.
          lock              Lock screen (see PROGRAMS above).
          initscr          Reinitialize physical screens (see PROGRAMS
                            above).
          iconify          Minimize (unmap) currently focused window.
          uniconify        Maximize (map) window returned by dmenu
                            selection.
          always_raise      When set tiled windows are allowed to obscure
                            floating windows.
          button2          Fake a middle mouse button click (mouse button
                            2).
          width_shrink      Shrink the width of a floating window.
          width_grow        Grow the width of a floating window.
          height_shrink    Shrink the height of a floating window.
          height_grow      Grow the height of a floating window.
          move_left        Move a floating window a step to the left.
          move_right        Move a floating window a step to the right.
          move_up          Move a floating window a step upwards.
          move_down        Move a floating window a step downwards.
          name_workspace    Name the current workspace.
          search_workspace  Search for a workspace.
          search_win        Search the windows in the current workspace.
{{EbuildFooter}}
{{EbuildFooter}}

Revision as of 02:54, November 17, 2014

Spectrwm

   Tip

We welcome improvements to this page. To edit this page, Create a Funtoo account. Then log in and then click here to edit this page. See our editing guidelines to becoming a wiki-editing pro.


   Note

Spectrwm was previously known as Scrotwm.

Introduction

From their page: spectrwm is a small dynamic tiling window manager for X11. It tries to stay out of the way so that valuable screen real estate can be used for much more important stuff. It has sane defaults and does not require one to learn a language to do any configuration. It was written by hackers for hackers and it strives to be small, compact and fast.


Installation

root # emerge x11-wm/spectrwm 

Xlockmore is also needed

root # emerge x11-misc/xlockmore


Setup

xinitrc

Edit ~/.xinitrc:

exec spectrwm

Copy /etc/spectrwm.conf to your home dir as an hidden file.

 $  cp /etc/spectrwm.conf ~/.spectrwm.conf

You can edit spectrwm.conf to suit your needs. The file is thoroughly commented so you won't feel lost.

Bindings (default)

   Note

Usually the M (Modus) key is either alt or the super key.

From the man page:

BINDINGS

    spectrwm provides many functions (or actions) accessed via key or mouse
    bindings.
    The current mouse bindings are described below:
Mouse binding description
M1 Focus window
M-M1 Move window
M-M3 Resize window
M-S-M3 Resize window while maintaining it centered
    The default key bindings are described below:
          M-S-<Return>        term
          M-p                 menu
          M-S-q               quit
          M-q                 restart
          M-<Space>           cycle_layout
          M-S-<\>             flip_layout
          M-S-<Space>         stack_reset
          M-h                 master_shrink
          M-l                 master_grow
          M-,                 master_add
          M-.                 master_del
          M-S-,               stack_inc
          M-S-.               stack_dec
          M-<Return>          swap_main
          M-j, M-<TAB>        focus_next
          M-k, M-S-<TAB>      focus_prev
          M-m                 focus_main
          M-S-j               swap_next
          M-S-k               swap_prev
          M-b                 bar_toggle
          M-S-b               bar_toggle_ws
          M-x                 wind_del
          M-S-x               wind_kill
          M-<1-9,0,F1-F12>    ws_<1-22>
          M-S-<1-9,0,F1-F12>  mvws_<1-22>
          M-<Keypad 1-9>      rg_<1-9>
          M-S-<Keypad 1-9>    mvrg_<1-9>
          M-<Right>           ws_next
          M-<Left>            ws_prev
          M-<Up>              ws_next_all
          M-<Down>            ws_prev_all
          M-a                 ws_next_move
          M-S-<Left>          ws_prev_move
          M-S-<Up>            ws_prior
          M-S-<Right>         rg_next
          M-S-<Left>          rg_prev
          M-s                 screenshot_all
          M-S-s               screenshot_wind
          M-S-v               version
          M-t                 float_toggle
          M-S-<Delete>        lock
          M-S-i               initscr
          M-w                 iconify
          M-S-w               uniconify
          M-S-r               always_raise
          M-v                 button2
          M--                 width_shrink
          M-=                 width_grow
          M-S--               height_shrink
          M-S-=               height_grow
          M-[                 move_left
          M-]                 move_right
          M-S-[               move_up
          M-S-]               move_down
          M-S-/               name_workspace
          M-/                 search_workspace
          M-f                 search_win

The action names and descriptions are listed below:

          term              Spawn a new terminal (see PROGRAMS above).
          menu              Menu (see PROGRAMS above).
          quit              Quit spectrwm.
          restart           Restart spectrwm.
          cycle_layout      Cycle layout.
          flip_layout       Swap the master and stacking areas.
          stack_reset       Reset layout.
          master_shrink     Shrink master area.
          master_grow       Grow master area.
          master_add        Add windows to master area.
          master_del        Remove windows from master area.
          stack_inc         Add columns/rows to stacking area.
          stack_dec         Remove columns/rows from stacking area.
          swap_main         Move current window to master area.
          focus_next        Focus next window in workspace.
          focus_prev        Focus previous window in workspace.
          focus_main        Focus on main window in workspace.
          swap_next         Swap with next window in workspace.
          swap_prev         Swap with previous window in workspace.
          bar_toggle        Toggle overall visibility of status bars.
          bar_toggle_ws     Toggle status bar on current workspace.
          wind_del          Delete current window in workspace.
          wind_kill         Destroy current window in workspace.
          ws_n              Switch to workspace n, where n is 1 through
                            workspace_limit.
          mvws_n            Move current window to workspace n, where n is 1
                            through workspace_limit.
          rg_n              Focus on region n, where n is 1 through 9.
          mvrg_n            Move current window to region n, where n is 1
                            through 9.
          ws_next           Switch to next workspace with a window in it.
          ws_prev           Switch to previous workspace with a window in it.
          ws_next_all       Switch to next workspace.
          ws_prev_all       Switch to previous workspace.
          ws_next_move      Switch to next workspace with the current window.
          ws_prev_move      Switch to previous workspace with the current
                            window.
          ws_prior          Switch to last visited workspace.
          rg_next           Switch to next region.
          rg_prev           Switch to previous region.
          screenshot_all    Take screenshot of entire screen (if enabled)
                            (see PROGRAMS above).
          screenshot_wind   Take screenshot of selected window (if enabled)
                            (see PROGRAMS above).
          version           Toggle version in status bar.
          float_toggle      Toggle focused window between tiled and floating.
          lock              Lock screen (see PROGRAMS above).
          initscr           Reinitialize physical screens (see PROGRAMS
                            above).
          iconify           Minimize (unmap) currently focused window.
          uniconify         Maximize (map) window returned by dmenu
                            selection.
          always_raise      When set tiled windows are allowed to obscure
                            floating windows.
          button2           Fake a middle mouse button click (mouse button
                            2).
          width_shrink      Shrink the width of a floating window.
          width_grow        Grow the width of a floating window.
          height_shrink     Shrink the height of a floating window.
          height_grow       Grow the height of a floating window.
          move_left         Move a floating window a step to the left.
          move_right        Move a floating window a step to the right.
          move_up           Move a floating window a step upwards.
          move_down         Move a floating window a step downwards.
          name_workspace    Name the current workspace.
          search_workspace  Search for a workspace.
          search_win        Search the windows in the current workspace.