ラベル apache の投稿を表示しています。 すべての投稿を表示
ラベル apache の投稿を表示しています。 すべての投稿を表示

2014/12/19

linux apache2.4 module memo

■proxyモジュール多いね
LoadModule proxy_module modules/mod_proxy.so
LoadModule lbmethod_bybusyness_module modules/mod_lbmethod_bybusyness.so
LoadModule lbmethod_byrequests_module modules/mod_lbmethod_byrequests.so
LoadModule lbmethod_bytraffic_module modules/mod_lbmethod_bytraffic.so
LoadModule lbmethod_heartbeat_module modules/mod_lbmethod_heartbeat.so
LoadModule proxy_ajp_module modules/mod_proxy_ajp.so
LoadModule proxy_balancer_module modules/mod_proxy_balancer.so
LoadModule proxy_connect_module modules/mod_proxy_connect.so
LoadModule proxy_express_module modules/mod_proxy_express.so
LoadModule proxy_fcgi_module modules/mod_proxy_fcgi.so
LoadModule proxy_fdpass_module modules/mod_proxy_fdpass.so
LoadModule proxy_ftp_module modules/mod_proxy_ftp.so
LoadModule proxy_http_module modules/mod_proxy_http.so
LoadModule proxy_scgi_module modules/mod_proxy_scgi.so


/etc/httpd/conf.d/proxy.conf
=->/etc/httpd/conf.modules.d/00-proxy.conf

・apache 設定ファイル

UseCanonicalName
    サーバが自分自身の名前とポートを決定する方法を設定する
    canonical--->正典的。ネーミングは良くない。自分自身でown?

==>onの場合
 ServerName ディレクティブで指定されている ホスト名とポート番号を使って、その正規名 (自己参照の名前) を生成します
 じゃないと、ServerNameは意味がないだね。
==>offの場合
 UseCanonicalName Off の場合、 クライアントがホスト名とポートを指定したときには、 それらを元に自己参照 URL を作成します (指定がなかったときは 上の定義と同様にして正規名を解決します)

これぐらいだね。。。。
====>URL が最後のスラッシュ無しの ディレクトリになっている http://www/splat のようなとき、 Apache はリクエストを http://www.domain.com/splat/ へリダイレクトします


★apache Access Control
=->mod_authz_core
   mod_authz_host
  
・mod_rewrite
   ==>
   RewriteEngine On
   RewriteCond %{TIME_HOUR} >= 20 {OR}
   RewriteCond %{TIME_HOUR} < 07
   RewriteRule ^/fridge - [F]
   ==>The [F] RewriteRule flag causes a 403 Forbidden response to be sent
   07-20の間にOK
  
・ Require
  RequireAll
  RequireAny
  RequireNone
  =>Allow Deny Orderはdeprecated...........

<RequireAll>
    Require all granted
    Require not ip 10.252.46.165
    Require not host host.example.com
</RequireAll>

Require expr %{HTTP_USER_AGENT} != 'BadBot'
==>あいつだけだめ。。。


 Options Includes,FollowSymLinks
  =->FollowSymLinks シンボリックリンクファイルを認識させるかを設定します。
  =->Includes SSI を実行できるかどうかを設定します
 
.htaccess ファイル
==>AllowOverrideはnone、httpd.confで設定すれば、htaccessの設定は無効になる



★apache httpd module

apache mod-dav-------------
文字や画像、音声、動画などの要素を組み合わせて一つのソフトウェアやコンテンツ作品を組み立てること。

異なる種類の素材データを組み合わせ、配置や出現順、利用者の操作に対する反応などを設定していく編集作業を意味するが、(従来は必須であった)プログラミング言語やマークアップ言語などによるコードの記述を極力廃し、マウス操作など直感的な方法で作業を進めるという含意がある。

多くの場合、そのような作業に対応した専用のソフトウェアが用いられ、「オーサリングソフト」「オーサリングツール」などと呼ばれる。多くのツールは上級者が複雑な設定を行うことができるよう、補助的にプログラミングができるようになっていることが多い。

Apache Module mod_lua-------
==>this module allows the server to be extended with scripts written in the Lua programming language

Luaは、C言語のホストプログラムに組み込まれることを目的に設計されており、高速な動作と、高い移植性、組み込みの容易さが特徴である。いったんバイトコードにコンパイルされ、Lua VMで実行される。LuaJITは The Computer Language Benchmarks Game によると、変数に型のないスクリプト言語では最速の言語・処理系である[1]。


event------------------------------------
The event MPM handles some connections in an asynchronous way, where request worker threads are only allocated for short periods of time as needed, and other connections with one request worker thread reserved per connection. This can lead to situations where all workers are tied up and no worker thread is available to handle new work on established async connections.

To mitigate this problem, the event MPM does two things: Firstly, it limits the number of connections accepted per process, depending on the number of idle request workers. Secondly, if all workers are busy, it will close connections in keep-alive state even if the keep-alive timeout has not expired. This allows the respective clients to reconnect to a different process which may still have worker threads available.

This directive can be used to fine-tune the per-process connection limit. A process will only accept new connections if the current number of connections (not counting connections in the "closing" state) is lower than:

ThreadsPerChild + (AsyncRequestWorkerFactor * number of idle workers)

This means the absolute maximum numbers of concurrent connections is:

(AsyncRequestWorkerFactor + 1) * MaxRequestWorkers

MaxRequestWorkers was called MaxClients prior to version 2.3.13. The above value shows that the old name did not accurately describe its meaning for the event MPM.

AsyncRequestWorkerFactor can take non-integer arguments, e.g "1.5".

モジュールhttpd-------------
httpd -l
===>Compiled in modules

httpd -M==>モジュールの一覧

★TraceEnable off
HTTPのメソッドには、よく使うものとしてGETやPOSTというものがありますが、TRACEメソッドというものがありまして、これを有効にしておくと危ないよという話

==>なんか情報漏れので、無効にする


<IfModule mime_module>
 TypesConfig /etc/mime.types

</IfModule>


★mod_filter
This module enables smart, context-sensitive configuration of output content filters.
For example, apache can be configured to process different content-types through different filters,
even when the content-type is not known in advance (e.g. in a proxy).

★indirection -->間接参照、遠回し
AddOutputFilter
complex boolean expressions

FilterDeclare

★Register Providers
    FilterProviders
   
   

★2.4系
LogLevel alert rewrite:trace3

2014/10/03

apache Invalid command 'Order'Add Star

LoadModule authz_host_module modules/mod_authz_host.so
=>load module mod_access_compat, or update configuration to 2.4 authorization directives.

2014/06/13

php window apache Cannot load php5apache2_4.dll into server

==>Cannot load php5apache2_4.dll into server

==>apacheは86であれば、phpも86にする。

なおしたところVC9 x86 Thread Safeをインストールし直したところ次のステップに進むことができました。ありがとうございました。


apache2_4!!!!apache2_2?

Removing the Apache Tomcat runtime from a project in Eclipse

I had a similar problem. I had a prject referring to a no more existing Tomcat instance. I was not able to remove Tomcat from "Server" and "Runtime Environments" from UI (delete button always gray),so I solved the problem deleting all the reference from the filesystem:

In project folder check files:

    .classpath
    .settings/org.eclipse.wst.common.project.facet.core.xml

In workspace folder check:

    .metadata.plugins\org.eclipse.debug.core
    .metadata.plugins\org.eclipse.wst.server.core
    .metadata.plugins\org.eclipse.core.runtime.settings\org.eclipse.jst.server.tomcat.core.prefs

Maybe a bit brutal but I didn't find a better solution.

2013/10/24

apache mod_status

apache2.2.15で、何もしなくても利用できた。。。=>別の人が設定した。
apachectl status


(1)
ExtendedStatus On         <--コメントを外す

(2)
<Location /server-status>    <--コメントを外す
    SetHandler server-status
    Order deny,allow
    Deny from all
    Allow from 192.168.0.   <--192.168.0からのアクセスを許可
</Location>

(3)LoadModule cache_module modules/mod_status.so

アクセス:
http://www/server-status/
apachectl status

2013/10/11

tomcat apache mod_jk 設定、デバッグログ出力

LoadModule    jk_module  libexec/mod_jk.so
AddModule     mod_jk.c
JkWorkersFile /usr/local/jakarta-tomcat/conf/workers.properties
JkLogFile     /usr/local/apache/logs/mod_jk.log
JkLogLevel    debug、info、error、emerg
JkLogStampFormat "[%a %b %d %H:%M:%S %Y] "

Apache License

他のフリーソフトウェア向けライセンスと同様、Apache Licenseではユーザーがそのソフトウェアの使用や頒布、修正、派生版の頒布をすることを制限しない。

Apache Licenseは、頒布される二次的著作物が同じライセンスで提供されたり、フリーソフトウエア、オープンソースソフトウェアとして頒布されることを要求しない。要求するのは、ユーザーがそのソフトウェアにApache Licenseのコードが使われていることを知らせる文言を入れることだけである。従って、コピーレフトライセンスと異なり、Apache Licenseコードの二次創作物のユーザーには、フリーなライセンスが適用されない可能性もある

ライセンスされたファイルそれぞれに元々ある著作権と特許権の記述はそのまま保持されなければならず、何らかの修正が施されている場合は、その旨を追加記述しなければならない

2013/09/13

org.apache.catalina.Lifecycle

 *            start()
 *  -----------------------------
 *  |                           |
 *  | init()                    |
 * NEW ->-- INITIALIZING        |
 * | |           |              |     ------------------<-----------------------
 * | |           |auto          |     |                                        |
 * | |          \|/    start() \|/   \|/     auto          auto         stop() |
 * | |      INITIALIZED -->-- STARTING_PREP -->- STARTING -->- STARTED -->---  |
 * | |         |                                                  |         |  |
 * | |         |                                                  |         |  |
 * | |         |                                                  |         |  |
 * | |destroy()|                                                  |         |  |
 * | -->-----<--       auto                    auto               |         |  |
 * |     |       ---------<----- MUST_STOP ---------------------<--         |  |
 * |     |       |                                                          |  |
 * |    \|/      ---------------------------<--------------------------------  ^
 * |     |       |                                                             |
 * |     |      \|/            auto                 auto              start()  |
 * |     |  STOPPING_PREP ------>----- STOPPING ------>----- STOPPED ---->------
 * |     |                                ^                  |  |  ^
 * |     |               stop()           |                  |  |  |
 * |     |       --------------------------                  |  |  |
 * |     |       |                                  auto     |  |  |
 * |     |       |                  MUST_DESTROY------<-------  |  |
 * |     |       |                    |                         |  |
 * |     |       |                    |auto                     |  |
 * |     |       |    destroy()      \|/              destroy() |  |
 * |     |    FAILED ---->------ DESTROYING ---<-----------------  |
 * |     |                        ^     |                          |
 * |     |     destroy()          |     |auto                      |
 * |     -------->-----------------    \|/                         |
 * |                                 DESTROYED                     |
 * |                                                               |
 * |                            stop()                             |
 * --->------------------------------>------------------------------

2013/09/12

tomcat apache loadblancer worker

エラーが出った。。
The attribute 'worker.loadbalancer.balanced_workers' is deprecated - please check the documentation for the correct replacement.
=>loadbalancerはworkerであり、更に代表なworkerである



mod-jk.conf:
--------
#URLマッピング
JkMount /* loadbalancer
----------



workers.properties
--------
worker.list=tomcat1,tomcat2,loadbalancer

#tomcat1ワーカー
worker.tomcat1.port=18009
worker.tomcat1.host=localhost
worker.tomcat1.type=ajp13
worker.tomcat1.lbfactor=1

#tomcat2ワーカー
worker.tomcat2.port=28009
worker.tomcat2.host=localhost
worker.tomcat2.type=ajp13
worker.tomcat2.lbfactor=1

# Load-balancingワーカー
worker.loadbalancer.type=lb
worker.loadbalancer.balanced_workers=tomcat1,tomcat2
worker.loadbalancer.sticky_session=1


!!!
worker.loadbalancer.type=lb
worker.loadbalancer.balance_workers=node1,node2
worker.loadbalancer.sticky_session=True
#worker.loadbalancer.sticky_session_force=True

We’re defining a worker named loadbalancer with it’s type set to lb (obviously short for loadbalancer) and assign node1 and node2 to handle the load.

Sticky sessions are an important feature if you rely on jSessionIDs and are not using any session-replication layer. If sticky_session is True a request always gets routed back to the node which assigned this jSessionID. If that host should get disconnected, crash or become unreachable otherwise the request will be forwarded to another host in our cluster (although not too successfully as the session-id is invalid in it’s context).
You can prevent this from happening by setting sticky_session_force to True. In this case if the host handling the requested session-id fails, Apache will generate an internal server error 500.

Now we’ve told mod_jk about our setup. If you are using sticky sessions, you’ll need to tell Tomcat to append its node-id to the session id. This needs to be the same as worker.name.jvm_route, which by default is the worker’s name (in our case node1 and node2).



tomcatのserver.xml:
 <!-- You should set jvmRoute to support load-balancing via AJP ie :-->
<Engine name="Catalina" defaultHost="localhost" jvmRoute="tomcat1">
<Engine name="Catalina" defaultHost="localhost" jvmRoute="tomcat2">

2013/07/09

apache httpd.confの設定

★Apacheは、モジュールによって機能を追加する。組み込まれているモジュールは、以下のようにして確認できる
/usr/sbin/httpd -l
  core.c
  prefork.c ーープロセス
  http_core.c
  mod_so.c
 
Apache 2.0ではDSO(Dynamic Shared Object)を利用し、
実行時にモジュールを組み込む。
LoadModule php5_module modules/libphp5.so

★コンパイルオプション(稼働モードなど)を確認できる
/usr/sbin/httpd -V ←「-V」でコンパイルオプションを確認
Server version: Apache/2.0.54
Server built:   May 23 2005 08:12:24
Server's Module Magic Number: 20020903:9
Architecture:   32-bit
Server compiled with....
 -D APACHE_MPM_DIR="server/mpm/prefork" ←preforkになっている
 -D APR_HAS_SENDFILE
 -D APR_HAS_MMAP

★httpdの設定のみをチェックする
# /usr/sbin/httpd -t

★プロセス数関する設定
<IfModule prefork.c>
StartServers       8 立ち上げた際に最初に起動するプロセス数
MinSpareServers    5
MaxSpareServers   20 常時待機しているようにプロセス数
ServerLimit      256
MaxClients       256 上限プロセス数
MaxRequestsPerChild  4000 プロセスを定期的に再起動させる
     処理中、メモリーの申請と放棄繰り返し、メモリーの利用効率が悪くなる。
     一定回数に達すると、使い捨て。
</IfModule>
MaxClients=使用可能なメモリ量/Apacheの1プロセスが使用するメモリ量
難しい作業ね。1プロセスは、経験的には、静的コンテツの場合で数Mbytes、動的コンテンツで20?30Mbytes
値を少しずつ上げていき、vmstatやtopなどのコマンドでスワップへの書き込みが発生しない値にする
psコマンドでは、「VSZ 仮想」と「RSS物理」の値に注目
topコマンドの場合は、「VIRT仮想」と「RES物理」の値に注目

★Apache 2.0のデフォルト設定はプロセスベースの処理になっているため、
スレッドを使用する時、下記を修正する
/etc/sysconfig/httpd
  HTTPD=/usr/sbin/httpd.worker ←httpdかhttpd.workerを指定
スレッドの設定
<IfModule worker.c>
ServerLimit   プロセス
StartServers         2  プロセス
MaxClients         150  thread
MinSpareThreads     25
MaxSpareThreads     75
ThreadsPerChild     25 1つのプロセスで生成されるスレッド数
MaxRequestsPerChild  0
</IfModule>
MaxClients数=ThreadsPerChild数×プロセス数

★セキュリティ設定
・OS情報
ServerTokens ProductOnly
ServerSignature Off

<Directory />
(省略)
AllowOverride None ←.htaccessによる制限上書きを禁止
</Directory>

2013/07/01

2013/06/18

apacheとtomcatの連携

★apache側の設定:
httpd.conf
-------------
Listen 80
ServerName 名前
Include conf.d/*.conf==>別の設定ファイルを使う、httpdから相対パス
#連携用のモジュール
LoadModule proxy_module modules/mod_proxy.so
LoadModule proxy_balancer_module modules/mod_proxy_balancer.so
LoadModule proxy_ajp_module modules/mod_proxy_ajp.so
LoadModule proxy_connect_module modules/mod_proxy_connect.so
LoadModule cache_module modules/mod_cache.so
LoadModule jk_module modules/mod_jk.so
#location アクセス制限、ここが注意!
AllowとDenyの優先順位で、最終の判断で決める
Order deny,allow=>すべて許可
Order allow,deny=>すべて拒否
<Location /path/ >
    Order Deny,Allow
    Deny from all
    Allow from IPs
</Location>
#ここだ。。。。。mappingの設定
<IfModule mod_jk.c>
  JkWorkersFile conf.d/worker.properties
  ここも注意!「/パス」と「/パス/*」は違う物。。。
  JkMount /パス  tomcatN
  JkMount /パス/*  tomcatN
  JkLogFile "|/usr/sbin/rotatelogs  /var/log/httpd/jk_log.%Y-%m-%d 86400 540"
</IfModule>
worker.list=tomcatN
worker.tomcatN.port=
worker.tomcatN.host=
worker.tomcatN.type=ajp13
-------------

★tomcat側の設定
server.xml
-----------
<Connector port="8009"
               protocol="AJP/1.3" ここ、本来はHTTP/1.1だったが、AJPに修正する
               redirectPort="8443"
               useBodyEncodingForURI="true" />
-----------